Please send questions to st10@humboldt.edu .
(cons (cdr '(1 2 3)) (car '((a b c) (d e f))))
(cons 1 '())
(cons 1 (list 2 3))
(append (cdr '(1 2 3)) (car '((a b c) (d e f))))
(cons (cdr '(1 2 3)) (car '(((a b c)) (d e f))))

; define with a name and a value makes that name an
;    an expression with that value

(define foods '(apples carrots sourdough chocolate))
foods
(car foods)

; McCarthy also wanted HIGHER ORDER FUNCTIONS -
; a function that accepts a function as a parameter
;    OR returns a function
;    OR both;

; for example, he wanted to be able apply some function
;   to every element in a list (map)
;   and have that return a list of the results

; this is EASY to write in Scheme/LISP

(define (my-map a-function a-list)
  (cond 
      ((null? a-list) '())
      (else
          (cons (a-function (car a-list))
                (my-map a-function (cdr a-list)))
      )
  )
)

(define (add-1 a-number)
  (+ 1 a-number)
)

(add-1 456)
(my-map add-1 '(2 4 6 8 10))
(my-map car '((Tuttle 3381) (Burroughs 3333) (Burgess 3331)))
(my-map cdr '((Tuttle 3381) (Burroughs 3333) (Burgess 3331)))
(my-map car (my-map cdr '((Tuttle 3381) (Burroughs 3333) (Burgess 3331))))

; this led him to also want anonymous functions -- more on those
;    shortly;

; he wanted garbage collection, too;

; Scheme: a considerably-smaller and simpler Lisp dialect

; functional programming...

; a different programming model than imperative programming

; math function:

; f(x) = y  -> f:X -> Y
; X is the domain, Y is the range

; in math, a function's variables/parameters always stand for actual
;    values,
; whereas in imperative programming languages, variables refer to
;    to memory locations AS WELL AS values

; in math,   x = x + 1    ...does not make sense
; in imperative programming, it does;

; in functional programming, assignment is not
;    an available operation (or at least re-assignment is not)
; the idea of variable-as-a-memory-location is not there;
;    instead, you have constants, parameters, and values;

; named parameters ARE variables in the mathematical sense,
;    but in the functional model, you would not RE-assign
;    the values of parameters within a function body;

; and pure functional programming IS Turing-complete;
;   any function may be described using functions alone;

; so, you can't have imperative looping in pure functional
;    programming -- how do you repeat?
;... RECURSION!!
; instead of repeating a block of statements based on the
;    state of some control variable,
; you have repeated function calls on successively "smaller"
;    versions of the problem;

; another consequence: the value of a function depends ONLY
;    on the values of its arguments (and MAYBE non-local constants)
; (doesn't matter what statements preceded this...)
; ...this is called REFERENTIAL TRANSPARENCY

; ...this might make functional progrmaming VERY attractive
;    for concurrent applications;
; ...it also makes their semantics simpler (than imperative)
;    and would make program proofs easier (than imperative)

; from: 
; "Programming Languages, Principles and Practices", 2nd Edition,
;     Kenneth C. Louden, Thomson - Brooks/Cole, 2002:
;
; *   "summarize[s] the qualities of functional programming 
;      languages and functional programs as follows: [p. 476]:
;
; 1. All procedures are functions and clearly distinguish incoming
;    values (parameters) from outgoing values (results).
;
; 2. There are no variables or assignments --- variables are replaced 
;    by parameters.
;
; 3. There are no loops --- loops are replaced by recursive calls.
;
; 4. The value of a function depends only on the value of its 
;    parameters and not on the order of evaluation or on the 
;    execution path that led to the call.
;
; 5. Functions are first-class values."

; lambda calculus
; Alonzo Church!

; McCarthy adapted Church's notation:

(lambda (x) (+ 3 x))  ; means f(x) = x + 3
((lambda (x) (+ 3 x)) 4)

((lambda (num string) (+ 267 num)) 1 "woof")

(define looky
    (lambda (x) (* x 10)))
(looky 10)