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

my first haskell program

Name: Anonymous 2012-05-25 23:27

tell me what you think, /prog/


modulus x y  =
    if x > y
        then modulus (x-y) y
        else x

fizzbuzz x y =
    if (x<=100) then
        do
            if ((mod x 15)==0)
                then putStrLn "fizzbuzz"
                else if ((mod x 5)==0) then putStrLn "buzz"
                else if ((mod x 3)==0) then putStrLn "fizz"
                else print x
            fizzbuzz (x+1) y
        else return()

main = fizzbuzz 1 100

Name: Anonymous 2012-05-26 7:10


fizzbuzz = map fb [1..]
    where
    fb n | n `mod`  3 == 0 = "Fizz"
         | n `mod`  5 == 0 = "Buzz"
         | n `mod` 15 == 0 = "FizzBuzz"
         | otherwise       = show n

main = mapM_ putStrLn $ take 100 fizzbuzz

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