99 Smiley's ahead :)

For the Compleat Fan
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

99 Smiley's ahead :)

Post by newdep »

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)))))
Last edited by newdep on Tue Apr 26, 2005 11:57 am, edited 1 time in total.
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

## Stringway
(1(string(flat(fn :-()))))
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

## (not (happy))
(append ":" (reverse(2 2(encrypt "smiley" "\065"))))
-- (define? (Cornflakes))

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

Post by Lutz »

## a long one with a deeper meaning
(join (map char (map (fn (c) (- c 66)) (map char (explode "|ok")))))

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

## Eazy
":-)"

## Less eazy
(first '(":-)"))

## Boring
(last '(":-)"))

## Also boring
(nth 1 '(":-)"))

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

## Last one and now going back to business
(join (list ":" "-" ")"))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

You? Business?? at 5 past 5 ;-)
-- (define? (Cornflakes))

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Take care, you are only 2 desks away... ;-)

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

Post by Lutz »

## for the mathmatician
(join (reverse (map char (factor 2419))))

## beaten up mathmatician
(join (reverse (map char (factor 113693))))

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

Post by rickyboy »

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
(λx. x x) (λx. x x)

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

## HistoricSmile
(495 3(get-url "http://www-2.cs.cmu.edu/~sef/sefSmiley.htm"))
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

## Glasses
(sym(1 3(string(list(sym(append(reverse(string (~ 7)))))))))
-- (define? (Cornflakes))

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

Post by rickyboy »

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
(λx. x x) (λx. x x)

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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.
-- (define? (Cornflakes))

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

Post by Excalibor »

OK, lame, but...

Code: Select all

(silent (dolist (i '(: - ")")) (print i)))
Still lame, but funnier ;-)

Code: Select all

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

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

Post by Lutz »

I think you mean:

Code: Select all

(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

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

Post by Excalibor »

Lutz wrote:I think you mean:

Code: Select all

(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! :-)
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...
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 :-)
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

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

Post by 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.

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

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

Post by Excalibor »

Lutz wrote: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? :-)
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!

Locked