Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
haskell linked list
data List a = Nil | Cons a (List a) instance (Show a) => Show (List a) where show Nil = "Nil" show (Cons p l) = "(" ++ show p ++ ", " ++ show l ++ ")" fromlst :: [a] -> List a fromlst [] = Nil fromlst (p:q) = Cons p (fromlst q) tolst :: List a -> [a] tolst Nil = [] tolst (Cons p q) = p : tolst q main :: IO () main = do let n = fromlst [1..10] :: List Int putStrLn . show $ n putStr . show . tolst $ n
run
|
edit
|
history
|
help
0
Hanoi solver
Goodstein sequences
haskell fibonacci
Pi
Invert a monotonic function
project euler 3, haskell
haskell_exam
Factors of a number, prime numbers
Cubed
Derive type class for parameterized data type