On 4/12/13 5:40 PM, glen wrote:
Iteration is most aligned with stateful repetition. Recursion is most aligned with stateless repetition.
Purely functional constructs can capture iteration, though.

$ cat foo.hs
import Control.Monad.State
import Control.Monad.Loops

inc :: State Int Bool
inc = do i <- get
         put (i + 1)
         return (i < 10)

main = do
  putStrLn (show (runState (whileM inc get) 5))
$ ghc --make foo.hs
$ ./foo
([6,7,8,9,10],11)

============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com

Reply via email to