(DEFINE <symbol> <value-expression>) the symbol is "bound" to the value of the value-expression.
(LAMBDA (<arg1> <arg2> ... <argn>) <body>) A procedure is created that takes n formal arguments. When the procedure is called, the formal args will be bound to the real args, and will be available for use inside the body code.
(DEFINE (<symbol> <arg1> <arg2> ... <argn>) <body>)
defines a procedure named <symbol>. This is SYNTACTIC SUGAR for:
(DEFINE <symbol> (LAMBDA (<arg1> <arg2> ...
<argn>) <body>))
also defines a procedure named <symbol>.
Both of those last two defines have the IDENTICAL MEANING!!!
(LET ( (<symbol-1> <value-1>)
(<symbol-2> <value-2>)
...
(<symbol-n> <value-n>) )
<body> )
evaluates each expression value-1 through value-n as though it were
OUTSIDE the LET, and binds the LOCAL VARIABLES symbol-1 through symbol-n
to the corresponding results. These local variables can then be used inside
the BODY. LET is SYNTACTIC SUGAR for a particular way of using LAMBDA
(see your notes and the book).
Both DEFINE and LAMBDA (and LET, which is really a LAMBDA) are SPECIAL FORMS. They do not obey the Scheme Rules of Evaluation.
(COND (<predicate1> <clause1a> <clause1b>...<clause1m>)
(<predicate2> <clasue2> <clause2b> ... <clause2m>)
...
(<predicate-n> <clasue-n-a> <clause-n-b> ... <clause-n-m)
(else <else-clause-a> <else-clause-b> ... <else-clause-m) )
Test each predicate in order. If a predicate is true, then evaluate
the corresponding clauses, and that's all for the COND. If no predicate
is true, then evaluate the else-clauses. If you don't have an "else", and
none of the predicates are true, then an error is signaled.
(BEGIN <e1> <e2> ...<en>)
Evaluate and execute <e1>, then <e2>, then <e3>, etc. and
finally return the value that <en> returns. Note that BEGIN is ONLY
useful when the expressions before <en> have SIDE EFFECTS. This would
include things like "display" and "newline", or of course "set!".
(APPLY <procedure> <list-of-arguments>)
Evaluates the procedure <procedure> using the arguments from the
<list-of-arguments>.
(apply square '(5)) ==> 25 ; same as (square 5). note that
square only takes one arg
(apply + '( 1 2 3 4 5)) ==> 15 ;same as (+ 1 2 3 4 5). note that
+ takes unlimited number of args
(apply > '(5 6)) ==> #F ; same thing as (> 5 6).
(AND <e1> <e2> ... <en>) is a SPECIAL FORM. AND evaluates each arg, one at a time, left to right. If all the arguments evaluate to TRUE, then AND returns TRUE. If any argument evaluates to FALSE, then AND stops evaluating args and immediately returns FALSE.
(OR <e1> <e2> ... <en>) is also a SPECIAL FORM. It works just like AND, except that OR returns TRUE immediately if any argument evaluates to TRUE, and returns FALSE only if it evaluates all of the arguments and they all return FALSE.
(NOT <e1>) returns true if e1 evaluates to false, and false if e1 evaluates to true.
Operations: + , - , * , / , quotient
, remainder , abs , sin , cos , log ,
etc.
The arguments to these operations should be numbers. The results are
also numbers. Some operators, like + and *, take any number of arguments.
Some, like abs or sin, are unary. The "-" operator can be both n-ary (as
repeated subtraction) and unary (negation of a number).
Operations: '<expression> , which is Syntactic Sugar for (QUOTE <expression>). QUOTE is a SPECIAL FORM that stops the Scheme Rule of Evaluation. Instead of evaluating the quoted expression, Scheme will
(equal? x y) returns #t if x and y are symbols that are eq?, numbers that are =, or lists who's cars are equal? and whose cdrs are equal?.
(list 'a 'b 'c) is the same as (cons 'a (cons 'b (cons 'c '())))
(CDR <list>) returns the list of everything except the first element.
Syntactic Sugar: (car (cdr x)) = (cadr x), (cdr (car (cdr x)))= (cdadr x), etc.
(FILTER <predicate> <list>)
Calls the predicate <predicate> on each element of the list <list>,
and returns a new list of ONLY the elements when the predicate returned
TRUE!
For example, (filter odd? '(1 2 3 4 5 6)) ==> (1 3 5)
(ACCUMULATE <op> <init> <list>)
Takes a list and "reduces" it by repeatedly applying <op> to the
next element of the list, and the result of accumulating the rest of the
list. When the list is empty, accumulate returns <init>. Examples:
(display "String to print")
(display <symbol>)
Writes a string or the value of a symbol to the screen.
(newline)
Outputs a new line on the screen.
(error "This argument is of the wrong type: " <symbol>)
Prints an error message to the screen, consisting of strings and symbols.
Will then stop the interpreter and return you to the top level.