newLisp competition 2007

For the Compleat Fan
m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm
Location: Carifornia

Post by m35 »

rickyboy wrote:I actually can't bring myself to steal anything, unless I put the outfit on. :-)
rofl that's the funniest thing I've seen all week XD

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

Post by newdep »

Now i have a dilemma ;-)

I need to pick 2 files for the competition, not easy as there are some files/tools I like but perhpas others dont at all.
Difficult selection, for me, perhpas for you not at all. So i go for the most common divisor called "enjoyable tools" ;-)




So my First contribution is Pinballs, because of its hyphnotic infuence ;-)

(load "http://www.nodep.nl/downloads/newlisp/pinballs.lsp")
or can be found inside your newlisp distribution when using GS! ;-)

Image



My second contribution is (although still in progress)
(load "http://www.nodep.nl/downloads/newlisp/nlist.lsp")


Image
-- (define? (Cornflakes))

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Ah, the floodgates are opening... :-)

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Post by itistoday »

newdep wrote:My second contribution is (although still in progress)
(load "http://www.nodep.nl/downloads/newlisp/nlist.lsp")
Wow, I just spent some time using that to go through the newLISP files on your server, they're amazing! My favorite has to be worm.lsp!

Great job! :-D

And I love how you can load them just by using them as an argument to newlisp:

Code: Select all

$ newlisp http://www.nodep.nl/downloads/newlisp/worm.lsp

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

Post by newdep »

It's a .........!

Not a contribution for the newlisp competition but very well worth to be announced to the world and a very healty contribution to our family ;-)

(load "http://www.nodep.nl/downloads/newlisp/itsa.lsp")

We Enjoy ;-)
-- (define? (Cornflakes))

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

Post by Lutz »

Congratulations and my best wishes for you, and your growing family. Lets hope little Norman (what is his name?) leaves his amazingly creative dad some time for making more wonderful programs :-)

Lutz

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post by m i c h a e l »

Since Lutz has expressed it so well already, let Melissa and I just say: Congratulations on your new boy!

m i c h a e l

P.S. I wonder if your son will one day appreciate that his birth announcement was written in newLISP :-)

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

Post by newdep »

Thanks ! ;-)
-- (define? (Cornflakes))

ghfischer
Posts: 14
Joined: Mon May 09, 2005 4:17 pm
Location: Austin, tX

A short helper.

Post by ghfischer »

Although not a complex piece of code, the following is quite useful when you have to sort lists the way most real people think of sorting.

Code: Select all

