Why first lambda expression is args

Pondering the philosophy behind the language

Why first lambda expression is args

Postby ssqq » Mon Jul 06, 2015 8:52 am

I think first lambda expression should is 'lambda:

Code: Select all
> (first (lambda (x y) (+ x y)))
lambda
> (first (fn (x y) (+ x y)))
fn
> 'lambda
lambda
> 'fn
fn
> (cons 'fn '((x y) (+ x y)))
(fn (x y) (+ x y))


Why newLISP use args as first elements of lambda expression?
Why could not quote *lambda* and *fn*?
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: Why first lambda expression is args

Postby hartrock » Fri Oct 02, 2015 1:38 pm

ssqq wrote:I think first lambda expression should is 'lambda:

Code: Select all
> (first (lambda (x y) (+ x y)))
lambda
> (first (fn (x y) (+ x y)))
fn
> 'lambda
lambda
> 'fn
fn
> (cons 'fn '((x y) (+ x y)))
(fn (x y) (+ x y))


Why newLISP use args as first elements of lambda expression?
Why could not quote *lambda* and *fn*?

lambda is a property of a list, and not a symbol at its beginning; an example:
Code: Select all
> (set 'li (cons '(x y) (cons '(+ x y) '())))
((x y) (+ x y))
> (first li)
(x y)
> (set 'la (cons '(x y) (cons '(+ x y) '(lambda))))
(lambda (x y) (+ x y))
> (first la)
(x y)
>
-> both list and lambda list having (x y) as first element.
But only the lambda list works as function:
Code: Select all
> (li 3 4)

ERR: invalid list index
> (la 3 4)
7
>

From the manual http://www.newlisp.org/downloads/newlisp_manual.html#fn:
... The fn or lambda word does not exist on its own as a symbol, but indicates a special list type: the lambda list. ...
hartrock
 
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm


Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest