Commits

anon...@cec68495-dca5-4e2b-845c-11fdaaa4f967  committed e05c118

Removed LC - it is autogenerated from something else.

  • Participants
  • Parent commits 8950aed

Comments (0)

Files changed (49)

File vipe/lecture/Lambda-Calculus/.refs_n_links.html.swp

Binary file removed.

File vipe/lecture/Lambda-Calculus/Untitled.html

-<html>
-<head>
-<title>~/public_html/lecture/Lambda-Calculus/Untitled.html</title>
-<meta name="Generator" content="Vim/6.0">
-</head>
-<body bgcolor="#ffffff" text="#000000">
-<pre>
-
-</pre>
-</body>
-</html>

File vipe/lecture/Lambda-Calculus/code/Y_test.scm

-(load "church_test.scm")
-
-
-(define Y
-(lambda (f)
-        (
-                (lambda (x)
-                        (f (lambda (y) ((x x) y)))
-                )
-                (lambda (x)
-                        (f (lambda (y) ((x x) y)))
-                )
-        )
-))
-
-(define (top x) (car x))
-(define (var x) (cadr x))
-(define (result x) (caddr x))
-(define mysum
-(Y (lambda (f)
-	(lambda (x)
-		(if (<= (var x) (top x))
-		        ;
-			(f (list (top x) (+ (var x) 1) (+ (result x) (var x))))
-			x
-		)
-	)
-)))
-
-(define solution (mysum (list 10 5 0)))
-(display "The solution is: ")
-(display (result solution))
-(newline)
-	
-(define (top x) (lc_car x))
-(define (var x) (lc_car (lc_cdr x)))
-(define (result x) (lc_car (lc_cdr (lc_cdr x))))
-
-(define make-mysum-list
-(lambda (top)
-	(lambda (var)
-		(lambda (result)
-			((lc_cons top) ((lc_cons var) ((lc_cons result) zero)))
-		)
-	)
-))
-
-(define mysum
-(Y (lambda (f)
-	(lambda (x)
-		(((((less-or-equal (var x)) (top x))     ; If var x < top x
-			(lambda (no_use)
-			(f 
-				(((make-mysum-list 
-					(top x)) 
-					(succ (var x))) 
-					((add (result x)) (var x)))
-			)
-			))
-			(lambda (no_use)
-				x
-			)) 
-				zero ;  Pass zero as argument to no_use
-			)
-		)
-	)
-))
-
-(define solution (mysum 
-	(((make-mysum-list 
-		(int->church 10))
-		(int->church 5))
-		(int->church 0))
-		))
-
-(display "The solution is: ")
-(display (church->int (result solution)))
-(newline)
-

File vipe/lecture/Lambda-Calculus/code/church_test.scm

-(define zero (lambda (f) (lambda (x) x)))
-
-(define (church->int church)
-	((church (lambda (a) (+ a 1))) 0)
-)
-
-(define succ 
-(lambda (n) 
-	(lambda (f) 
-		(lambda (x) 
-			(f ((n f) x))
-		)
-	)
-))
-
-(define (int->church n)
-	(if (= n 0)
-		zero
-		(succ (int->church (- n 1)))
-	)
-)
-
-(define add
-(lambda (n)
-	(lambda (m)
-		((n succ) m)
-	)	
-))
-
-(define mult
-(lambda (m)
-	(lambda (n)
-		(lambda (f)
-			(m (n f))
-		)
-	)
-))
-
-(define power
-(lambda (m)
-	(lambda (n)
-		((n (mult m)) (succ zero))
-	)
-))
-
-(define c2 (int->church 2))
-(define c3 (int->church 3))
-(define c5 (int->church 5))
-(define c6 (int->church 6))
-
-(display "0^0 is ")
-(display (church->int ((power zero) zero)))
-(newline)
-
-(define lc_true  (lambda (x) (lambda (y) x)))
-(define lc_false (lambda (x) (lambda (y) y)))
-
-(define lc_cons
-(lambda (mycar)
-	(lambda (mycdr)
-		; we return this lambda-expression:
-		(lambda (which)
-			((which mycar) mycdr)
-		)
-	)
-))
-
-(define lc_car
-(lambda (tuple)
-	(tuple lc_true)
-))
-
-(define lc_cdr
-(lambda (tuple)
-	(tuple lc_false)
-))
-
-(define pred_next_tuple
-(lambda (tuple)
-	((lc_cons
-		(lc_cdr tuple))
-		(succ (lc_cdr tuple)))
-))
-
-(define pred
-(lambda (n)
-	(lc_car 
-		((n pred_next_tuple) 
-			((lc_cons zero) zero)
-		)
-	)
-))
-
-(define subtract
-(lambda (n)
-	(lambda (m)
-		((m pred) n)
-	)
-))
-
-(define is-zero?
-(lambda (n)
-        ((n (lambda (x) lc_false)) lc_true)
-))
-
-(define less-or-equal
-(lambda (x)
-        (lambda (y)
-                (is-zero? ((subtract x) y))
-        )
-))
-

File vipe/lecture/Lambda-Calculus/code/cond_test.scm

