Optimized tail recursion

Started by Jeff, August 22, 2007, 07:09:13 AM

Previous topic - Next topic

Jeff

Is there any optimization of tail recursion in newLisp?
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#1
No, and never will be, if it's tail-recursive it's easy to translate into iteration ;)



Lutz

Jeff

#2
This is true.  But it's not nearly as fun.  And truly, that is the one and only measure of any technique ;)
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#3
... here is some other good news: I am redoing the 'count primitive again so we can do this:


(count (sequence 0 127) (unpack (dup "b" (length str)) str))

a lot faster. Currently this takes about 7 seconds on a MacBook and works sorting the data, then counting and comparing with the list of things to count. It should be a lot faster using a hash algorithm and also scale in a linear fashion. The nice thing about 'count is, that it takes a list of any data type or s-expression to be counted.



Lutz

Jeff

#4
That's a good idea.  Interestingly enough, it takes about the same amount of time (assuming we are still talking about war and peace) on a quad-core g5.



Any change of including a dostring that iterates over characters quickly?
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

jrh

#5
Quote from: "Jeff" Interestingly enough, it takes about the same amount of time (assuming we are still talking about war and peace) on a quad-core g5.


That's because it is only using one processor.

Jeff

#6
True, but it's only using one 2.5GHz processor with 4 gigs of RAM and a very fast 300 GB SATA HD.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

jrh

#7
The SATA drive should not be a factor either as War and Peace will easily fit into RAM.



I know you are thrilled as all get out by your toy, but frankly I'm not impressed.  Given the current state of OSX and the available compilers, using a quad core for anything but a server seems pretty silly to me.  



Here is a processor that shows evidence of some real engineering talent - i.e. 1 watt @ 500 mhz:



http://www.linuxdevices.com/news/NS2399097703.html">//http://www.linuxdevices.com/news/NS2399097703.html



But then again, I liked the Mac Cube and prefer the Prius to the MurciƩlago.

Jeff

#8
SATA makes a difference in reading the file.  Enormous amounts of fast RAM makes a huge difference in processing large lists, such as would be created when unpacking a large string into a list of characters.



If it could do the job using 1 watt, what a world we would live in.



Until then, I am happy to use a super-powerful computer at work that generates enough heat to replace the building's furnace.  I will count characters with it by day and ride it by night.

 

In fact, I have developed a case mod that concentrates the heat generated by the power my machine wastes with its four cores into a super-powerful beam that can cut through bedrock.  Soon, I shall use it to carve my initials in the moon, barring interference from any big, blue superheroes.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code