Fork me on GitHub
#meander
<
2023-01-09
>
Stephan Renatus13:01:01

heya. just starting to wrap my mind around meander, and it’s been pleasant so far. can someone point out my mistake here, please? I had hoped that the following two snippets (🧵) would to the same, but they don’t. I’m exploring rewrites.

Stephan Renatus13:01:06

(defn process-suites [benchmarks]
  (m/rewrites {:bench benchmarks}
              {:bench (m/scan {:Version ?v
                               :Date ?d
                               :Suites (m/scan {:Pkg ?pkg
                                                :Benchmarks (m/scan {:Name ?name
                                                                     :NsPerOp ?ns_per_op})})})}
              {:version ?v :date ?d :pkg ?pkg :name ?name :ns_per_op ?ns_per_op}))

(defn process-suites0 [benchmarks]
  (m/rewrites benchmarks
               [{:Version !v
                 :Date !d
                 :Suites [{:Pkg !pkg
                           :Benchmarks [{:Name !name
                                         :NsPerOp !ns_per_op} ...]} ...]} ... ]
              [{:version !v :date !d :pkg !pkg :name !name :ns_per_op !ns_per_op} ...]))

Stephan Renatus13:01:23

the first does the trick, the second one returns nil when called on the data

gdubs18:01:11

best provide your input data

gdubs18:01:58

m/scan isn't equivalent to what you have below. scan looks for anything that matches and will skip over mismatches. Your below example requires that everything match.

Stephan Renatus08:01:19

the records are homogeneous, there are no missing fields