Monad newbie question

2011-01-13 Thread Saul Hazledine
Hello, I've never used monads but I have a problem that feels like it could be solved elegantly with them. I have a sequence of functions of arbitary size and an input sequence s. Each function is given a sequence and returns a sequence that can be bigger than the input sequence. I want the

Re: Monad newbie question

2011-01-13 Thread Saul Hazledine
On Jan 13, 9:18 am, Saul Hazledine shaz...@gmail.com wrote: Hello,   I've never used monads but I have a problem that feels like it could be solved elegantly with them.  I have a sequence of functions of arbitary size and an input sequence s. Each function is given a sequence and returns a

Re: Monad newbie question

2011-01-13 Thread Ken Wesson
On Thu, Jan 13, 2011 at 3:18 AM, Saul Hazledine shaz...@gmail.com wrote: Hello,  I've never used monads but I have a problem that feels like it could be solved elegantly with them.  I have a sequence of functions of arbitary size and an input sequence s. Each function is given a sequence and

Re: Monad newbie question

2011-01-13 Thread Saul Hazledine
On Jan 13, 7:35 pm, Ken Wesson kwess...@gmail.com wrote:    (let [seq-of-fns [f1 f2 f3 ... fm]]         (mapcat fm ... (mapcat f2 (mapcat f1 s))) If any of the functions return nil, I'd like the computation to stop. I don't see any real reason not to use (reduce #(if %1 (mapcat %2 %1))

Re: Monad newbie question

2011-01-13 Thread Meikel Brandmeyer
Hi, depending on the length of your function sequence you might run into stack overflows, though. Just keep that in mind (or add a tactically placed doall). Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send