For the partition-by solution to work, you have to ensure that the result 
set from the query is sorted by the foreign key:

(partition-by identity "aaabbbcccaaabbbcc")
;;=> ((\a \a \a) (\b \b \b) (\c \c \c) (\a \a \a) (\b \b \b) (\c \c))
(partition-by identity (sort "aaabbbcccaaabbbcc"))
;;=> ((\a \a \a \a \a \a) (\b \b \b \b \b \b) (\c \c \c \c \c))


On Monday, August 12, 2013 11:17:29 AM UTC-7, Colin Yates wrote:
>
> Great - thanks!
>
>
> On 12 August 2013 19:07, Jonah Benton <jo...@jonah.com <javascript:>>wrote:
>
>>
>> Sounds like a job for partition-by:
>>
>> http://clojuredocs.org/clojure_core/clojure.core/partition-by
>>
>>
>>
>> On Mon, Aug 12, 2013 at 1:55 PM, Colin Yates <colin...@gmail.com<javascript:>
>> > wrote:
>>
>>> Is there such a thing as a lazy group-by for a sequence of elements when 
>>> the elements are sorted on the criteria used to group them?  I can imagine 
>>> how one would look in a few lines of Clojure code but I am surprised there 
>>> isn't one already.
>>>
>>> My actual criteria is that I am pulling things from a database that live 
>>> on the "many" side of a one-many and I want to sort on the "one" FK.
>>>
>>> This is all based on the assumption that 
>>> http://clojuredocs.org/clojure_core/clojure.core/group-by is eager!
>>>  
>>> -- 
>>> -- 
>>> 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/groups/opt_out.
>>>  
>>>  
>>>
>>
>>  -- 
>> -- 
>> 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 a topic in the 
>> Google Groups "Clojure" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/clojure/yGP0Ac_CUkY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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/groups/opt_out.

Reply via email to