Lisp HUG Maillist Archive

A Head scratcher

I am going through this tutorial & i'm having trouble with the one exercise:

(defun stooge (larry moe curly)
(list larry  (list ' moe curly) curly ' larry))

The call is:
(stooge ' Moe ' curly ' Larry)

The result is:
(moe (moe larry) larry larry)

I'm having a bit of trouble understanding this. Can anyone help?

Re: A Head scratcher

It seems deliberately obfuscated, but just think within the function
body that larry means the first thing passed in, moe the second, curly
the third. It builds a list starting with the first thing, followed by
a nested list that starts with the symbol moe (its quoted to prevent
evaluation) followed by the third thing passed in. After that nested
list comes the third thing passed in, followed by larry (again, quoted
to prevent evaluation).

On 18 December 2017 at 10:12, Stanley Overby <sovrby@gmail.com> wrote:
> I am going through this tutorial & i'm having trouble with the one exercise:
>
> (defun stooge (larry moe curly)
> (list larry  (list ' moe curly) curly ' larry))
>
> The call is:
> (stooge ' Moe ' curly ' Larry)
>
> The result is:
> (moe (moe larry) larry larry)
>
> I'm having a bit of trouble understanding this. Can anyone help?

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:30 UTC