(define (natural-key s)
  (set 'strs (parse s "[0-9]+" 0))
  (set 'nums (find-all "[0-9]+" s))
  (if nums (set 'nums (map int nums)) (set 'nums '()))
  (filter if (flat (transpose (list strs nums))))
)

(define (natural-sort l)
  (sort l (fn (x y) (< (natural-key x) (natural-key y))))
)

(set 'foo '("i19n" "i17n" "z40" "40a" "50" "foo" "z4000" "z30"))

(natural-sort foo)
which returns

Code: Select all

("40a" "50" "foo" "i17n" "i19n" "z30" "z40" "z4000")
Based on Human Sorting

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

Post by Lutz »

But doesn't the plain newLISP 'sort' do this already?

Code: Select all

(set 'foo '("i19n" "i17n" "z40" "40a" "50" "foo" "z4000" "z30")) 

(sort foo) => ("40a" "50" "foo" "i17n" "i19n" "z30" "z40" "z4000")
Lutz

ps: but the difference will show up with a different example:

Code: Select all

(set 'foo '("i19n" "i17n" "z40" "40a" "50" "foo" "z4000" "z80"))

; natural sort
("40a" "50" "foo" "i17n" "i19n" "z40" "z80" "z4000")

; plain sort
("40a" "50" "foo" "i17n" "i19n" "z40" "z4000" "z80")

ghfischer
Posts: 14
Joined: Mon May 09, 2005 4:17 pm
Location: Austin, tX

Better example.

Post by ghfischer »

Good point Lutz. I should have provided a better example.

Here's the basic case

Code: Select all

> (natural-sort '("a10" "a2" "a1" "a14"))
("a1" "a2" "a10" "a14")
> (sort '("a10" "a2" "a1" "a14"))
("a1" "a10" "a14" "a2")
and the embedded case

Code: Select all

> (natural-sort '("i30z" "i3n" "i20n" "i18z"))
("i3n" "i18z" "i20n" "i30z")
> (sort '("i30z" "i3n" "i20n" "i18z"))
("i18z" "i20n" "i30z" "i3n")
Of course there's always the edge cases ...

Code: Select all

> (natural-sort '("i1" "i03" "i5"))
("i1" "i03" "i5")
> (sort '("i1" "i03" "i5"))
("i03" "i1" "i5")
To me having the zero first seems better. But to most non-programmers it doesn't. Hopefully whatever you're sorting in this case will have consistency on leading zeroes.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

a little too short to get my vote (:-) but it's certainly nice to see you back on the board!

ghfischer
Posts: 14
Joined: Mon May 09, 2005 4:17 pm
Location: Austin, tX

Post by ghfischer »

cormullion wrote:a little too short
I also noticed that in 9.2.5 or higher I can make it even shorter! :)

Code: Select all

(define (natural-key s)
  (filter if (flat (transpose (list (parse s "[0-9]+" 0) (map int (find-all "[0-9]+" s)))))))

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

Post by pjot »

Folks,

It's time for my contribution: a comicbook reader.

It is able to handle .cbr, .cbz and .rar formats, reads JPG, PNG and GIF files. Written with GTK-server because I am porting the newlisp code to another language as well.

Runs in Unix/Linux/Win32. Users of the infamous Win32 platform need to download 'unzip.exe' and 'unrar.exe' separately. See the header of the program for details.

Free comicbooks can be obtained from FlashbackUniverse, FreeComicBooks and many other places, including torrentsites (if you have the original copy yourself, of course ;-) )

The code is here: http://www.turtle.dds.nl/newlisp/comic.lsp
The corresponding configfile here: http://www.gtk-server.org/gtk-server.cfg

This is a screenshot of the program running in windowed mode, after pressing the right mouse button:

Image


The program also handles key events. Pressing the <SPACE> key moves forward to the next page, also <CURSORRIGHT>. The <CURSORLEFT> moves back, and with the 'F' key fullscreen mode can be toggled on or off.

Enjoy!!!

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Looks great, but...


Image

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

Post by pjot »

Runs in Unix/Linux/Win32.
I do not own a Mac so I cannot support MacOSX.... sorry! If you want me to support MacOSX, please donate €600,= so I can buy one :-)

From your error it seems newLisp is unable to load the GTK-server DLL. Did you compile it from scratch? It should be possible to run GTK on MacOSX, but again, I have never tested it myself...

Peter

tom
Posts: 168
Joined: Wed Jul 14, 2004 10:32 pm

Post by tom »

You have to admit that's the best "something's wrong" post ever, no matter what the problem is...

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

Post by Lutz »

There is a long drawn out procedure to compile the GTK libraries for the Mac (natively, not X-Windows) and I tried it twice, but never could get it to work.

Before OS X 10.5 Leopard, there was a rumor that GTK would ship with Mac OS X, but unfortunately this did not come true.

Lets just hope then one day GTK offers binaries for OS X, just like they do for Windows.

Lutz

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

Post by pjot »

You have to admit that's the best "something's wrong" post ever, no matter what the problem is...
That's true! I fully agree :-)
Lets just hope then one day GTK offers binaries for OS X, just like they do for Windows.
Indeed, I hope so too... as soon as it happens I'll support MacOSX as well.

Cheers
Pete

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

Competition rules?

Post by Cyril »

as long as the newlisp language is involved
I am just curious what the word "involved" means. Does my newLISP syntax highlighting mode for Vim (written in vimscript) qualify? Not that I am pretending to be a winner, but may I at least enter the competition with this contribution?
With newLISP you can grow your lists from the right side!

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

Post by newdep »

Hi Cyril,

Sure...you may post anything (upto 2 contributions..etc..) Its up to the users to descide what they vote ;-)
And even extentions like yours or even Modules are contributions and welcome ofcourse..

Regards, Norman.
-- (define? (Cornflakes))

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

Post by newdep »

Hi Pjot, Nice work the comicbook reader ;-)
-- (define? (Cornflakes))

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

Post by Cyril »

newdep wrote:Sure...you may post anything (upto 2 contributions..etc..)
So, let me start. My first contribution is newlisp.vim -- the newLISP syntax highlighting plugin for the Vim text editor. You can load it...Oops! You don't need to load anything, it is already on you computer: look into 'util' subdirectory of your newLISP installation. Russians have came! ;-) But, is you insist, it is script #2067 at the Vim site.

My second contribution is vidirect.lsp -- a small script that helps to download videos from sites like YouTube and some others. It is small because it does nothing by itself: it queries the site vidirect.ru to obtain the downloading url, it runs wget (windows version) to perform download, it even works with windows clipboard with an external program. Unfortunately the documentation is in Russian language -- the script is targeted not to lisp hackers, but to end users. The full distribution (source, binary, Russian documentation, two accompanying third-party programs) is here, and the source alone is here. Enjoy!
With newLISP you can grow your lists from the right side!

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

Post by pjot »

For Win32 users I made a ZIP package with the full application.

Installation:

1) Install a GTK Runtime Environment from here or here (either one will do).
2) Unzip the ZIP file in a directory of your choice.

It is assumed you have the newlisp binary in your PATH, and if not, copy it to the same directory.

Now run 'comic.exe' and enjoy!

Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Here's my contribution for this year (windows only):

http://hpwsoft.de/anmeldung/html1/newLI ... test07.php

(I am not ready in time, so I post what I have so far.)
;-(
(Project is far bigger than last contribution, so newLISP in heavy duty)


Merry christmas to all newLISP'ers!

Edit: The fact that I can not publish the source is that it contains technical and price data of my employer.
(I get a special permit from Lutz to do so. Thanks to Lutz!)
Last edited by HPW on Tue Dec 18, 2007 9:33 pm, edited 1 time in total.
Hans-Peter

Locked