Fork me on GitHub
Ben Sless18:04:49

Hello, I'm playing around with meader trying to replicate destructuring, and I can't figure out the correct accumulator syntax This naive rewrite works:

(let [s
       [[!b '& ?bs] [!x & ?xs]]
       [!b !x
        ?bs ?xs])]

  (s '[[x & xs] [1 2 3]]))
But anything I've tried with accumulators turned out wrong. Any ideas?


A couple things. Not 100% sure what you mean by accumulators. I'm also guessing you are using strategies. Any reason? Finally an example of what isn't working would be super helpful for knowing how we can help. Not sure if someone has reimplemented drstructuring already using meander, but should definitely be possible.

Ben Sless04:04:23

Thank you Here's an example where the final pattern fails

(let [s
       [[!b ..?n '& ?bs] [!x ..?n & ?xs]]
       [!b !x ..?n
        ?bs ?xs])]

  [(s '[[x & xs] [1 2 3]])
   (s '[[x y & xs] [1 2 3]])
   (s '[[x y z & xs] [1 2 3]])
   (s '[[x y z & xs] [1 2]])])