50 likes | 223 Views
CS360 Lab 3. TA: Mark Boady Professor: Krzysztof Nowak. Homework 3. Flatten (different interpretations) Input: Normal List, Output: Delayed List Input: Delayed List, Output: Normal List Input: Delayed List, Output Delayed List Lambda Calculus
E N D
CS360 Lab 3 TA: Mark Boady Professor: Krzysztof Nowak
Homework 3 • Flatten (different interpretations) • Input: Normal List, Output: Delayed List • Input: Delayed List, Output: Normal List • Input: Delayed List, Output Delayed List • Lambda Calculus • A detailed walkthrough of question 3.39 is posted to section of the CS360 website • PA1 • A link to an example of the set! command for iterator on my CS360 website
Part 1 • Experiment with pyth.hs and primes.hs in haskell • To take the first 20 primes from the infinite list of primes. Prelude> :load primes [1 of 1] Compiling Main ( primes.hs, interpreted ) Ok, modules loaded: Main. *Main> take 20 primes [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71]
Part 2 • Mceval is a scheme interpreter running inside the scheme interpreter. • A subset of the basic functionality has be redefined • Append is defined here using the basic functionality that works in mceval • Run the code exactly as given • Remember to load the file
Part 3 & 4 • Part 3: Make sure your tree is balanced • Part 4: Haskell has easy Lambda Calc. syntax • In Lambda Calc. the first two Church Numerals • λs.λz. z for zero • λs.λz.(s z) for one • In Haskell • let zero = \s -> \z -> z • let one = \s -> \z -> (s z) • zero (+ 1) 0 • one (+ 1) 0