Andres Raba
unread,Jun 21, 2011, 5:12:04 AM6/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to p2pu...@googlegroups.com
Hello Janus!
I think what is meant by a procedure is applying the operator to the operands in a combination. In a sense, the description of the procedure sits inside the operator which is the first symbol of a combination. Like + in (+ 5 6 7). Then again, not all combinations have the operator in the first position after the opening parenthesis. Like (1 2 3 4) which gives an error when evaluated, because 1 is not a procedure. The list evaluates to itself when quoted like this: '(1 2 3 4).
We could say that an expression is any primitive or combination that returns a value. Be it a single number, a list, a predicate returning true or false, etc. For example, this is an expression: 2.71. And this is compound expression: (sin 1.6), it applies the procedure sin to argument 1.6. This is also a compound expression: (* 4 (+ 7 19)). It applies the procedures * and + to its arguments.
Procedures are the recipes of evaluation you can define using construct like this:
(define (my-procedure arg1 arg2) <body containing expressions>)
So you get a named procedure which you then use, e.g.: (my-procedure 9.1 2.5)
You can have a procedure without a name! (That is introduced in the first lecture and in section 1.3.2.)
As I understand, a function is a procedure always returning the same value with the same arguments. No side effects and no internal state.
An expression returning true or false is for example (< x y). It applies the procedure "<" to x and y. This can be then used in (cond ), (if ) or other forms in the position of the predicate.
The above explanation might be too vague. And maybe I'm wrong. Others please elaborate on this.
Andres