How to use macros for streaming?

My question is, how can I get one of the Clojure streaming macros to work in my particular case? Thanks.

I get this error:

(IllegalArgumentException Don't know how to create ISeq from: bene_csv.core$test_key_exclusion$fn__346 clojure.lang.RT.seqFrom (RT.java:487) 

When I call this function:

 bene-csv.core=> (test-key-exclusion bene-data 1 gic-data 0 2 3) 

Given this code - a working solution without a macro with a stream commented out -

 (defn ret-non-match-rows "Expects a sequence of sequences, like what is returned from clojure-csv. Returns nil if there a match; else returns failing row." [sos cmp-col-idx inq-row-idx inq-row] (let [inq-row inq-row] (loop [[row & remain-seq] sos pos 0] (let [cmp-val (nth inq-row inq-row-idx nil)] (cond (not row) inq-row (= cmp-val (nth row cmp-col-idx)) nil :not-found (recur remain-seq (inc pos))))))) (defn test-key-exclusion "This function takes csv-data1 (the includees) and tests to see if each includee is in csv-data2 (the includeds). This function also gathers enough other data, so that excludees (those not found), can be identified." [csv-data1 pkey-idx1 csv-data2 pkey-idx2 lnam-idx fnam-idx] (-> (map #(ret-non-match-rows csv-data2 pkey-idx2 pkey-idx1 %1) csv-data1) (filter (complement nil?)) (map (fn [row] (vector (nth row pkey-idx1 nil) (nth row lnam-idx nil) (nth row fnam-idx nil)))))) (comment (map (fn [row] (vector (nth row pkey-idx1 nil) (nth row lnam-idx nil) (nth row fnam-idx nil))) (filter (complement nil?) (map #(ret-non-match-rows csv-data2 pkey-idx2 pkey-idx1 %1) csv-data1))) 

with data like the following:

 [["0123456789" "SMITHFIELD" "HAM"]["1123456789" "LITTLE" "CHICKEN"] ...] 
+4
source share
1 answer

You use the thread-first macro, but you must use the thread-last macro . The thread-last macro attached to the ->> character does the same as the thread-first macro, except that it inserts the forms as the last argument instead of the first.

So your code will look something like this:

 (->> (map #(ret-non-match-rows csv-data2 pkey-idx2 pkey-idx1 %1) csv-data1) (filter (complement nil?)) (map (fn [row] (vector (nth row pkey-idx1 nil) (nth row lnam-idx nil) (nth row fnam-idx nil)))))) 
+15
source

Source: https://habr.com/ru/post/1411815/


All Articles