I use Haskell for my programming during leisure these days. Being a programmer in imperative languages for over 8 years, it is tough to wrap my head around some functional constructs (especially the folds). I was solving a problem from project Euler, and happened to produce the following code.
f (num, den) s | num*10 < den = s
| otherwise = f (ratio (num, den) s') s'
where s' = (s+2)
Can this explicit recursion be rewritten using folds or some other functional construct? The main hurdle for me in using a fold was to come up with the step function. Eventually I gave up, and resorted to the recursion.
EDIT: Also, how do I make the output returned by another function within a function as the input to the calling function without explicit recursion?
untilto me