Re: [stack] recursion is too hard

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Mar 9, 2009, at 6:06 PM, William Tanksley wrote:

> John Nowak wrote:
>
>>    map(F) = ifte(null?, id, uncons spread(F, map(F)) cons)
>> Can you spot the problem? Is there a *general* method for avoiding  
>> it?
>
> I hope you get a clueful reply. I'll speak for all whose answer is  
> "no"
> to say, "no, I don't spot the problem."

Alright, if no one will bite...

The problem is that all calls to 'F' except the first see the values  
meant to be later consed onto the list from previous calls of 'F'. One  
solution is to swap the values out of the way, call 'map(F)' below the  
values to be later consed on, and then swap them back before the cons:

    map(F) = ifte(null?, id, uncons swap spread(map(F), F) swap cons)

My alternative "elegant" solution to this is a spread combinator  
variant that hides the result of the first function from the second.  
Slava has said this is possible to implement efficiently using smart  
combinators.

Despite some strong reservations about having semantics depend on  
types or stack effects, I think that smart combinators should probably  
be used more heavily. Producing better smart combinators is probably  
the most interesting "practical" research topic that could be worked  
on in the context of stack-based languages at the moment. I hope  
someone here is interested in pursuing it.

- John
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.