---------------------------------------------------------------- -- Daan Leijen (c) 2001 -- -- $Revision$ -- $Author$ -- $Date$ ---------------------------------------------------------------- module Length where instruction primAddInt "addint" :: Int -> Int -> Int instruction primLeInt "leint" :: Int -> Int -> Bool data List a = Nil | Cons a (List a) data Bool = False | True addInt x y = case x of x -> case y of y -> primAddInt x y leInt x y = case x of x -> case y of y -> primLeInt x y length xs = let len n xs = case xs of Nil -> n Cons x xx -> case addInt n 1 of m -> len m xx in len 0 xs fromTo i n = case leInt i n of False -> Nil True -> Cons i (fromTo (addInt i 1) n) main = length (fromTo 1 100000)