That's great too; I think I'll use this instead, since it doesn't
involve unpacking lists. Thanks a lot, both of you.
On Dec 24, 11:39 am, Sean Devlin wrote:
> We could define a fn called take-until
>
> (defn take-until
> [pred coll]
> (take-while (complement pred) coll))
>
> And get the last
We could define a fn called take-until
(defn take-until
[pred coll]
(take-while (complement pred) coll))
And get the last entry of that
user=>(last (take-until odd? [2 4 6 8 9 10 11]))
8
It's based on take-while, so it's lazy.
Sean
On Dec 24, 1:34 pm, Chouser wrote:
> On Thu, Dec 24, 200
Excellent, thank you very much!
On Dec 24, 11:34 am, Chouser wrote:
> On Thu, Dec 24, 2009 at 1:24 PM, samppi wrote:
> > I'm having trouble with figuring out something. First, to get the
> > first element of a sequence so that (pred element) is false, you do
> > (first (drop-while pred sequence)
On Thu, Dec 24, 2009 at 1:24 PM, samppi wrote:
> I'm having trouble with figuring out something. First, to get the
> first element of a sequence so that (pred element) is false, you do
> (first (drop-while pred sequence)). This is lazy, and stops
> immediately when the element is found.
>
> Now, I
I'm having trouble with figuring out something. First, to get the
first element of a sequence so that (pred element) is false, you do
(first (drop-while pred sequence)). This is lazy, and stops
immediately when the element is found.
Now, I want to get the element *right before* the element returne