I strongly prefer the lambda
-heavy style for teaching, since it makes function creation more explicit, as Jay says.
When learning, the simple functions you start with like atom?
are define
d at the top level. This means it's possible, and even more compact, to create the function with the defun
-style define
you mention.
However, when you start using functions as first-class values, e.g., as an argument to map
, you'll be seeing lambda
for the first time, and it might seem weirder and more magical than it really is.
Instead, if you've been defining your functions with lambda
the whole time, it's less of a leap to see that functions are just like any other value. They happen to be on the right-hand side of define
pretty frequently, but are no different from a number or a quoted constant:
(define x 1)
(define l '(2 3 4 5))
(define s (cons x ls))
(define f (lambda (n) (+ n 2)))
Of course, the language supports both forms, so it comes down to style eventually. To me, there is an appealing consistency in the usage of define
when all of your functions are made with lambda
: the first argument is always a symbol, and the second argument is just any old expression. And the fact that lambda
is just like any old expression is one of the most important things for any functional programmer to learn.