*Main> zip [0 ..] "abc" [(0,'a'),(1,'b'),(2,'c')] *Main> :t and and :: Foldable t => t Bool -> Bool *Main> and [] True *Main> and [True, False] False *Main> and [True, True] True *Main> and [True] True *Main> and [False] False *Main> or [] False *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> take 10 primes [2,3,5,7,11,13,17,19,23,29] *Main> take 100 primes [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> fib 4 3 *Main> fib 5 5 *Main> fib 10 55 *Main> fib 100 C-c C-cInterrupted. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> fib' 5 0 1 5 *Main> fib 5 5 *Main> fib 10 55 *Main> fib' 10 0 1 55 *Main> fib' 100 0 1 3736710778780434371 *Main> fib' 1000 0 1 817770325994397771 *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> fib' 1000 0 1 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875 *Main> :t (:) (:) :: a -> [a] -> [a] *Main> 1:[] [1] *Main> 2:1:[] [2,1] *Main> :t zipWith zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> take 10 fibs [0,1,1,2,3,5,8,13,21,34] *Main> take 100 fibs [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,5527939700884757,8944394323791464,14472334024676221,23416728348467685,37889062373143906,61305790721611591,99194853094755497,160500643816367088,259695496911122585,420196140727489673,679891637638612258,1100087778366101931,1779979416004714189,2880067194370816120,4660046610375530309,7540113804746346429,-6246583658587674878,1293530146158671551,-4953053512429003327,-3659523366270331776,-8612576878699335103,6174643828739884737,-2437933049959450366] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> take 20 fibs [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> Cons 1 Nil Cons 1 Nil *Main> Cons 2 (Cons 1 Nil) Cons 2 (Cons 1 Nil) *Main> [2, 1] [2,1] *Main> :t Cons Cons :: a -> List a -> List a *Main> :t Nil Nil :: List a *Main> P True "abc" P True "abc" *Main> :t P True "abc" P True "abc" :: Pair Bool [Char] *Main> :t (True, "abc") (True, "abc") :: (Bool, [Char]) *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) lec4.hs:71:36: error: • Occurs check: cannot construct the infinite type: b ~ Maybe b • In the expression: v In an equation for ‘lookup'’: lookup' k ((k', v) : xs) | k == k' = v • Relevant bindings include xs :: [(a, b)] (bound at lec4.hs:71:20) v :: b (bound at lec4.hs:71:17) lookup' :: a -> [(a, b)] -> Maybe b (bound at lec4.hs:70:1) | 71 | lookup' k ((k', v):xs) | k == k' = v | ^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :t Just Just :: a -> Maybe a *Main> :t Nothing Nothing :: Maybe a *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> lookup' 1 (zip [0 ..] "abcde") Just 'b' *Main> lookup' 5 (zip [0 ..] "abcde") Nothing *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> lookup'' 5 (zip [0 ..] "abcde") Left "404" *Main> :t Node Node :: a -> Tree a -> Tree a -> Tree a *Main> :t Empty Empty :: Tree a *Main> ;r :55:2: error: Parse error: module header, import declaration or top-level declaration expected. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> height tree0 2 *Main> height tree1 3