Target: 99 newlisp expressions that evaluate to a smiley
Please add yours to the list ;-)
Greetings, Norman.
---
## elegant
((0(fn :->)0)1)
## readable
(reverse {)-:})
## Lispy
(lambda :-)
## Shorter
;-)
## Shortest ;)
;)
## Silent
c:newlisp -c :-)
## Illigal
c:newlisp -e "(last (main-args))" :-)
## Nose
(sym(join(map string(flat(0(fn (:)(o)({)})))))))
## Too simple
(sym {:-)})
## Odd
(sym (5(setq $0(string((cons'(sym :-))2)))))
## Stringway
(1(string(flat(fn :-()))))
## (not (happy))
(append ":" (reverse(2 2(encrypt "smiley" " 65"))))
## a long one with a deeper meaning
(join (map char (map (fn (c) (- c 66)) (map char (explode "|ok")))))
## Eazy
":-)"
## Less eazy
(first '(":-)"))
## Boring
(last '(":-)"))
## Also boring
(nth 1 '(":-)"))
## Last one and now going back to business
(join (list ":" "-" ")"))
You? Business?? at 5 past 5 ;-)
Take care, you are only 2 desks away... ;-)
## for the mathmatician
(join (reverse (map char (factor 2419))))
## beaten up mathmatician
(join (reverse (map char (factor 113693))))
How about a more circuitous way:
((fn(v w)(v w((fn(v w x y z)(v w(x -(z w w)(z w y))))cons(dup"c"3)map")6:"unpack)))apply'pack)
--Ricky
## HistoricSmile
(495 3(get-url "http://www-2.cs.cmu.edu/~sef/sefSmiley.htm"))
## Glasses
(sym(1 3(string(list(sym(append(reverse(string (~ 7)))))))))
Very cool, Norman! If I use that but remove the 'append' call, I get the same thing.
Thanks for making these submissions -- although it seems a time-waster, you've actually been teaching me some points of newLISP programming! For instance, I never really paid attention much to string slicing until reading your entries prompted me to. --Ricky
Haha..yes its a 100% timewaster indeed ;-)
I just wanted to see how far one would get trying to create smiley's
in newlisp without the direct use of characters.. So it possible ;-)
But indeed the string 'rest function is great, Lutz introduced it in the last
release and one gets very addicted with it...
I think ill quit now targeting the 99 :-)
Ooo btw... the append is indeed a leftover from another one ;-)
Should not be in there..
Regards, Norman.
OK, lame, but...
(silent (dolist (i '(: - ")")) (print i)))
Still lame, but funnier ;-)
(define-macro (:- x) (silent (print (string ":-" (first (args))))))
(:- ")")
laters!
dvd
PS- any way to get the macro to eval itself, so I can write ":- )" on the repl and it gets evaluated? maybe I'm asking too much...
I think you mean:
(define-macro (:-) (silent (print (string ":-" (first (args))))))
> (:- |)
:- |
because (args) takes only the unassigned arguments, so you have to throw out the 'x. This was a changed in 8.4.2, previously (args) returned all arguments.
Also, why do you use a macro for this? It would only be necessary when passing symbols directly, as in my example.
I did not understand the last question. Do you want to call your fuinction/macro recurselvy? you can do that.
Good to hear from you Excalibor, a lot of folks are very happy with with your newlisp.vim.
Lutz
Quote from: "Lutz"
I think you mean:
(define-macro (:-) (silent (print (string ":-" (first (args))))))
> (:- |)
:- |
because (args) takes only the unassigned arguments, so you have to throw out the 'x. This was a changed in 8.4.2, previously (args) returned all arguments.
Aahh... that's why I had to throw the 'x out (I'm using the last development version, 8.5.4; btw, I like the indexing thing! :-)
Quote
Also, why do you use a macro for this? It would only be necessary when passing symbols directly, as in my example.
Just because... :-) It adds to the sum, still way below the proposed 99, but two less than before... Also, it was an opportunity to keep playing with macros... I'm still thinking in writing a newLISP tutorial that's both useful and fun, but I'm very short of time... Thus I jumped to the last version, and I'm exploring all the changes, lots of them, newlisp is keeping you busy! also, congrats for the korozu.com success, I'm sure it will give newlisp a great boost and lots of exciting new functionality and documentation...
Quote
I did not understand the last question. Do you want to call your fuinction/macro recurselvy? you can do that.
actually I want to call the macro without the parens :-)
think about a DSL written on newlisp, it will help to get the parens off the way, to make things easier for others... of course, a parenthetical dsl "enhancing" newlisp would be cool by itself, and that's probably what I would do... but I remember a common lisp tutorial, writting a small game, that managed to get rid of the parens by using macros... i know CL macros are not NL's, but it never hurts to ask :-)
Quote
Good to hear from you Excalibor, a lot of folks are very happy with with your newlisp.vim.
Lutz
thanks, i've been pretty busy the last months, thus i just walked around the fora, but didn't have time to work on it... i will try to get a newlisp.vim based on 8.5.4 this weekend... no promises, but it's feasible :-)
take care and congrats for a great tool,
dvd
newLISP does not have a 'reader macro function', which could change the behaviour of the source code reader, which is hardcoded in newLISP (and very fast). so there is no ways to get rid of our beloved parenthesis.
An updated newlisp.vim is always included in the source distribuition in the doc directory, I always have been making changes to it as they came up. But it would be good to update it on your web site, as many people run into you site and get it from there.
Lutz
Quote from: "Lutz"
newLISP does not have a 'reader macro function', which could change the behaviour of the source code reader, which is hardcoded in newLISP (and very fast). so there is no ways to get rid of our beloved parenthesis.
OK, I was just wondering... I don't dislike parentheses, they are pretty useful ;-) (see? :-)
Quote
An updated newlisp.vim is always included in the source distribuition in the doc directory, I always have been making changes to it as they came up. But it would be good to update it on your web site, as many people run into you site and get it from there.
Lutz
Done (corrected the version number within the file)
I was thinking in adding some more support for different kinds of things still pending, and if we fix on an autoindent policy, implementing it so it makes autoindent as well...
but it's a bit tricky, so I may fail again, i'll let you know, anyway...
laters!