The most
bad-ass procedure in
scheme has to be
lambda. This
procedure itself returns a
procedure. In
scheme whenever a
procedure is made, the
scheme interpreter uses
lambda like this:
What you would normally enter:
(
define (square x)
(* x x))
What the
interpreter does (and you can do yourself if you like):
(
define square (
lambda (x) (* x x)))
In the second example, the
variable square is
bound to the
return value of
lambda which is a
procedure that takes one
argument and
returns its square.
(
define (make-every-proc proc)
(
lambda (a) (every proc a)))
(define every-bf (make-every-proc
butfirst))
(every-bf '(hello you crazy world))
==> (ello ou razy orld)
I
defined the
procedure make-every-proc that takes in a
procedure, proc and returns a procedure, (unnamed), that takes in a
sentence and
applies proc to every element. You can see how this works now. Good Stuff. GO
CAL!!