[Haskell-cafe] partially indeterminate?

Karl Voelker ktvoelker at gmail.com
Tue Jul 16 04:59:21 CEST 2013


I will suggest an analogy to a similar (but simpler) situation.

Suppose you are adding up some numbers.

foo = let { x = 3; y = 4; z = 5 } in x + y + z

That pattern only works if you know in advance how many numbers you are
going to add.

Otherwise, you need a function that works on a whole list of numbers:

sum = foldr (+) 0

So...the short answer to your question is: use recursion. The better answer
is: use library functions that do the recursion for you. You might want to
look at foldM:

http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Monad.html#v:foldM

-Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130715/7a6bb871/attachment.htm>


More information about the Haskell-Cafe mailing list