define
, cond
, and
(and others) are special forms. In general, what's special about a special form?
a*b+c
in Racket.
one
and two
.
2nd
that returns the second element in a list having at least two elements. Example:
> (2nd '(5 3 7 9)) 3
a*b+c
can be expressed in Racket as (+ (* a b) c)
2nd
:
(define (2nd-1 lst) (cadr lst)) (define (2nd-2 lst) (second lst)) (define (2nd-3 lst) (list-ref lst 1))
Quick sidebar: As a rule, I never use list
as a parameter name because it then hides the built-in procedure list
, often leading to a baffling error.