Fork me on GitHub

@timothypratley Another idea for #130: extend the familiar & syntax:

{&... [!k !v]}
;; desugars intuitively to 
{& (m/seqable [!k !v] ...)}

;; or

{&!k !v} ;; implicitly includes !v in the repeating pattern

;; or 

{&!k &!v} ;; over-specification? 
There is already precedence in ..?n for splitting a symbol up into components to bind ?n


I agree and I like the {&!k !v} notation! That seems very intuitive to me and I like that it doesn’t use metadata. I think this would be really cool and work well!


This would also apply to sets: #{ &!x } looks better to me than using metadata #{ ^& !x }


+1 I think this looks way better than the metadata and I find it clearer about the structure (metadata is always weird because it looks like another element). I think this works still for expression: #{(m/pred int? &!x) &?more} seems possible and very cool 🙂


All, just getting started with meander, and trying to match against a pattern of keys within a map to return in a search. For example

(defn testm [input]
  (m/search input
    (m/scan {(m/re #"LX") ?result})
    {:result ?result}))

(testm {"LX-1" "a" "LX-2" "b"})


where I would want to result to be

({:result "a"} {:result "b"})
is this possible?


I think this will do what you want:

(defn testm [input]
  (m/search input
            {(m/re #"LX.*") ?result}
            {:result ?result}))


Thank you, if I wanted to nest that part in a broader transformation (say there were other keys that I was applying a transformation to), would you recommend apply different m/search’s and then composing the results?


It all depends on what you are wanting to accomplish. You can do other keys as well inside the same search. There is no limitation on that. For example:

(m/search {"LX-1" "a" "LX-2" "b" :x 1 :y 2}
  {(m/re #"LX.*") ?result
   :x ?x
   :y ?y}
  {:result ?result
   :x (even? ?x)
   :y (even? ?y)})


I'm fairly new to meander myself, so take anything I say with a grain of salt, but most of what I have been doing is matching/transforming nested maps and I rarely have to use more than one top-level rewrite/search/etc.


thank you, that is really helpful, attempting to translate a bunch of custom transformation base clojure to meander, so very much in the easy stages of understanding what it can do.