Y'know, I'm guilty of not looking into flatland/useful enough. I'll have to 
try out codox on it, and see if that makes it easier for me to get 
acquainted with it.

Thanks, Alex.



On Wednesday, March 19, 2014 6:57:27 AM UTC-4, Alex Nixon wrote:
>
> Or use glue from flatland.useful.seq <https://github.com/flatland/useful>
>  and:
>
> user=> (glue conj [] (fn [s n] (= (inc (last s)) n)) [1 3 4 5 7 9 10 13])
> ([1] [3 4 5] [7] [9 10] [13])
>
>
> On 19 March 2014 04:10, Shantanu Kumar <kumar.s...@gmail.com <javascript:>
> > wrote:
>
>>
>>
>> On Wednesday, 19 March 2014 09:39:56 UTC+5:30, Shantanu Kumar wrote:
>>>
>>> Something like this?
>>>
>>> (defn x [1 3 4 5 7 9 10 13])
>>>
>>
>> Sory for the typo. Should be (def x [1 3 4 5 7 9 10 13])
>>  
>>
>>>
>>> (reduce (fn [a i] (let [y (last a) z (last y)] (if (and z (= (inc z) i)) 
>>> (conj (pop a) (conj y i)) (conj a [i])))) [] x)
>>>
>>> Shantanu
>>>
>>> On Wednesday, 19 March 2014 08:26:43 UTC+5:30, John Gabriele wrote:
>>>>
>>>> If you've got a sorted list of numbers, for example:
>>>>
>>>>     [1 3 4 5 7 9 10 13]
>>>>
>>>> where some are consecutive, how can you pull out the consecutive runs? 
>>>> That is, either produce
>>>>
>>>>     [1 [3 4 5] 7 [9 10] 13]    ; or maybe something like
>>>>     [[1 7 13] [3 4 5] [9 10]]  ; (the first vec is the elements left 
>>>> over)
>>>>
>>>> from the original coll?
>>>>
>>>> I can do it in Python in an imperative style, but it's a bit messy. My 
>>>> hunch is that there's probably a shorter way in Clojure, but I'm not 
>>>> seeing 
>>>> it.
>>>>
>>>> Thanks!
>>>>
>>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to