fork download
  1. data MyList a = Nil | Cons a (MyList a) deriving (Eq,Ord,Show,Read)
  2.  
  3. range n m |n == m = Cons m Nil
  4. range n m = Cons n (range (n + 1) m)
  5.  
  6. myfoldl _ v Nil = v
  7. myfoldl f v (Cons x xs) = myfoldl f (f v x) xs
  8.  
  9. myreverse = myfoldl (\ys x -> Cons x ys) Nil
  10.  
  11. myhead (Cons x _) = x
  12.  
  13. main = print (myhead (myreverse (range 1 1000000)))
Success #stdin #stdout 0.27s 32384KB
stdin
Standard input is empty
stdout
1000000