Hey Frank, Try opening up a repl, and running this *for* comprehension.
(def user_textfile [[:id1 {:name 'Frank'}] [:id3 {:name 'Tim'}]]) (def user_database [[:id1 {:age 38}] [:id2 {:age 27}] [:id3 {:age 18}] [:id4 {:age 60}]]) (for [i user_textfile j user_database :when (= (first i) (first j))] {(first i) (merge (second i) (second j))}) *({:id1 {:age 38, :name Frank'}} {:id3 {:age 18, :name Tim'}}) ;; result from repl * Hth Tim Washington Interruptsoftware.com <http://interruptsoftware.com> On Sun, Mar 9, 2014 at 5:33 AM, Frank Behrens <fbehr...@gmail.com> wrote: > Hi, > > i'm investigating if clojure can be used to solve the challenges and > problems we have at my day job better than ruby or powershell. A very > common use case is validating data from different systems against some > criteria. i believe clojure can be our silver bullet, but before that, it > seems to be required to wrap my head around it. > > So I am starting in the first level with the challenge to validate some > data from the user database against our active directory. > > I already have all the parts to make it work: Which is to make a hash by > user_id from the database table, export a textfile from AD, each line > representing a user, parse it, merge the information from the > user_table_hash, and voila. > > I did not finish to implement this. So I don't know if this naive approach > will work with 400.000 records in the user database and 100.000 in the > textfile. > But I already think about how I could implement this in a more memory > efficient way. > > So my simple question: > > I have user_textfile (100.000 records) which can be parsed into a > unordered list of user-maps. > I have user_table in the database(400.000 record) which I can query with > order and gives me an ordered list of user-maps. > > So I would first order the user_textfile and then conj the user_table > ordered list into it, while doing the database query. > Is that approach right ? How would I then merge the two ordered lists like > in the example below? > > (defn user_textfile > ([:id1 {:name 'Frank'}] > [:id3 {:name 'Tim'}])) > > (defn user_database > ([:id1 {:age 38}] > [:id2 {:age 27}] > [:id3 {:age 18}] > [:id4 {:age 60}])) > > (merge-sorted-lists user_database user_textfile) > => > ([:id1 {:name 'Frank' :age 38}] > [:id3 {:name 'Tim' :age 18}])) > > Any feedback is appreciated. > Have a nice day, > Frank > > -- > 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. > -- 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.