Thanks, all.
Earlier, I was going to ask how to break out of a sequence op prematurely, 
i.e., you give it some replication number but want to break early if you get an 
end-flag value. While I was composing the post I thought of using Maybe for the 
good values and Nothing for the end value. Ergo, losing the Nothings at the end.
I was passing a map and an empty list into some state, but since the map 
doesn't change once it's created I moved it into a Reader. I was using the list 
to collect the elements but thought I can get that functionality automatically 
using sequence. 
So, one thing leads to another. It's interesting how ideas begin bubbling up 
after one absorbs some critical mass of Haskell.
Michael  
--- On Mon, 5/23/11, Malcolm Wallace <malcolm.wall...@me.com> wrote:

From: Malcolm Wallace <malcolm.wall...@me.com>
Subject: Re: [Haskell-cafe] [Maybe Int] sans Nothings
To: "haskell-cafe Cafe" <haskell-cafe@haskell.org>
Date: Monday, May 23, 2011, 12:35 PM


On 23 May 2011, at 17:20, michael rice wrote:

> What's the best way to end up with a list composed of only the Just values,
> no Nothings?

Alternatively,

    [ x      | Just x <- originals ]

It also occurs to me that perhaps you still want the Just constructors.

    [ Just x | Just x <- originals ]
    [ x      | x@(Just _) <- originals ]


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to