0

Well, I asked Dani and she said I could create a Haskell catagory in code snippits just by submitting a Haskell program :p . What self respecting code repository would be without one? So here goes, this program calculates the nth triangular number, given n by the user.

Steven.

module Main
      where

result x = foldr (+) 0 [1..read x]

main = do
putStrLn("Your input: ")
user_data <- getLine
putStrLn("My output: ")
print(result user_data)
3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Rashakil Fol
0

It's not good form to put the body of a 'do' block (or any other artifact) on the first row. It's probably illegal, and although GHC accepts the syntax, it won't let you put any more top-level definitions in the file.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.