On Aug 16, 10:02 am, botgerry <botge...@gmail.com> wrote:
> 1:  searching in a, if find one inner vector includes number 9 then
> append it a number 13
>  [[1 2 3 4] [ "ok" "metoo"] [ 5 8 9 ]]  => [[1 2 3 4] [ "ok" "metoo"]
> [ 5 8 9 13]]

(into []
  (for [x a]
    (if (contains? x 9)
      (conj x 13)
      x)))

> 2: searching in a, if found two or many inner vectors include same
> element the merge them as one inner vector
> others not touch
>
> (def b ( conj  a  [ 5  10 "oops"]))  => [[1 2 3 4] ["ok" "metoo"] [5 8
> 9] [5 10 "oops"]]
> in b, [5 8 9] and [5 10 "oops"] both include 5, it should be merge to
> [5 8 9 10 "oops"] :
> [[1 2 3 4] ["ok" "metoo"] [5 8 9] [5 10 "oops"]]  => [[1 2 3 4] ["ok"
> "metoo"] [5 8 9 10 "oops"]]

Does the order matter? If it doesn't, this could probably be most
easily done with sets and maps.

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