Unicode and newLISP-tk

Started by Excalibor, April 28, 2005, 01:42:41 AM

Previous topic - Next topic

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



> (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

#1
Awesome!  You know what would be cool too?  If one could do this in newLISP:
> (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

#2
Quote from: "rickyboy"Awesome!  You know what would be cool too?  If one could do this in newLISP:
> (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

#3
'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=Differences_to_Other_LISPs">http://newlisp.org/index.cgi?page=Diffe ... ther_LISPs">http://newlisp.org/index.cgi?page=Differences_to_Other_LISPs



See the parapgraphs 1. and 9.



Lutz