meander

Stephan Renatus 2023-01-09T13:33:01.067289Z

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 Renatus 2023-01-10T08:47:53.669709Z

thanks for your reply. example data would be https://github.com/bobheadxi/gobenchdata/blob/gh-pages/benchmarks.json

Stephan Renatus 2023-01-10T08:48:19.882399Z

the records are homogeneous, there are no missing fields

Stephan Renatus 2023-01-09T13:33:06.384089Z

(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 Renatus 2023-01-09T13:33:23.719559Z

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

gdubs 2023-01-09T18:46:11.786239Z

best provide your input data

gdubs 2023-01-09T18:46:58.710679Z

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.