Streams in newLISP

For the Compleat Fan
Elica
Posts: 57
Joined: Wed Feb 13, 2008 6:41 pm

Post by Elica »

itistoday wrote:...since most of the basic tools for making streams in newLISP are there for them...
I'd say not most, but all. Theoretically, to have complete support for streams one need only constructor and two selectors (for head and tail). They are like CONS/CAR/CDR for lists.

So, if these three functions are implemented correctly, and if the underlying mechanism of the Lisp is OK, then this is all what is needed to be able to re-implement the examples above and any other example.

Oh, yes, printing a stream would be helpful, but this is a kind of 'debugging' function, not vital for the stream processing itself.

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

Post by itistoday »

Elica wrote:I'd say not most, but all. Theoretically, to have complete support for streams one need only constructor and two selectors (for head and tail). They are like CONS/CAR/CDR for lists.
Good point. :-)
Oh, yes, printing a stream would be helpful, but this is a kind of 'debugging' function, not vital for the stream processing itself.
And that's there as well, without tail-call recursion unfortunately. :-\
Get your Objective newLISP groove on.

Elica
Posts: 57
Joined: Wed Feb 13, 2008 6:41 pm

Post by Elica »

itistoday wrote:...without tail-call recursion unfortunately.
What about iteration? It does not gulp down the stack...

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

Post by itistoday »

Elica wrote:What about iteration? It does not gulp down the stack...
lol! Sorry, that's what I get for sticking too close to my scheme-inspired source for all things stream.

Here it is, this'll go forever if necessary:

Code: Select all

(define (print-stream s)
	(while (not (empty-stream? s))
		(print (head s) " ")
		(set 's (tail s))
	)
	"done"
)
:-D
Get your Objective newLISP groove on.

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

Elica wrote:
itistoday wrote:...without tail-call recursion unfortunately.
What about iteration? It does not gulp down the stack...
This reminds me a passage from "Code Patterns in newLISP": Recursion or iteration?

In any case we can get through!
;)

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

Post by itistoday »

newBert wrote:This reminds me a passage from "Code Patterns in newLISP": Recursion or iteration?
;)
It's just that I was translating Scheme code (which supports tail-call recursion) to newLISP. Tail-call recursion is just as fast as iteration (because they're pretty much the same thing, no?)
Get your Objective newLISP groove on.

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

itistoday wrote:It's just that I was translating Scheme code (which supports tail-call recursion) to newLISP.

That's what I do most of the time
;)
itistoday wrote:Tail-call recursion is just as fast as iteration (because they're pretty much the same thing, no?)
Personally, I prefer 'tail-call recursion' that I find more intuitive, clearer and more elegant. And I regret it is not optimized in newLISP.
:)

P.S.: that's why I'm still hesitant between Scheme and newLISP (with a slight preference for newLISP ... )

Elica
Posts: 57
Joined: Wed Feb 13, 2008 6:41 pm

Post by Elica »

newBert wrote:P.S.: that's why I'm still hesitant between Scheme and newLISP (with a slight preference for newLISP ... )
Why hesitant? Enjoy both!
Say NO to software monogamy.

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

newBert wrote:
Elica wrote:
itistoday wrote:...without tail-call recursion unfortunately.
What about iteration? It does not gulp down the stack...
This reminds me a passage from "Code Patterns in newLISP": Recursion or iteration?

In any case we can get through!
;)
After consulting the oracle of all knowledge, I found this:
http://en.wikipedia.org/wiki/Common_Lisp
Lastly, the Scheme standards documents require tail-call optimization, which the CL standard does not. Most CL implementations do offer tail-call optimization, although often only when the programmer uses an optimization directive. Nonetheless, common CL coding style does not favor the ubiquitous use of recursion that Scheme style prefers -- what a Scheme programmer would express with tail recursion, a CL user would usually express with an iterative expression in do, dolist, loop, or (more recently) with the iterate package.
That makes it official, iteration IS the CORRECT way to do it! ;) LOL
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

Elica wrote:
newBert wrote:P.S.: that's why I'm still hesitant between Scheme and newLISP (with a slight preference for newLISP ... )
Why hesitant? Enjoy both!
Say NO to software monogamy.
I agree ... but I have to take into account the limitations of my machine :D

I already have installed many Logo(s), including Elica and aUCBLogo that I really enjoy, PLT-Scheme, OpenLisp, FBSL (a "Freestyle" Basic for Windows), and occasionally Caml, Python and CLisp with the intention to compare...

... and I admit that sometimes it's all Greek (or Latin) to me ;)

But its really true that one enriches the other, and vice versa. I do not conceive to use only one programming language. Two or three seem acceptable in order to not disperse excessively :)

Moreover it's time that I do the "housework" :D

Well, I keep newLisp and Scheme, and Elica and aUCBLogo, and FBSL (because it is a interpreted Basic, flexible, fast and efficient). And I continue to study while having fun, or to have fun while studying. Because "I do not want to die stupid", as we say in French.

Regards,
B.
:)

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

xytroxon wrote:That makes it official, iteration IS the CORRECT way to do it! ;) LOL
... and what about the newLISP way? LOL again
;)

Elica
Posts: 57
Joined: Wed Feb 13, 2008 6:41 pm

Post by Elica »

Elica wrote:While waiting for permission to post the original paper...
I got a permission. Also, the author was so kind to send me the paper in PDF. I have uploaded it (temporarily) here:

http://elica.net/download/loethe.pdf

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm
Location: Carifornia

Post by m35 »

Thank you for sharing this Elica

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

Post by itistoday »

Elica wrote:I got a permission. Also, the author was so kind to send me the paper in PDF. I have uploaded it (temporarily) here:

http://elica.net/download/loethe.pdf
Awesome, thanks for doing that, I've downloaded it and have added it to the list of things I'm going to read. :-)
Get your Objective newLISP groove on.

Locked