1
votes

I want to take a sequence [44 1 11] generated using (map #(nth %1 0 nil) v1) and feed (map) that into successive calls to the same function. I am just not sure which Clojure builtin or builtins to use other than for.

Here are the details.

Given these two vectors:

(def v1 [[44 2 3 4 5]
         [1 6 7 5 10]
         [11 12 13 14 15]])

(def v2 [[1 2 3 4 44]
         [1 6 7 5 1]
         [11 12 13 14 44]])

and this function

(defn ret-non-match-rows
    "Expects a sequence of sequences, like what is returned from clojure-csv.
     Returns all csv rows that do not match cmp-val at cmp-col-idx."

    [s-o-s cmp-val cmp-col-idx]

    (filter (complement nil?) 
       (map #(if (ret-col-match %1 cmp-val cmp-col-idx) nil %1) s-o-s) ))

So I am asking for help in how to feed (map) [44 1 11] into ret-non-match-rows like this

(ret-non-match-rows v2 44 4)
(ret-non-match-rows v2 44 1)
(ret-non-match-rows v2 44 11)

but using Clojure built-ins to generate those individual calls.

Thank You.

Edit:

The following gives me what I want, but I'm wondering if there is a cleaner way to do it.

(def ssn-1 [44 1 11])
(def tst (partial ret-non-match-rows v2 4))
(map #(tst %1) ssn-1)

I get back a sequence of sequences and will parse that to get my results.

1
I am having trouble understanding the question. Are you asking for help writing ret-non-match-rows, or ret-col-match, or something else? - user100464
What is v2 for? You don't seem to use it anywhere. - Rafał Dowgird
I've edited the original post, and hopefully it's a little clearer. - octopusgrabbus
@octopusgrabbus Sorry, it is even less clear now. How do elements from v1 and v2 map to the arguments in the sequence of calls? - Rafał Dowgird
It makes some sense if the 4 in the first call is a typo (and you meant 44 instead), I made an answer based on this assumption. - Rafał Dowgird

1 Answers

1
votes

Maybe you want this:

(map (partial ret-non-match-rows v2 44) (map first v1))

(assuming the 4 in the first example call is a typo and should be 44)