On Monday, 3 September 2012 14:03:42 UTC+1, Dave Sann wrote:
>
> (defn take-while-reduce
> "fancy take accumulating a reduced value on taken items
> this value can then be tested in the take fn
>
Much appreciated.
--
You received this message because you are subscribed to the Google
Grou
On Monday, 3 September 2012 06:26:07 UTC+1, Stephen Compall wrote:
>
> (->> ss (map tok-fn), (reductions (partial apply merge) #{}),
> (take-while #(...)), (map #(do %2 %1) ss), last)
>
> Use of `atom' for this sort of thing is certainly an antipattern, so
> consider any alternative that su
On Tue, 2012-09-04 at 15:24 -0700, Sean Corfield wrote:
> But that is a hypothetical, yes? You're not suggesting that take-while
> actually does that, right?
Right. As of right now.
--
Stephen Compall
"^aCollection allSatisfy: [:each | aCondition]": less is better than
--
You received this m
On Tue, Sep 4, 2012 at 2:23 PM, Stephen Compall
wrote:
> On Tue, 2012-09-04 at 09:48 -0700, Sean Corfield wrote:
>> Stephen, could you elaborate on this?
>
> Requiring pred to be free of side effects provides many invariants about
> it to the `take-while' implementation; the legality of out-of-ord
On Tue, 2012-09-04 at 09:48 -0700, Sean Corfield wrote:
> Stephen, could you elaborate on this?
Requiring pred to be free of side effects provides many invariants about
it to the `take-while' implementation; the legality of out-of-order
calling is just one of them.
> My reading of the side-effect
On Mon, Sep 3, 2012 at 1:58 PM, Stephen Compall
wrote:
> On Sun, 2012-09-02 at 23:02 -0700, Ben Wolfson wrote:
>> Can you say what this means (the note about take-while being called in
>> coll order)?
>>
>> Does it mean that it's not a guarantee of the API that the predicate
>> passed to take-whil
On Mon, Sep 3, 2012 at 10:36 PM, Aaron Cohen wrote:
>
> It wouldn't even be all that insane if you had 1000 otherwise idle
> cores sitting around and an expensive enough predicate.
Touché (perhaps up to a factor of n). (Though I suspect you need more
assumptions given that the specific algorithm
On Tue, Sep 4, 2012 at 1:24 AM, Ben Wolfson wrote:
> On Mon, Sep 3, 2012 at 1:58 PM, Stephen Compall
> wrote:
> Of course take-while might cause more of a lazy seq to be realized
> than is present in its output because of seq chunking. But I'd *hope*
> that it wouldn't exacerbate that by reservin
On Mon, Sep 3, 2012 at 1:58 PM, Stephen Compall
wrote:
>> I would have hoped that would be guaranteed
>
> Nevertheless, by declaring "pred must be free of side-effects",
> `take-while' is refusing to make that promise, among many others.
It seems like a leap to go from pred being free of side-eff
On Mon, 2012-09-03 at 01:12 -0700, Alan Malloy wrote:
> (map #(do %2 %1) c1 c2) is a neat trick I hadn't seen in this context;
> thanks for showing me!
Perhaps you'd also like to advocate for the inclusion of `first-arg',
which has several other uses, in core? :)
--
Stephen Compall
^aCollection
On Sun, 2012-09-02 at 23:02 -0700, Ben Wolfson wrote:
> Can you say what this means (the note about take-while being called in
> coll order)?
>
> Does it mean that it's not a guarantee of the API that the predicate
> passed to take-while be called *successively* on the items in the
> collection pa
I have used the following (from a bunch of utils I have for seqs) in the
past to do this kind of thing.
You will need to define the reduce-fn and the predicate you need.
examples below in the comment.
(defn take-while-reduce
"fancy take accumulating a reduced value on taken items
this va
I have used the following in the past in some utils I have for seqs:
(defn take-while-reduce
"fancy take accumulating a reduced value on taken items
this value can then be tested in the take fn
e.g (take-while-reduce 0 (fn [v i] (inc v))
(fn [v i] (= v i))
(map #(do %2 %1) c1 c2) is a neat trick I hadn't seen in this context;
thanks for showing me!
On Sunday, September 2, 2012 10:26:07 PM UTC-7, Stephen Compall wrote:
>
> On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote:
> > I have written the following function using take-while and a pred
> >
On Sun, Sep 2, 2012 at 10:25 PM, Stephen Compall
wrote:
> On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote:
>> I have written the following function using take-while and a pred
>> function with an atom to store the set of unique tokens. It works
>
> Only because in the current implementation, ta
On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote:
> I have written the following function using take-while and a pred
> function with an atom to store the set of unique tokens. It works
Only because in the current implementation, take-while happens to be
called in coll order, which is not a guar
16 matches
Mail list logo