Hi I am trying a functional solution for a recurrent problem. I must balance 2 vectors :
I must pass from A1 to A2 with following priority: assign aval qty first for records with the same :cat , then to needs in early :day. Thanking in advance for any kind of help. PS :day in format AAAMMDD (def A1 {:avail [ {:day 20190101 :qty 10 :mkey "AAABB" :cat "CO1"} {:day 20190101 :qty 20 :mkey "OS100" :cat "CO1"} {:day 20190102 :qty 50 :mkey "OS200" :cat " "} {:day 20190103 :qty 50 :mkey "OS300" :cat " "} {:day 20190104 :qty 40 :mkey "OS400" :cat " "} ] :needs [ {:day 20190107 :qty -100 :mkey "OS200" :cat " "} {:day 20190108 :qty -50 :mkey "OS300" :cat " "} {:day 20190109 :qty -100 :mkey "OS400" :cat " "} {:day 20190217 :qty -100 :mkey "OS100" :cat "CO1"} ] } ) after (def A2 {:avail [ {:day 20190101 :qty 0 :mkey "AAABB" :cat "CO1"} {:day 20190101 :qty 0 :mkey "OS100" :cat "CO1"} {:day 20190102 :qty 0 :mkey "OS200" :cat " "} {:day 20190103 :qty 0 :mkey "OS300" :cat " "} {:day 20190104 :qty 0 :mkey "OS400" :cat " "} ] :needs [ {:day 20190107 :qty 0 :mkey "OS200" :cat " "} {:day 20190108 :qty -10 :mkey "OS300" :cat " "} {:day 20190109 :qty -100 :mkey "OS400" :cat " "} {:day 20190217 :qty -70 :mkey "OS100" :cat "CO1"} ] } ) -- 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.