Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Clean

Name: Anonymous 2009-01-01 14:40

Does anyone use Haskell Clean?
Its faster then GHC

Name: Anonymous 2009-01-01 17:20

[code]import Control.Monad.ST
import Control.Monad
import Data.STRef

whileM cond action = do
    action
    b <- cond
    if b then whileM cond action else return ()

factorial n = do
    acc <- newSTRef 1
    i <- newSTRef 1
    whileM (do liftM (<= n) $ readSTRef i) $ do
        i' <- readSTRef i
        modifySTRef acc (*i')
        modifySTRef i (+1)
        return ()
    readSTRef acc

main = print (runST $ factorial 7)[code]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List