Joe
My question came from that very documentation so I'm well aware of it.

I've never used a lambda but your Javascipt example helps a lot and
suggests that 'quote' in


((quote (X) (* X X)) 9)


transforms the statement into something like

(
  (de anon (X)
    (* X X)
  )
  anon 9
)

If that's right..great but the transformation isn't intuitive to me at
all i.e. I thought quote just stopped the evaluation of a symbol.
It looks like it's doing a lot more than that here.

Also I read that ' is a macro for quote but I couldn't produce a '
equivalent of ((quote (X) (* X X)) 9) i.e.

: ((quote (X) (* X X)) 9)
-> 81
: (('(X) (* X X)) 9)
!? (('(X) (* X X)) 9)
NIL -- Undefined
?
: (('X (* X X)) 9)
!? ('X (* X X))
X -- Undefined


Best Regards
Dean

On 22 November 2016 at 04:16, Joe Bogner <joebog...@gmail.com> wrote:

> Hi dean,
>
> It's not clear what you're asking. Does this help explain it?
>
> http://software-lab.de/doc/tut.html
>
> --- from the page ---
>
> Anonymous functions without the lambda keyword
>
> There's no distinction between code and data in PicoLisp, quote will
> do what you want (see also this FAQ entry).
>
> : ((quote (X) (* X X)) 9)
> -> 81
>
> : (setq f '((X) (* X X)))  # This is equivalent to (de f (X) (* X X))
> -> ((X) (* X X))
> : f
> -> ((X) (* X X))
> : (f 3)
> -> 9
>
> --- end from the page ---
>
> And http://software-lab.de/doc/ref.html
>
> "The most prominent read-macro in Lisp is the single quote character
> "'", which expands to a call of the quote function. Note that the
> single quote character is also printed instead of the full function
> name."
>
> ---
>
> In other words, quote is allowing you to define an anonymous function
> equivalent to (function(x) { return x*x })(9) (in javascript for
> example)
>
> On Mon, Nov 21, 2016 at 3:37 PM, dean <deangwillia...@gmail.com> wrote:
> > I could do with some help understanding step by step what's happening
> > here...
> >
> > Intuitively I can see that 9 squared is 81 but I can't really see,
> > precisely, what this was doing
> >
> > ((quote (X) (* X X)) 9)
> > -> 81
> >
> > so I put it in a function in a file to trace it
> >
> > (de go ()
> > ((quote (X) (* X X)) 9)
> > )
> >
> > but it's not giving me the step by step explanation I was hoping for
> >
> > : (trace go)
> > !? (method "X" C)
> > (('((X) (* X X)) 9)) -- Symbol expected
> > ?
> >
> > Any help to understand what's happening at each stage would be very much
> > appreciated.
> >
> > Thank you in anticipation.
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to