20-CS-4003-001 Organization of Programming Languages Fall 2017
Basic Operations

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures        Code


(define v1 (lambda () 2))  -  v1 is an expression
(define v2 (lambda (x) (+ x 2)))  -  v2 is an expression which takes an argument
(define v3 (lambda (x y) (+ x y)))  -  v3 is an expression which takes two arguments
(define v4 (lambda (x) (lambda (x y) (x y z))))  -  v4 is a closure
(define v5 (list (v1) (v2 42) (v3 1 2) (v4 cons)))  -  v5 is a crazy list
(define v6 (v4 cons))  -  v6 is a procedure
(define v7 (v4 +))  -  v7 is a different procedure
(define f1 (lambda (x)
   (if (= x 0) '() (cons x (f1 (- x 1))))
 -  f1 is a recursive procedure producing a list of numbers
(define f2 (lambda (x)
   (if (= x 0) '() (append (f2 (- x 1))
                               (list x)))
 -  f2 is like f1 but produces the list in reverse
(define f3* (lambda (x lst)
   (if (= x 0)
       (f3* (- x 1) (cons x lst)))))
 -  f3* is great
(define f3 (lambda (x)
   (f3* x '())))
 -  a11 is a list of the results above minus a10