On 27.12.2009, at 01:47, samppi wrote:

> creates a new rule that repeats a given subrule. The problem with rep+
> right now is that it increases the stack for every token it consumes,
> which overflows the stack with large amounts of tokens.
>
> Is there, then, a way to rewrite rep+ so that it does not grow the
> stack?

I don't see one immediately. The problem is not really related to  
monads, it's that your rep+ is recursive but not tail-recursive. Tail- 
recursive monadic functions can be handled using lazy evaluation, but  
this simple solution does not work in your case. Your rep+ needs to be  
written in a very different way.

One idea: if you can express rep+ in terms of m-until, you can then  
use the specialized version state-m-until that is not recursive any  
more.

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to