Thanks Meikel,
This is in line with what I was thinking for my own custom filter
function.
Now how would you modify it if the same record can be both "sales" and
"upgrade" at the same time?
I.e. if filters are not mutually exclusive.

- Dmitry

On Oct 18, 8:12 am, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 18.10.2009 um 09:48 schrieb Dmitry Kakurin:
>
>
>
>
>
> > Here is what I have right now:
> >  (let [idata ... something ...
> >        sales
> >          (filter
> >            #($ (% "Product Type Identifier") = "1" &&
> >                 % "Vendor Identifier" = "01010012"
> >            )
> >            idata
> >          )
> >        upgrades
> >          (filter
> >            #($ % "Product Type Identifier" = "7" &&
> >                % "Vendor Identifier" = "01010012"
> >            )
> >            idata
> >          )
> >        demo
> >          (filter
> >            #($ % "Product Type Identifier" = "1" &&
> >                % "Vendor Identifier" = "01010318"
> >            )
> >            idata
> >          )
> >    ]
> >    (println "Sales   : " (sum-units sales))
> >    (println "Upgrades: " (sum-units upgrades))
> >    (println "Demo    : " (sum-units demo))
>
> Maybe you can do:
>
> (reduce (fn [[sales upgrades demo :as v] data]
>            (cond
>              (is-sales? data)   [(conj sales data) upgrades demo]
>              (is-upgrade? data) [sales (conj upgrades data) demo]
>              (is-demo? data)    [sales upgrades (conj demo data)]
>              :else v))
>          [[] [] []] (get-idata))
>
> This will hold the resulting collections completely in memory, but not  
> the idata part. This is maybe not what you want, because it's too big.  
> Or it is what you want, because you want to close the file at some  
> point in time. I think defining anything lazy will hold onto idata.  
> (or at least part of the end results)
>
> Sincerely
> Meikel
>
>  smime.p7s
> 3KViewDownload

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to