Unicode and newLISP-tk

Q&A's, tips, howto's
Locked
Excalibor
Posts: 47
Joined: Wed May 26, 2004 9:48 am
Location: Madrid, Spain

Unicode and newLISP-tk

Post by Excalibor »

Hi all,

I dunno exactly how Unicode support is done (or not) in newLISP, I have to dig into the docs and code, but this is a session of newLISP 8.5.4 with newLISP-tk 1.2.5

Code: Select all

> (setq Πελειάδεω 10)
10
> (println Πελειάδεω)
10
10
> 
Pretty impressive, actually... (BTW the symbol reads, in classical greek, "Peleiádeo-o", which is the genitive form of Peleos, the father of Achilles, from the first verse of the _Illiad_, which I copy&pasted from my blog, which starts with that first verse...)

I dunno which encoding was used, because copying from firefox to newlisp-tk, and then back to firefox may have caused haymen with the encodings, but anyway...

:-)

laters!
dvd

PS- this also works: (setq ñañañá 13) :-)

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

Awesome! You know what would be cool too? If one could do this in newLISP:

Code: Select all

> (map (λ (x) (+ x 42)) '(1 2 3))
(43 44 45)
That is, make λ the same as lambda. Now that would rock. --Ricky

P.S. -- What is "ñañañá"? It's sounds like something a baby would say. :-)
(λx. x x) (λx. x x)

Excalibor
Posts: 47
Joined: Wed May 26, 2004 9:48 am
Location: Madrid, Spain

Post by Excalibor »

rickyboy wrote:Awesome! You know what would be cool too? If one could do this in newLISP:

Code: Select all

> (map (λ (x) (+ x 42)) '(1 2 3))
(43 44 45)
That is, make λ the same as lambda. Now that would rock. --Ricky

P.S. -- What is "ñañañá"? It's sounds like something a baby would say. :-)
Funny, neither (constant), nor (setq), nor (define) allows me to assign lambda the way you suggest...

Is there a way to access the body assigned to a macro? something similar to (args), but with the body (like Tcl's [info body foo])...

If there's, then we can define a macro to delay the eager evaluation of "lambda" so it can be bound to λ the way we want, but I can't see how right now...

"ñañañá" is what someone angry with you would tell you when you start talking, trying to mock you or tease you (a mocking version of "blah blah blah" like in the (ficticious (mostly)) conversation: "I don't like it! I don't want to do it! I don't want to---" "Ñañañañañá! oh shut up!") but in spanish :-) many times sung instead of said, I think the english equivalent would be "nyah, nyah, nyah" or something like that...

laters!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

'lambda' or 'fn' are build in attributes of a list, they are not symbols, i.e

(first (lambda (x) (+ x x))) => (x) ; not lambda

Imagine you have a function or macro (it doesn't matter for this example)

(define (double x) (+ x x)) => (lambda (x) (+ x x))

You can acces the body:

(last double) => (+ x x)

and modify it:

(set-nth 1 double '(+ x x x)) => (lambda (x) (+ x x x))

(double 3) => 9

So, yes you can acces the body of a function or macro, which are always first-class objects in newLISP. In Common LISP or Scheme after evaluating the define/defun/lambda expression, they are not accessable any more and 'lambda' or 'macro' a symbols like 'print' 'map' etc. In newLISP lambda indicates that the list is a special sub-type of list a "lambda list". You can cons on to it or append to it, and they evaluate to themselves.

Macros work very different in newLISP as they do in Common LISP or Scheme. Please read the manual chapters about lambda and lambda expressions (chapter 7) and the function reference about 'define' and 'define-macro' and 'expand', where all this is explained in more detailed.

There is also 2 paragraphs about it in here: http://newlisp.org/index.cgi?page=Diffe ... ther_LISPs

See the parapgraphs 1. and 9.

Lutz

Locked