Optimized tail recursion

For the Compleat Fan
Locked
Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Optimized tail recursion

Post by Jeff »

Is there any optimization of tail recursion in newLisp?
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

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

Post by Lutz »

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

Lutz

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

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

Artful code

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

Post 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

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post 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?
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

jrh
Posts: 36
Joined: Mon Nov 14, 2005 9:54 pm
Location: Portland, Oregon

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

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post 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.
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

jrh
Posts: 36
Joined: Mon Nov 14, 2005 9:54 pm
Location: Portland, Oregon

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

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post 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.
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Locked