Page 1 of 1
Optimized tail recursion
Posted: Wed Aug 22, 2007 2:09 pm
by Jeff
Is there any optimization of tail recursion in newLisp?
Posted: Wed Aug 22, 2007 2:40 pm
by Lutz
No, and never will be, if it's tail-recursive it's easy to translate into iteration ;)
Lutz
Posted: Wed Aug 22, 2007 2:50 pm
by Jeff
This is true. But it's not nearly as fun. And truly, that is the one and only measure of any technique ;)
Posted: Wed Aug 22, 2007 3:50 pm
by Lutz
... here is some other good news: I am redoing the 'count primitive again so we can do this:
Code: Select all
(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
Posted: Wed Aug 22, 2007 6:18 pm
by Jeff
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?
Posted: Fri Aug 24, 2007 3:05 pm
by jrh
Jeff wrote: 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.
Posted: Fri Aug 24, 2007 3:40 pm
by Jeff
True, but it's only using one 2.5GHz processor with 4 gigs of RAM and a very fast 300 GB SATA HD.
Posted: Fri Aug 24, 2007 4:23 pm
by jrh
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
But then again, I liked the Mac Cube and prefer the Prius to the MurciƩlago.
Posted: Fri Aug 24, 2007 4:43 pm
by Jeff
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.