Idris-dev/test/basic003/test027.idr
Jan de Muijnck-Hughes 5ea6aa0520 Address semantic differences in putting things to STDOUT.
The changes are as follows:

+ `print` is for putting showable things to STDOUT.
+ `printLn` is for putting showable things to STDOUT with a new line
+ `putCharLn` for putting a single character to STDOUT, with a new line.

Effects has been updated accordingly.
2015-03-06 17:26:33 +00:00

26 lines
582 B
Idris

module Main
using (Ord a, Num n)
isort : List a -> List a
isort [] = []
isort (x :: xs) = insert x (isort xs)
where -- insert : a -> List a -> List a
insert x [] = [x]
insert x (y :: ys) = if x < y then x :: y :: ys
else y :: insert x ys
msum : Num n => List n -> n
msum [] = 0
msum (x :: xs) = x + msum xs
mprod : List n -> n
mprod [] = 1
mprod (x :: xs) = x * mprod xs
main : IO ()
main = do printLn $ isort [1,5,3,5,1,9,8]
printLn $ msum [1..10]
printLn $ mprod [1..10]