-(define a 5)
-(cond ((= a 3) (begin (display a) (display "is equal to 3") (newline)))
-      ((

File vipe/lecture/Lambda-Calculus/code/div_test.scm

-(load "while_test.scm")
-
-(define greater-or-equal
-(lambda (x)
-	(lambda (y)
-		((less-or-equal y) x)
-	)
-))
-
-(define reminder_helper
-(Y (lambda (f)
-	(lambda (x)
-		(((lambda (div)
-			(lambda (div_by)
-				(((((greater-or-equal div) div_by)
-					(lambda (no_use)
-						(f ((lc_cons 
-							((subtract div) div_by))
-							div_by))
-					))
-					(lambda (no_use)
-						div
-					))
-					zero
-				)
-			)
-		) (lc_car x)) (lc_cdr x))
-	)
-)))
-
-(define reminder
-(lambda (div)
-	(lambda (div_by)
-		(reminder_helper ((lc_cons div) div_by))
-	)
-))
-
-(define reminder2
-(lambda (div)
-    (lambda (div_by)
-        ((Y (lambda (f)
-            (lambda (x)
-                (((((greater-or-equal x) div_by)  ; We can still see div_by
-                    (lambda (no_use)
-                        (f ((subtract x) div_by))
-                    ))
-                    (lambda (no_use)
-                        x
-                    )
-                )
-                    zero)    ; Pass zero as an argument to no_use
-            )
-        ))
-            div)  ; Pass div as the initial x
-    )
-))
-
-
-(display (church->int ((reminder (int->church 100)) (int->church 9))))
-(newline)
-
-;(define (div_get_counter tuple) (lc_car tuple))
-;(define (div_get_number tuple) (lc_car (lc_cdr tuple)))
-;(define (div_get_div_by tuple) (lc_car (lc_cdr (lc_cdr tuple))))
-
-(define divide_helper 
-(Y (lambda (f)
-	(lambda (x)
-		(((lambda (div)
-			(lambda (div_by)
-				(((((greater-or-equal div) div_by)
-					(lambda (no_use)
-						(succ (f ((lc_cons 
-							((subtract div) div_by)) 
-							div_by)))
-					))
-					(lambda (no_use)
-						zero
-					))
-					zero
-				)
-			)
-		) (lc_car x)) (lc_cdr x))
-	)
-)))
-
-(define divide
-(lambda (div)
-	(lambda (div_by)
-		(divide_helper ((lc_cons div) div_by))
-	)
-))
-
-(define divide2
-(lambda (div)
-    (lambda (div_by)
-        ((Y (lambda (f)
-            (lambda (x)
-                (((((greater-or-equal x) div_by)  
-                    (lambda (no_use)
-                        (succ (f ((subtract x) div_by)))
-                    ))
-                    (lambda (no_use)
-                        zero
-                    )
-                )
-                    zero)    ; Pass zero as an argument to no_use
-            )
-        ))
-            div)  ; Pass div as the initial x
-    )
-))
-
-(display "50/8=")
-(display (church->int ((divide (int->church 50)) (int->church 8))))
-(newline)
-
-(display "divide2: 50/8=")
-(display (church->int ((divide2 (int->church 50)) (int->church 8))))
-(newline)

File vipe/lecture/Lambda-Calculus/code/funcs_test1.scm

-(define myfunc 0)
-(set! myfunc (lambda (h) (* 3 h)))
-
-(define twice (lambda (func x)
-	(func (func x))
-))
-
-(display (twice myfunc 2))
-(newline)

File vipe/lecture/Lambda-Calculus/code/hello.scm

-(define make-counter
-(lambda (s)
-	(define increment
-	(lambda ()
-		(set! s (+ s 1))
-		s
-	))
-	increment
-))

File vipe/lecture/Lambda-Calculus/code/sequence_test.scm

-(define (f1 x) (display 5) 0)
-(define (f2 x) (display "+") 0)
-(define (f3 x) (display 6) 0)
-(define (f4 x) (display "=") 0)
-(define (f5 x) (display 11) 0)
-(define (f6 x) (newline) 0)
-
-(define my_seq
-(lambda (x)
-	(f6 (f5 (f4 (f3 (f2 (f1 x))))))
-))
-
-(my_seq 0)

File vipe/lecture/Lambda-Calculus/code/test.scm

-(load "div_test.scm")
-
-(newline)
-(display "Result is : ")
-(display (church->int ((reminder (int->church 100)) (int->church 7))))
-(newline)

File vipe/lecture/Lambda-Calculus/code/while_test.scm

-(load "Y_test.scm")
-
-(define lc_while
-(lambda (mycond)
-	(lambda (oper)
-		(lambda (initial_value)
-			((Y (lambda (f)
-				(lambda (x)
-					((((mycond x)
-						(lambda (no_use)
-							(f (oper x))
-						))
-						(lambda (no_use)
-							x
-						)
-					) zero)
-				)
-			)) initial_value)
-		)
-	)
-))
-
-(define (_cond x) (if (> x 5) lc_false lc_true))
-(define (_oper x) 
-	(display x)
-	(newline)
-	(+ x 1)
-)
-(((lc_while _cond) _oper) 0)
-
-
-(define _cond
-(lambda (x)
-	((less-or-equal x) (int->church 10))
-))
-
-(define _oper
-(lambda (x)
-	((mult x) (int->church 2))
-))
-
-(define a (((lc_while _cond) _oper) (int->church 1)))
-
-(display "a = ")
-(display (church->int a))
-(newline)
-

File vipe/lecture/Lambda-Calculus/code/y_test.scm

-(load "church_test.scm")
-
-
-(define Y
-(lambda (f)
-        (
-                (lambda (x)
-                        (f (lambda (y) ((x x) y)))
-                )
-                (lambda (x)
-                        (f (lambda (y) ((x x) y)))
-                )
-        )
-))
-
-(define (top x) (car x))
-(define (var x) (cadr x))
-(define (result x) (caddr x))
-(define mysum
-(Y (lambda (f)
-	(lambda (x)
-		(if (<= (var x) (top x))
-		        ;
-			(f (list (top x) (+ (var x) 1) (+ (result x) (var x))))
-			x
-		)
-	)
-)))
-
-(define solution (mysum (list 10 5 0)))
-(display "The solution is: ")
-(display (result solution))
-(newline)
-	
-(define (top x) (lc_car x))
-(define (var x) (lc_car (lc_cdr x)))
-(define (result x) (lc_car (lc_cdr (lc_cdr x))))
-
-(define make-mysum-list
-(lambda (top)
-	(lambda (var)
-		(lambda (result)
-			((lc_cons top) ((lc_cons var) ((lc_cons result) zero)))
-		)
-	)
-))
-
-(define mysum
-(Y (lambda (f)
-	(lambda (x)
-		(((((less-or-equal (var x)) (top x))     ; If var x < top x
-			(lambda (no_use)
-			(f 
-				(((make-mysum-list 
-					(top x)) 
-					(succ (var x))) 
-					((add (result x)) (var x)))
-			)
-			))
-			(lambda (no_use)
-				x
-			)) 
-				zero ;  Pass zero as argument to no_use
-			)
-		)
-	)
-))
-
-(define solution (mysum 
-	(((make-mysum-list 
-		(int->church 10))
-		(int->church 5))
-		(int->church 0))
-		))
-
-(display "The solution is: ")
-(display (church->int (result solution)))
-(newline)
-

File vipe/lecture/Lambda-Calculus/cond.scm

-; Conditionals
-; ------------
-
-; Use the if statement to put a conditional.
-; Syntax:
-; (if cond [true statement] [optional false statement])
-
-(define a 50)
-(define b 30)
-(if (< a b)
-    (display "a is lesser than b")
-    (display "a is not lesser than b")
-)
-
-; Note: there can only be _one_ statement in the if conditionals. If you want
-; to execute more than one statement use the "begin" construct. "begin" packs 
-; a few statements into one statement (and returns the value of the 
-; last statement.
-
-(if (< a b)
-    (begin
-        (display a)
-        (display " is lesser than ")
-        (display b)
-        (newline)
-    )
-)
-
-; The if returns the value of the expression that was executed.
-(define max-of-a-and-b (if (> a b) a b))
-
-

File vipe/lecture/Lambda-Calculus/cond.scm.html

-<HTML>
-<HEAD>
-<TITLE>cond.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Conditionals</FONT>
-<FONT color=#0000ff>; ------------</FONT>
-
-<FONT color=#0000ff>; Use the if statement to put a conditional.</FONT>
-<FONT color=#0000ff>; Syntax:</FONT>
-<FONT color=#0000ff>; (if cond [true statement] [optional false statement])</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> a <FONT color=#ff00ff>50</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> b <FONT color=#ff00ff>30</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>&lt;</FONT> a b<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;a is lesser than b&quot;</FONT><FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;a is not lesser than b&quot;</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Note: there can only be _one_ statement in the if conditionals. If you want</FONT>
-<FONT color=#0000ff>; to execute more than one statement use the &quot;begin&quot; construct. &quot;begin&quot; packs </FONT>
-<FONT color=#0000ff>; a few statements into one statement (and returns the value of the </FONT>
-<FONT color=#0000ff>; last statement.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>&lt;</FONT> a b<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>begin</FONT></B>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> a<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot; is lesser than &quot;</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> b<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; The if returns the value of the expression that was executed.</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> max-of-a-and-b <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>&gt;</FONT> a b<FONT color=#6a5acd>)</FONT> a b<FONT color=#6a5acd>))</FONT>
-
-
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/cond_funcs_loops.scm

-; Conditionals
-; ------------
-
-; Use the if statement to put a conditional.
-; Syntax:
-; (if cond [true statement] [optional false statement])
-
-(define a 50)
-(define b 30)
-(if (< a b)
-    (display "a is lesser than b")
-    (display "a is not lesser than b")
-)
-
-; Note: there can only be _one_ statement in the if conditionals. If you want
-; to execute more than one statement use the "begin" construct. "begin" packs a ; few statements into one statement (and returns the value of the 
-; last statement.
-
-(if (< a b)
-    (begin
-    	(display a)
-	(display " is lesser than ")
-	(display b)
-	(newline)
-    )
-)
-
-; The if returns the value of the expression that was executed.
-(define max (if (> a b) a b))
-
-

File vipe/lecture/Lambda-Calculus/funcs.scm

-; Functions
-; ---------
-
-; use the "lambda" keyword to define an anonymous function.
-
-(define pythagoras 
-    (lambda (a b)
-        (sqrt 
-            (+ 
-                (* a a) 
-                (* b b)
-            )
-        )
-    )
-)
-
-(display (pythagoras 3 4))
-(newline)
-; Displays 5
-
-; Note: you can declare a lambda and execute it in the same statement:
-
-(define myvar ((lambda (a) (* 2 a)) 10))
-; myvar will be set to 20
-
-; A function executes all the statements inside it and returns the last statement.
-
-(define myfunc 
-    (lambda (a b)
-        (display a)
-        (display "+")
-        (display b)
-        (display "=")
-        (+ a b)
-    )
-)
-
-(display (myfunc 5 6))
-(newline)
-;Will display:
-;5+6=11
-
-; More about "define" and "set!"
-; ------------------------------
-
-; A define inside a function will only be visible inside that function.
-; Assuming a variable of the same name was defined in the outside, it will 
-; be restored to the same value as soon as the function terminates.
-
-(define a 500)
-
-(define myfunc
-    (lambda ()
-        (define a 6)
-        (display a)
-        (newline)
-    )
-)
-
-(myfunc)
-(display a)
-(newline)
-
-; A function can see all the variables that were defined on the outside.
-
-; set! sets the variable that is most closest to the current scope. (hence 
-; is in the inner-most scope).
-
-(define a "a_old_value")
-(define b "b_old_value")
-
-(define myfunc
-    (lambda ()
-        (define a 30)
-        (set! a "a_new_value")
-        (set! b "b_new_value")
-    )
-)
-
-(display a)
-(newline)
-(display b)
-(newline)
-
-; This code will print:
-; a_old_value
-; b_new_value
-
-; Functions inside functions
-; --------------------------
-
-; One can define functions inside functions. Those functions can see the
-; variables of the outer functions even after those functions terminated.
-; This behaviour is called lexical scoping.
-
-(define display_sums 
-    (lambda (a b c d e f)
-        (define display_sum 
-            (lambda (one two)
-                (display one)
-                (display "+")
-                (display two)
-                (display "=")
-                (display (+ one two))
-                (newline)
-            )
-        )
-        (display_sum a b)
-        (display_sum c d)
-        (display_sum e f)
-    )
-)
-
-(if #f
-    (display_sum 5 6) ; Error!, display_sum is not defined in this scope.
-)
-
-
-
-
-(define make-counter
-    (lambda (start_from)
-        (define increment
-            (lambda ()
-                (set! start_from (+ start_from 1))
-                start_from
-            )
-        )
-        increment
-    )
-)
-
-(define counter (make-counter 100))
-(display (counter))
-(newline)
-(display (counter))
-(newline)
-; This code will print:
-; 100
-; 101
-
-;;; Now let's define a second counter
-(define second-counter (make-counter 100))
-(display (second-counter))
-(newline)
-(display (counter))
-(newline)
-
-; Lambdas are regular variables
-; -----------------------------
-
-; You can pass them around. For example:
-
-(define myfunc 0)
-(set! myfunc (lambda (h) (* 3 h)))
-
-(define twice (lambda (func x)
-    (func (func x))
-))
-
-(display (twice myfunc 2))
-(newline)
-
-; This will print 18

File vipe/lecture/Lambda-Calculus/funcs.scm.html

-<HTML>
-<HEAD>
-<TITLE>funcs.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Functions</FONT>
-<FONT color=#0000ff>; ---------</FONT>
-
-<FONT color=#0000ff>; use the &quot;lambda&quot; keyword to define an anonymous function.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> pythagoras 
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>a b<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>sqrt</FONT> 
-            <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> 
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>*</FONT> a a<FONT color=#6a5acd>)</FONT> 
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>*</FONT> b b<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>pythagoras <FONT color=#ff00ff>3</FONT> <FONT color=#ff00ff>4</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>; Displays 5</FONT>
-
-<FONT color=#0000ff>; Note: you can declare a lambda and execute it in the same statement:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> myvar <FONT color=#6a5acd>((</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>a<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>*</FONT> <FONT color=#ff00ff>2</FONT> a<FONT color=#6a5acd>))</FONT> <FONT color=#ff00ff>10</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#0000ff>; myvar will be set to 20</FONT>
-
-<FONT color=#0000ff>; A function executes all the statements inside it and returns the last statement.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> myfunc 
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>a b<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> a<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;+&quot;</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> b<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;=&quot;</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> a b<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>myfunc <FONT color=#ff00ff>5</FONT> <FONT color=#ff00ff>6</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>;Will display:</FONT>
-<FONT color=#0000ff>;5+6=11</FONT>
-
-<FONT color=#0000ff>; More about &quot;define&quot; and &quot;set!&quot;</FONT>
-<FONT color=#0000ff>; ------------------------------</FONT>
-
-<FONT color=#0000ff>; A define inside a function will only be visible inside that function.</FONT>
-<FONT color=#0000ff>; Assuming a variable of the same name was defined in the outside, it will </FONT>
-<FONT color=#0000ff>; be restored to the same value as soon as the function terminates.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> a <FONT color=#ff00ff>500</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> myfunc
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>()</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> a <FONT color=#ff00ff>6</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> a<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT>myfunc<FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> a<FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; A function can see all the variables that were defined on the outside.</FONT>
-
-<FONT color=#0000ff>; set! sets the variable that is most closest to the current scope. (hence </FONT>
-<FONT color=#0000ff>; is in the inner-most scope).</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> a <FONT color=#ff00ff>&quot;a_old_value&quot;</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> b <FONT color=#ff00ff>&quot;b_old_value&quot;</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> myfunc
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>()</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> a <FONT color=#ff00ff>30</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>set!</FONT></B> a <FONT color=#ff00ff>&quot;a_new_value&quot;</FONT><FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>set!</FONT></B> b <FONT color=#ff00ff>&quot;b_new_value&quot;</FONT><FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> a<FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> b<FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; This code will print:</FONT>
-<FONT color=#0000ff>; a_old_value</FONT>
-<FONT color=#0000ff>; b_new_value</FONT>
-
-<FONT color=#0000ff>; Functions inside functions</FONT>
-<FONT color=#0000ff>; --------------------------</FONT>
-
-<FONT color=#0000ff>; One can define functions inside functions. Those functions can see the</FONT>
-<FONT color=#0000ff>; variables of the outer functions even after those functions terminated.</FONT>
-<FONT color=#0000ff>; This behaviour is called lexical scoping.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> display_sums 
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>a b c d e f<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> display_sum 
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>one two<FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> one<FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;+&quot;</FONT><FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> two<FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;=&quot;</FONT><FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> one two<FONT color=#6a5acd>))</FONT>
-                <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>display_sum a b<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>display_sum c d<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>display_sum e f<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#ff00ff>#f</FONT>
-    <FONT color=#6a5acd>(</FONT>display_sum <FONT color=#ff00ff>5</FONT> <FONT color=#ff00ff>6</FONT><FONT color=#6a5acd>)</FONT> <FONT color=#0000ff>; Error!, display_sum is not defined in this scope.</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-
-
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> make-counter
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>start_from<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> increment
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>()</FONT>
-                <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>set!</FONT></B> start_from <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> start_from <FONT color=#ff00ff>1</FONT><FONT color=#6a5acd>))</FONT>
-                start_from
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-        increment
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> counter <FONT color=#6a5acd>(</FONT>make-counter <FONT color=#ff00ff>100</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>counter<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>counter<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>; This code will print:</FONT>
-<FONT color=#0000ff>; 100</FONT>
-<FONT color=#0000ff>; 101</FONT>
-
-<FONT color=#0000ff>;;; Now let's define a second counter</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> second-counter <FONT color=#6a5acd>(</FONT>make-counter <FONT color=#ff00ff>100</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>second-counter<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>counter<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Lambdas are regular variables</FONT>
-<FONT color=#0000ff>; -----------------------------</FONT>
-
-<FONT color=#0000ff>; You can pass them around. For example:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> myfunc <FONT color=#ff00ff>0</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>set!</FONT></B> myfunc <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>h<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>*</FONT> <FONT color=#ff00ff>3</FONT> h<FONT color=#6a5acd>)))</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> twice <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>func x<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT>func <FONT color=#6a5acd>(</FONT>func x<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>))</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>twice myfunc <FONT color=#ff00ff>2</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; This will print 18</FONT>
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/gvimize.pl

-#!/usr/bin/perl
-
-#$gvim = "L:\\programs\\vim\\vim55\\gvim";
-#$vimruntime = "L:\\programs\\vim\\vim55";
-$gvim = "gvim";
-$vimruntime = "/usr/share/vim/vim58";
-
-open I, "index.old.html";
-while ($line = <I>)
-{
-	if ($line !~ /scm/)
-	{
-	}
-	else
-	{
-		$filename = $line;
-		chomp($filename);
-		$filename =~ s/^.*"([a-zA-Z_]*\.scm)".*$/$1/;
-		$title = $line;
-		chomp($title);
-		$title =~ s/^.*">//;
-		$title =~ s/<\/a>.*$//;
-		#print "<a href=\"$filename.html\">$title</a>" . ("\&nbsp;" x 8) .  " (<a href=\"$filename\">Scheme Code</a>)<br>\n";
-
-        my $dest_filename = $filename . ".html";
-        my @src_stat = stat($filename);
-        my @dest_stat = stat($dest_filename);
-        if ( (! -e $dest_filename) ||
-             ($src_stat[9] > $dest_stat[9])
-           )
-        {
-            # Do Nothing
-        }
-        else
-        {
-            next;
-        }
-            
-		
-        my @commands = ("syn on", "so $vimruntime/syntax/2html.vim", "wq", "q");
-        my $cmd_line = $gvim . " -f " . join(" ", (map { "+\"$_\"" } @commands)) . " " . $filename;
-        print "$cmd_line\n";
-        system($cmd_line);
-        # system("$gvim -f -c \"syn on\" -c \"so $vimruntime/syntax/2html.vim\" -c \"wq\" -c \"q\" $filename");
-        #exit();
-	}
-}
-close (I);

File vipe/lecture/Lambda-Calculus/htmlize.pl

-#!/usr/bin/perl
-
-open I, "index.old.html";
-while ($line = <I>)
-{
-	if ($line !~ /scm/)
-	{
-		print $line;
-	}
-	else
-	{
-		$filename = $line;
-		chomp($filename);
-		$filename =~ s/^.*"([a-zA-Z_]*\.scm)".*$/$1/;
-		$title = $line;
-		chomp($title);
-		$title =~ s/^.*">//;
-		$title =~ s/<\/a>.*$//;
-		print "<a href=\"$filename.html\">$title</a>" . ("\&nbsp;" x 8) .  " (<a href=\"$filename\">Scheme Code</a>)<br>\n";
-	}
-}
-close (I);

File vipe/lecture/Lambda-Calculus/index.html

-<html>
-<head>
-<title>
-Haifux - Lecture about Scheme and Lambda Calculus
-</title>
-</head>
-<body bgcolor="#FFFFFF">
-
-<h1>Haifux - Lecture about Scheme and Lambda Calculus</h1>
-
-<br><br>
-
-<div align="right">
-<h3>By Shlomi Fish</h3>
-</div>
-
-<br><br>
-
-<h2>Scheme</h2>
-
-<a href="output_vars.scm.html">Output and Variables</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="output_vars.scm">Scheme Code</a>)<br>
-<a href="cond.scm.html">Conditionals</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="cond.scm">Scheme Code</a>)<br>
-<a href="funcs.scm.html">Functions</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="funcs.scm">Scheme Code</a>)<br>
-<a href="loops.scm.html">Loops</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="loops.scm">Scheme Code</a>)<br>
-<a href="lists.scm.html">Lists</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lists.scm">Scheme Code</a>)<br>
-
-<h2>Lambda Calculus</h2>
-
-<a href="lc_intro.scm.html">Introduction</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_intro.scm">Scheme Code</a>)<br>
-<a href="lc_bools_conds_tuples.scm.html">Booleans, Conditionals and Tuples</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_bools_conds_tuples.scm">Scheme Code</a>)<br>
-<a href="lc_bool_ops.scm.html">Boolean Operations</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_bool_ops.scm">Scheme Code</a>)<br>
-<a href="lc_church.scm.html">Church Numerals</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_church.scm">Scheme Code</a>)<br>
-<a href="lc_church_ops.scm.html">Church Numerals Operations</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_church_ops.scm">Scheme Code</a>)<br>
-<a href="lc_Y.scm.html">The Y Combinator</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_Y.scm">Scheme Code</a>)<br>
-<a href="lc_constructs.scm.html">Common Language Constructs</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_constructs.scm">Scheme Code</a>)<br>
-<a href="lc_church_div.scm.html">Division and Modulo in Church Numerals</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="lc_church_div.scm">Scheme Code</a>)<br>
-
-<h2>Finale</h2>
-
-<a href="notes.scm.html">Final Notes</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<a href="notes.scm">Scheme Code</a>)<br>
-<a href="refs_n_links.html">References and Links</a><br>
-<br>
-<br>
-<br>
-<hr>
-<a href="../Lambda-Calculus.tar.gz">This lecture in an archive</a><br>
-</body>
-</html>

