DEV Community

Discussion on: #100DaysOfHaskell: Start

Collapse
 
shadowdevil profile image
Shadow Devil

Very cool post!
I think the problem with repl.it is, that you have to have a "main :: IO ()" function that is being executed when running. You could do a short demonstration of your defined functions like this:

-- create list of x-steps n-times
-- e.g. 2 3 => [2,4,6]
countBy x n = [x | x <- [x, 2*x..n*x]]

-- create sum of all positive input numbers
-- e.g. [1, 2, -3] => 1 + 2 => 3
positiveSum xs = sum [ x | x <- xs, x > 0]

main:: IO ()
main = do
    putStrLn "countBy: Create list of x-steps n-times"
    putStrLn "e.g. 2 3 => [2,4,6]"
    print (countBy 2 3)
    putStrLn "positiveSum: Create sum of all positive input numbers"
    putStrLn "e.g. [1, 2, -3] => 1 + 2 => 3"
    print (positiveSum [1, 2, -3])
Enter fullscreen mode Exit fullscreen mode
Collapse
 
miku86 profile image
miku86

Thanks,
I will have a look at it!
I currently use :l main all the time.