POV-Ray : Newsgroups : povray.off-topic : My hypothesis : Re: My hypothesis Server Time
29 Jul 2024 14:26:02 EDT (-0400)
  Re: My hypothesis  
From: Warp
Date: 5 Sep 2011 12:01:36
Message: <4e64f25f@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Let's test that hypothesis. Consider the following example:

>    module Main where

>    import System.IO
>    import System.Random

>    main = do
>      x <- randomRIO (1, 100)
>      main_loop x

>    main_loop x = do
>      putStr "Guess: "
>      hFlush stdout
>      l <- getLine
>      let g = read l
>      if g == x
>        then putStrLn "Correct."
>        else do
>          if g < x
>            then putStrLn "Too low."
>            else putStrLn "Too high."
>          main_loop x

  That doesn't look functional at all. It looks imperative.

  Throw in some functional tricks (such as infinite lists, currying and
such) and it becomes harder to figure out.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.