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

Lambda calculus, Type theory, Formal semantics, Program analysis

Prev     Next     All lectures        Code

Lists, Conditions, Operations

 (define a1 'a) - Variable a1 is an atom (define a2 1) - a2 is a number (define a3 '(1 2 3)) - a3 is the list '(1 2 3) (define a4 (cons 0 a3)) - a4 extends list a3 by one element at the front (define a5 (append a4 '(a))) - a5 extends list a4 at the rear by appending a list (define a6 (car a5)) - a6 is the first element of the list a5 (define a7 (cdr a5)) - a7 is a5 with the first element removed (define a8 (cddr a5)) - a8 is a5 with the first two elements removed (define a9 (cdddr a5)) - a9 is a5 with the first three elements removed (define a10 (cadr a5)) - a10 is the second element of a5 (define a11 (caddr a5)) - a11 is the third element of a5 (define a12 (equal? (+ 1 1) 2)) - a12 is true (define a13 (< (+ 1 1) (- 3 1))) - a13 is false (define a14 (<= (+ 1 1) (- 3 1))) - a14 is true (define a15 (if (> (cadr a3) a6) 1 2)) - a15 is 1 (define a16 (if (> (cadr a3) 6) '(1 2 3) 23)) - a16 is 23 (define a17 (if (< (cadr a3) 6) '(1 2 3) 23)) - a17 is '(1 2 3)