File vipe/lecture/Lambda-Calculus/index.old.html

-<html>
-<head>
-<title>
-Haifux - Lecture about Scheme and Lambda Calculus
-</title>
-</head>
-<body bgcolor="#FFFFFF">
-
-<h1>Haifux - Lecture about Scheme and Lambda Calculus</h1>
-
-<h2>Scheme</h2>
-
-<a href="output_vars.scm">Output and Variables</a><br>
-<a href="cond.scm">Conditionals</a><br>
-<a href="funcs.scm">Functions</a><br>
-<a href="loops.scm">Loops</a><br>
-<a href="lists.scm">Lists</a><br>
-
-<h2>Lambda Calculus</h2>
-
-<a href="lc_intro.scm">Introduction</a><br>
-<a href="lc_bools_conds_tuples.scm">Booleans, Conditionals and Tuples</a><br>
-<a href="lc_bool_ops.scm">Boolean Operations</a><br>
-<a href="lc_church.scm">Church Numerals</a><br>
-<a href="lc_church_ops.scm">Church Numerals Operations</a><br>
-<a href="lc_Y.scm">The Y Combinator</a><br>
-<a href="lc_constructs.scm">Common Language Constructs</a><br>
-<a href="lc_church_div.scm">Division and Modulo in Church Numerals</a><br>
-
-<h2>Finale</h2>
-
-<a href="notes.scm">Final Notes</a><br>
-<a href="refs_n_links.html">References and Links</a><br>
-<br>
-<br>
-<br>
-<hr>
-<a href="../Lambda-Calculus.tar.gz">This lecture in an archive</a><br>
-</body>
-</html>

