ghc -e 'let hw = let zhw = zip "hello" "world"; h = [fst x | x <- zhw]; w = [snd y | y <- zhw] in h ++ " " ++ w' -e 'hw'
Tag Archives: haskell
haskell factorial function
ghc -e 'let {factorial 0 = 1; factorial n | n > 0 = product [1..n]; factorial n | n < 0 = (-1) * factorial (-n); factorial -n = (-1) * factorial n; }' -e 'factorial 5' -e 'factorial -6' -e 'factorial (-7)'
haskell one liners begin with -e
ghc -e 'let hw (x,y) = x ++ " " ++ y' -e 'hw (unzip (zip "hello" "world"))'