Category "iteration"

Why does converting the factorial function to iterative form by defunctionalizing the continuation give such a bad result?

I'm trying the "defunctionalize the continuation" technique on some recursive functions, to see if I can get a good iterative version to pop out. Following alon

How to convert an XML structured-like object to a JSON string in Java?

So I have an XML structured object (Java) and need some help to convert it to a JSON string without using any library and in an iterative way. E.g <root>

Python fuctional style iterative algoritm?

In Haskell there is a simple list function available iterate :: (a -> a) -> a -> [a] iterate f x = x : iterate f (f x) In python it could be implemen

How to start iterating a file at specific line?

I’m iterating through a file’s lines with enumerate(), and sometimes would need to start the iterating at a specific file line, so I attempted testf

In Rust, is there a way to iterate through the values of an enum?

I come from a Java background and I might have something like enum Direction { NORTH, SOUTH, EAST, WEST} and I could do something with each of the values in tur

Iterate the values from the List and get oldest, newest dates

I am working on spring application. I am having a LinkedHashMap<Integer, List<MyDTO>> object, in the value of the map (i.e,List<MyDTO>) I hav

Executing function upon required number of times

calculate the sum of squares of given integers, excluding any negatives. The first line of the input will be an integer N (1 <= N <= 100), indicating the