Commit c0f0f9ba authored by sof's avatar sof
Browse files

[project @ 1997-07-27 00:11:16 by sof]

parent c2a15491
--!! cg001: main = -42 -- take 1
main = print ( f () )
where
f :: a -> Int
f x = -42
main = print ((f id2) (10 + thirty_two))
where
f x = g x
where
g x = h x
where
h x = x
thirty_two :: Int
thirty_two = 32
id2 x = x
main = print (id2 (id2 id2) (42::Int))
-- where
-- id2 = s k k
-- id2 x = s k k x
id2 = s k k
s x y z = x z (y z)
k x y = x
main = print (length ([9,8,7,6,5,4,3,2,1] :: [Int]))
--!! answer: 65532
main = print foo
foo :: Int
foo = ((1 + 2 + 32767 - 4) * 6) --later? `div` 3
main = print (length thirteen_ones)
where
thirteen_ones = take (13::Int) ones
ones :: [Int]
ones = 1 : ones
data Tree a = Leaf a | Branch (Tree a) (Tree a)
main = print (height our_tree)
where
our_tree :: Tree Int
our_tree =
Branch (Branch (Leaf 1) (Branch (Branch (Leaf 1) (Leaf 1)) (Leaf 1)))
(Branch (Leaf 1) (Leaf 1))
height :: Tree a -> Int
height (Leaf _) = 1
height (Branch t1 t2) = 1 + max (height t1) (height t2)
main = print (length comp_list)
where
comp_list :: [(Int,Int)]
comp_list = [ (elem1,elem2)
| elem1 <- given_list,
elem2 <- given_list,
elem1 >= (4::Int),
elem2 < (3::Int)
]
given_list :: [Int]
given_list = [1,2,3,4,5,6,7,8,9]
main = print (length take_list)
where
take_list :: [Int]
take_list = takeWhile (\ x -> x < 6) given_list
given_list :: [Int]
given_list = [1,2,3,4,5,6,7,8,9]
main = print a
where
a :: Int
b :: Int
(a, b) = (3 + 4, 5 + 6)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment