Complete Haskell newbie here, my apologies….
I am trying to create a sequence of values out of another sequence and the last value generated (So it’s not completely obvious to me how I would use map).
In clojure I would use a loop construct which is basically equivalent to a recursive function. So I thought I could use this problem with a recursive function along the lines of
genSequence :: [a] -> [b] -> [a]
genSequence result [] = reverse result
genSequence a:as b:bs = genSequence ((computeNextA a b):a:as) bs
and I guess this isn’t so bad (the real function is of course more complicated …) but I read about monads (read the excellent tutorial by Philip Walder, then some stuff on monads in clojure) and can’t help the feeling that I should be using them here. So far my knowledge of monads is purely theoretical, unfortunately, so I would be very thankful if you could help me along.
Not sure if this helps, but something like (assuming that
computeNextAis+)is equivalent to