File vipe/lecture/Lambda-Calculus/lc_Y.scm

-; The Y Combinator
-; ----------------
-
-; The Y combinator is defined as follows:
-
-(define Y
-    (lambda (f)
-        (
-            (lambda (x)
-                    (f (lambda (y) ((x x) y)))
-            )
-            (lambda (x)
-                    (f (lambda (y) ((x x) y)))
-            )
-        )
-    )
-)
-
-; It has the property that (Y f) is equivalent to (f (Y f)) (and so to
-; infinity. One can use the Y combinator to implement recursion in 
-; lambda calculus.
-
-; Let's see an example in Scheme on how to use the Y combinator:
-
-(define (top x) (car x))
-(define (var x) (cadr x))        ; (cadr x) is equivalent to (car (cdr x))
-(define (result x) (caddr x))
-
-; This function calculates the sum of integers from (var x) to (top x).
-; Note that we can only pass one argument to the Y's function so a 
-; list is used to pass multiple arguments.
-(define mysum
-    (Y (lambda (f)
-        (lambda (x)
-            (if (<= (var x) (top x))
-                ; If part
-                    ; The Y combinator enables us to use f to call 
-                    ; itself recursively.
-                (f (list 
-                    (top x) 
-                    (+ (var x) 1) 
-                    (+ (result x) (var x))
-                ))
-                ; Else part
-                x
-            )
-        )
-    ))
-)
-
-
-(define solution (mysum (list 10 5 0)))
-(display "The solution is: ")
-(display (result solution))
-(newline)
-
-; Naturally, we can convert this entire thing to lambda calculus:
-
-(define (top x) (lc_car x))
-(define (var x) (lc_car (lc_cdr x)))
-(define (result x) (lc_car (lc_cdr (lc_cdr x))))
-
-(define make-mysum-list
-(lambda (top)
-    (lambda (var)
-        (lambda (result)
-            ((lc_cons top) ((lc_cons var) ((lc_cons result) zero)))
-        )
-    )
-))
-
-; Notice that we wrap the inner if's in lambdas and pass zero as no_use.
-; Otherwise, both conditional clauses will always be evaluated and it will
-; run an infinite number of times.
-(define mysum
-    (Y (lambda (f)
-        (lambda (x)
-            (((((less-or-equal (var x)) (top x)) ; If var x < top x
-                ; If part
-                (lambda (no_use)
-                    (f 
-                        (((make-mysum-list 
-                            (top x)) 
-                            (succ (var x))) 
-                            ((add (result x)) (var x))
-                        )
-                    )
-                ))
-                ; Else part
-                (lambda (no_use)
-                    x
-                )) 
-                    zero ;  Pass zero as argument to no_use
-            )
-        )
-    ))
-)
-
-(define solution (mysum 
-    (((make-mysum-list 
-        (int->church 10))
-        (int->church 5))
-        (int->church 0))
-        ))
-
-(display "The solution is: ")
-(display (church->int (result solution)))
-(newline)
-

File vipe/lecture/Lambda-Calculus/lc_Y.scm.html

-<HTML>
-<HEAD>
-<TITLE>lc_Y.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; The Y Combinator</FONT>
-<FONT color=#0000ff>; ----------------</FONT>
-
-<FONT color=#0000ff>; The Y combinator is defined as follows:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> Y
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>((</FONT>x x<FONT color=#6a5acd>)</FONT> y<FONT color=#6a5acd>)))</FONT>
-            <FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>((</FONT>x x<FONT color=#6a5acd>)</FONT> y<FONT color=#6a5acd>)))</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; It has the property that (Y f) is equivalent to (f (Y f)) (and so to</FONT>
-<FONT color=#0000ff>; infinity. One can use the Y combinator to implement recursion in </FONT>
-<FONT color=#0000ff>; lambda calculus.</FONT>
-
-<FONT color=#0000ff>; Let's see an example in Scheme on how to use the Y combinator:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>car</FONT> x<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>cadr</FONT> x<FONT color=#6a5acd>))</FONT>        <FONT color=#0000ff>; (cadr x) is equivalent to (car (cdr x))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>result x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>caddr</FONT> x<FONT color=#6a5acd>))</FONT>
-
-<FONT color=#0000ff>; This function calculates the sum of integers from (var x) to (top x).</FONT>
-<FONT color=#0000ff>; Note that we can only pass one argument to the Y's function so a </FONT>
-<FONT color=#0000ff>; list is used to pass multiple arguments.</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> mysum
-    <FONT color=#6a5acd>(</FONT>Y <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>&lt;=</FONT> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>))</FONT>
-                <FONT color=#0000ff>; If part</FONT>
-                    <FONT color=#0000ff>; The Y combinator enables us to use f to call </FONT>
-                    <FONT color=#0000ff>; itself recursively.</FONT>
-                <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>list</FONT> 
-                    <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>)</FONT> 
-                    <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>)</FONT> <FONT color=#ff00ff>1</FONT><FONT color=#6a5acd>)</FONT> 
-                    <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> <FONT color=#6a5acd>(</FONT>result x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>))</FONT>
-                <FONT color=#6a5acd>))</FONT>
-                <FONT color=#0000ff>; Else part</FONT>
-                x
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> solution <FONT color=#6a5acd>(</FONT>mysum <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>list</FONT> <FONT color=#ff00ff>10</FONT> <FONT color=#ff00ff>5</FONT> <FONT color=#ff00ff>0</FONT><FONT color=#6a5acd>)))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;The solution is: &quot;</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>result solution<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Naturally, we can convert this entire thing to lambda calculus:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>lc_car x<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>lc_car <FONT color=#6a5acd>(</FONT>lc_cdr x<FONT color=#6a5acd>)))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>result x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>lc_car <FONT color=#6a5acd>(</FONT>lc_cdr <FONT color=#6a5acd>(</FONT>lc_cdr x<FONT color=#6a5acd>))))</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> make-mysum-list
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>top<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>var<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>result<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>((</FONT>lc_cons top<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>((</FONT>lc_cons var<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>((</FONT>lc_cons result<FONT color=#6a5acd>)</FONT> zero<FONT color=#6a5acd>)))</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>))</FONT>
-
-<FONT color=#0000ff>; Notice that we wrap the inner if's in lambdas and pass zero as no_use.</FONT>
-<FONT color=#0000ff>; Otherwise, both conditional clauses will always be evaluated and it will</FONT>
-<FONT color=#0000ff>; run an infinite number of times.</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> mysum
-    <FONT color=#6a5acd>(</FONT>Y <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>(((((</FONT>less-or-equal <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>))</FONT> <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>))</FONT> <FONT color=#0000ff>; If var x &lt; top x</FONT>
-                <FONT color=#0000ff>; If part</FONT>
-                <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>no_use<FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>(</FONT>f 
-                        <FONT color=#6a5acd>(((</FONT>make-mysum-list 
-                            <FONT color=#6a5acd>(</FONT>top x<FONT color=#6a5acd>))</FONT> 
-                            <FONT color=#6a5acd>(</FONT>succ <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>)))</FONT> 
-                            <FONT color=#6a5acd>((</FONT>add <FONT color=#6a5acd>(</FONT>result x<FONT color=#6a5acd>))</FONT> <FONT color=#6a5acd>(</FONT>var x<FONT color=#6a5acd>))</FONT>
-                        <FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>))</FONT>
-                <FONT color=#0000ff>; Else part</FONT>
-                <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>no_use<FONT color=#6a5acd>)</FONT>
-                    x
-                <FONT color=#6a5acd>))</FONT> 
-                    zero <FONT color=#0000ff>;  Pass zero as argument to no_use</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> solution <FONT color=#6a5acd>(</FONT>mysum 
-    <FONT color=#6a5acd>(((</FONT>make-mysum-list 
-        <FONT color=#6a5acd>(</FONT>int-&gt;church <FONT color=#ff00ff>10</FONT><FONT color=#6a5acd>))</FONT>
-        <FONT color=#6a5acd>(</FONT>int-&gt;church <FONT color=#ff00ff>5</FONT><FONT color=#6a5acd>))</FONT>
-        <FONT color=#6a5acd>(</FONT>int-&gt;church <FONT color=#ff00ff>0</FONT><FONT color=#6a5acd>))</FONT>
-        <FONT color=#6a5acd>))</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#ff00ff>&quot;The solution is: &quot;</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>church-&gt;int <FONT color=#6a5acd>(</FONT>result solution<FONT color=#6a5acd>)))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/lc_bool_ops.scm

-; Boolean Operations in Lambda Calculus
-; -------------------------------------
-
-; Not:
-; Think of not(a) as
-; if a == true
-;      return false
-; else
-;      return true
-; end
-; Thus in lc it would become:
-(define lc_not
-    (lambda (x)
-            ((x lc_false) lc_true)
-    )
-)
-
-; And(x,y):
-; again, think of and as:
-; if x == true
-;      if b == true
-;          return true
-;      else
-;           return false
-;      end
-; else
-;      return false
-; end
-
-(define lc_and
-    (lambda (x)
-            (lambda (y)
-                    ((x ((y lc_true) lc_false)) lc_false)
-            )
-    )
-)
-
-; Or(x,y):
-; if x == true
-;     return true
-; else
-;     if y == true
-;         return true
-;     else
-;         return false
-;     end
-; end
-
-(define lc_or
-    (lambda (x)
-            (lambda (y)
-                    ((x lc_true) ((y lc_true) lc_false))
-            )
-    )
-)
-
-
-; Note, as opposed to the && and || operators in C or the "and" and "or" 
-; statements in Scheme, those ands and ors always evaluate both expressions.

File vipe/lecture/Lambda-Calculus/lc_bool_ops.scm.html

-<HTML>
-<HEAD>
-<TITLE>lc_bool_ops.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Boolean Operations in Lambda Calculus</FONT>
-<FONT color=#0000ff>; -------------------------------------</FONT>
-
-<FONT color=#0000ff>; Not:</FONT>
-<FONT color=#0000ff>; Think of not(a) as</FONT>
-<FONT color=#0000ff>; if a == true</FONT>
-<FONT color=#0000ff>;      return false</FONT>
-<FONT color=#0000ff>; else</FONT>
-<FONT color=#0000ff>;      return true</FONT>
-<FONT color=#0000ff>; end</FONT>
-<FONT color=#0000ff>; Thus in lc it would become:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_not
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>((</FONT>x lc_false<FONT color=#6a5acd>)</FONT> lc_true<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; And(x,y):</FONT>
-<FONT color=#0000ff>; again, think of and as:</FONT>
-<FONT color=#0000ff>; if x == true</FONT>
-<FONT color=#0000ff>;      if b == true</FONT>
-<FONT color=#0000ff>;          return true</FONT>
-<FONT color=#0000ff>;      else</FONT>
-<FONT color=#0000ff>;           return false</FONT>
-<FONT color=#0000ff>;      end</FONT>
-<FONT color=#0000ff>; else</FONT>
-<FONT color=#0000ff>;      return false</FONT>
-<FONT color=#0000ff>; end</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_and
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>((</FONT>x <FONT color=#6a5acd>((</FONT>y lc_true<FONT color=#6a5acd>)</FONT> lc_false<FONT color=#6a5acd>))</FONT> lc_false<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Or(x,y):</FONT>
-<FONT color=#0000ff>; if x == true</FONT>
-<FONT color=#0000ff>;     return true</FONT>
-<FONT color=#0000ff>; else</FONT>
-<FONT color=#0000ff>;     if y == true</FONT>
-<FONT color=#0000ff>;         return true</FONT>
-<FONT color=#0000ff>;     else</FONT>
-<FONT color=#0000ff>;         return false</FONT>
-<FONT color=#0000ff>;     end</FONT>
-<FONT color=#0000ff>; end</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_or
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT>
-                    <FONT color=#6a5acd>((</FONT>x lc_true<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>((</FONT>y lc_true<FONT color=#6a5acd>)</FONT> lc_false<FONT color=#6a5acd>))</FONT>
-            <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-
-<FONT color=#0000ff>; Note, as opposed to the &amp;&amp; and || operators in C or the &quot;and&quot; and &quot;or&quot; </FONT>
-<FONT color=#0000ff>; statements in Scheme, those ands and ors always evaluate both expressions.</FONT>
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/lc_bools_conds_tuples.scm

-; Boolean constants in lambda calculus.
-; -------------------------------------
-
-; Traditonally true and false are:
-(define lc_true  (lambda (x) (lambda (y) x)))
-(define lc_false (lambda (x) (lambda (y) y)))
-
-; Stay tuned to see why:
-
-; Simple conditionals:
-; --------------------
-
-; The C-expression mycond ? a : b can be expressed in lambda calculus as:
-((mycond a) b)
-
-; Therefore, we can define if as:
-(define lc_if 
-    (lambda (mycond) 
-        (lambda (if-true) 
-            (lambda (if-false) 
-                ((mycond if-true) if-false)
-            )
-        )
-    )
-)
-
-(display (((lc_if lc_true) 5) 6))
-(newline)
-; Prints 5
-
-; Representing Tuples
-; -------------------
-
-; We can represent tuple as an if-expression. If the conditional is passed 
-; the value lc_true then we will return the tuple's car. If the if is passed 
-; the value lc_false then we will return the tuple's cdr.
-
-(define lc_cons
-    (lambda (mycar)
-        (lambda (mycdr)
-            ; we return this lambda-expression:
-            (lambda (which)
-                ((which mycar) mycdr)
-            )
-        )
-    )
-)
-
-(define lc_car
-    (lambda (tuple)
-        (tuple lc_true)
-    )
-)
-
-(define lc_cdr
-    (lambda (tuple)
-        (tuple lc_false)
-    )
-)
-
-; Example:
-(define mytuple ((lc_cons "A car") "A cdr"))
-
-(display (lc_car mytuple))
-(newline)
-; Prints "A car"
-(display (lc_cdr mytuple))
-(newline)
-; Prints "A cdr"

File vipe/lecture/Lambda-Calculus/lc_bools_conds_tuples.scm.html

-<HTML>
-<HEAD>
-<TITLE>lc_bools_conds_tuples.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Boolean constants in lambda calculus.</FONT>
-<FONT color=#0000ff>; -------------------------------------</FONT>
-
-<FONT color=#0000ff>; Traditonally true and false are:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_true  <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT> x<FONT color=#6a5acd>)))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_false <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>y<FONT color=#6a5acd>)</FONT> y<FONT color=#6a5acd>)))</FONT>
-
-<FONT color=#0000ff>; Stay tuned to see why:</FONT>
-
-<FONT color=#0000ff>; Simple conditionals:</FONT>
-<FONT color=#0000ff>; --------------------</FONT>
-
-<FONT color=#0000ff>; The C-expression mycond ? a : b can be expressed in lambda calculus as:</FONT>
-<FONT color=#6a5acd>((</FONT>mycond a<FONT color=#6a5acd>)</FONT> b<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Therefore, we can define if as:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_if 
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>mycond<FONT color=#6a5acd>)</FONT> 
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>if-true<FONT color=#6a5acd>)</FONT> 
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>if-false<FONT color=#6a5acd>)</FONT> 
-                <FONT color=#6a5acd>((</FONT>mycond if-true<FONT color=#6a5acd>)</FONT> if-false<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(((</FONT>lc_if lc_true<FONT color=#6a5acd>)</FONT> <FONT color=#ff00ff>5</FONT><FONT color=#6a5acd>)</FONT> <FONT color=#ff00ff>6</FONT><FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>; Prints 5</FONT>
-
-<FONT color=#0000ff>; Representing Tuples</FONT>
-<FONT color=#0000ff>; -------------------</FONT>
-
-<FONT color=#0000ff>; We can represent tuple as an if-expression. If the conditional is passed </FONT>
-<FONT color=#0000ff>; the value lc_true then we will return the tuple's car. If the if is passed </FONT>
-<FONT color=#0000ff>; the value lc_false then we will return the tuple's cdr.</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_cons
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>mycar<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>mycdr<FONT color=#6a5acd>)</FONT>
-            <FONT color=#0000ff>; we return this lambda-expression:</FONT>
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>which<FONT color=#6a5acd>)</FONT>
-                <FONT color=#6a5acd>((</FONT>which mycar<FONT color=#6a5acd>)</FONT> mycdr<FONT color=#6a5acd>)</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_car
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>tuple<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>tuple lc_true<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> lc_cdr
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>tuple<FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>(</FONT>tuple lc_false<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Example:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> mytuple <FONT color=#6a5acd>((</FONT>lc_cons <FONT color=#ff00ff>&quot;A car&quot;</FONT><FONT color=#6a5acd>)</FONT> <FONT color=#ff00ff>&quot;A cdr&quot;</FONT><FONT color=#6a5acd>))</FONT>
-
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>lc_car mytuple<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>; Prints &quot;A car&quot;</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>display</FONT> <FONT color=#6a5acd>(</FONT>lc_cdr mytuple<FONT color=#6a5acd>))</FONT>
-<FONT color=#6a5acd>(</FONT><FONT color=#008b8b>newline</FONT><FONT color=#6a5acd>)</FONT>
-<FONT color=#0000ff>; Prints &quot;A cdr&quot;</FONT>
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/lc_church.scm

-; Church Numerals
-; ---------------
-
-; But how to represent numbers in lambda calculus? Alonso Church, the 
-; logician who invented lambda calculus suggested the following method:
-(define zero (lambda (f) (lambda (x) x)))
-(define one  (lambda (f) (lambda (x) (f x))))
-(define two  (lambda (f) (lambda (x) (f (f x)))))
-(define three  (lambda (f) (lambda (x) (f (f (f x))))))
-
-; We take f and execute it on x N times
-
-; Converting Church numerals to regular integers:
-
-(define (church->int church)
-	(
-        (church 
-            (lambda (a) (+ a 1))
-        ) 
-            0
-    )
-)
-
-; Finding the successor to a Church numeral:
-; Let's take f and execute it on n one more time:
-(define succ 
-    (lambda (n) 
-	    (lambda (f) 
-    		(lambda (x) 
-    			(f ((n f) x))
-    		)
-    	)
-    )
-)
-
-; Converting an integer to a Church numeral
-(define (int->church n)
-	(if (= n 0)
-		zero
-		(succ (int->church (- n 1)))
-	)
-)

File vipe/lecture/Lambda-Calculus/lc_church.scm.html

-<HTML>
-<HEAD>
-<TITLE>lc_church.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Church Numerals</FONT>
-<FONT color=#0000ff>; ---------------</FONT>
-
-<FONT color=#0000ff>; But how to represent numbers in lambda calculus? Alonso Church, the </FONT>
-<FONT color=#0000ff>; logician who invented lambda calculus suggested the following method:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> zero <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> x<FONT color=#6a5acd>)))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> one  <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>f x<FONT color=#6a5acd>))))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> two  <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT>f x<FONT color=#6a5acd>)))))</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> three  <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>(</FONT>f x<FONT color=#6a5acd>))))))</FONT>
-
-<FONT color=#0000ff>; We take f and execute it on x N times</FONT>
-
-<FONT color=#0000ff>; Converting Church numerals to regular integers:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>church-&gt;int church<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT>
-        <FONT color=#6a5acd>(</FONT>church 
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>a<FONT color=#6a5acd>)</FONT> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>+</FONT> a <FONT color=#ff00ff>1</FONT><FONT color=#6a5acd>))</FONT>
-        <FONT color=#6a5acd>)</FONT> 
-            <FONT color=#ff00ff>0</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Finding the successor to a Church numeral:</FONT>
-<FONT color=#0000ff>; Let's take f and execute it on n one more time:</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> succ 
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>n<FONT color=#6a5acd>)</FONT> 
-        <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>f<FONT color=#6a5acd>)</FONT> 
-            <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT> 
-                <FONT color=#6a5acd>(</FONT>f <FONT color=#6a5acd>((</FONT>n f<FONT color=#6a5acd>)</FONT> x<FONT color=#6a5acd>))</FONT>
-            <FONT color=#6a5acd>)</FONT>
-        <FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-
-<FONT color=#0000ff>; Converting an integer to a Church numeral</FONT>
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> <FONT color=#6a5acd>(</FONT>int-&gt;church n<FONT color=#6a5acd>)</FONT>
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>if</FONT></B> <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>=</FONT> n <FONT color=#ff00ff>0</FONT><FONT color=#6a5acd>)</FONT>
-        zero
-        <FONT color=#6a5acd>(</FONT>succ <FONT color=#6a5acd>(</FONT>int-&gt;church <FONT color=#6a5acd>(</FONT><FONT color=#008b8b>-</FONT> n <FONT color=#ff00ff>1</FONT><FONT color=#6a5acd>)))</FONT>
-    <FONT color=#6a5acd>)</FONT>
-<FONT color=#6a5acd>)</FONT>
-</PRE>
-</BODY>
-</HTML>

File vipe/lecture/Lambda-Calculus/lc_church_div.scm

-; Reminder and Division in Church Numerals
-; ----------------------------------------
-
-; I promised that I will show how they were done so here goes:
-
-(define greater-or-equal
-    (lambda (x)
-        (lambda (y)
-            ((less-or-equal y) x)
-        )
-    )
-)
-
-
-(define reminder
-    (lambda (div)
-        (lambda (div_by)
-            ((Y (lambda (f)
-                (lambda (x)
-                    (((((greater-or-equal x) div_by)  ; We can still see div_by
-                        (lambda (no_use)
-                            (f ((subtract x) div_by))
-                        ))
-                        (lambda (no_use)
-                            x
-                        )
-                    )
-                        zero)    ; Pass zero as an argument to no_use
-                )
-            ))
-                div)  ; Pass div as the initial x
-        )
-)
-
-(display (church->int ((reminder (int->church 100)) (int->church 9))))
-(newline)
-
-(define divide
-    (lambda (div)
-        (lambda (div_by)
-            ((Y (lambda (f)
-                (lambda (x)
-                    (((((greater-or-equal x) div_by)  
-                        (lambda (no_use)
-                            ; Add one to the result of (x-div_by)/div_by
-                            (succ (f ((subtract x) div_by)))  
-                        ))
-                        (lambda (no_use)
-                            zero
-                        )
-                    )
-                        zero)    ; Pass zero as an argument to no_use
-                )
-            ))
-                div)  ; Pass div as the initial x
-        )
-    )
-)
-
-(display "50/8=")
-(display (church->int ((divide (int->church 50)) (int->church 8))))
-(newline)
-
-; Note that the version of divide does not use tail-recursion.
-; Thus, it will consume a memory of O(div/div_by). Nevertheless, 
-; a tail recursion version can be written using a tuple of 
-; (div, accumlator).
-
-

File vipe/lecture/Lambda-Calculus/lc_church_div.scm.html

-<HTML>
-<HEAD>
-<TITLE>lc_church_div.scm.html</TITLE>
-</HEAD>
-<BODY BGcolor=#FFFFFF TEXT=#000000>
-<PRE>
-<FONT color=#0000ff>; Reminder and Division in Church Numerals</FONT>
-<FONT color=#0000ff>; ----------------------------------------</FONT>
-
-<FONT color=#0000ff>; I promised that I will show how they were done so here goes:</FONT>
-
-<FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>define</FONT></B> greater-or-equal
-    <FONT color=#6a5acd>(</FONT><B><FONT color=#a52a2a>lambda</FONT></B> <FONT color=#6a5acd>(</FONT>x<FONT color=#6a5acd>)</FONT>