This is a bug, similar to https://dev.clojure.org/jira/browse/CLJ-2105 and http://dev.clojure.org/jira/browse/CLJ-2003. I've spent a little time on it but have not figured out the exact problem. If you'd like to file it and reference those and/or drop it as a comment on one of those, would be happy to have more cases to verify when it's fixed.
On Sunday, July 30, 2017 at 1:33:45 AM UTC-5, Cole Frederick wrote: > > Hi to anyone reading, > I'm trying to understand a difference in behavior when using > clojure.spec/conform on two different regex ops: + and *. > They often conform the same when there is at least one item, but not > always. > > One small case I've found is: > (s/def ::evens-or-odds (s/alt :evens (s/+ even?) > :odds (s/+ odd?))) > > (defn conform-test [nums] > (let [star (s/conform (s/* ::evens-or-odds) nums) > plus (s/conform (s/+ ::evens-or-odds) nums)] > [(= star plus) > star > plus])) > > (conform-test [1 2 3]) => > [true > [[:odds [1]] [:evens [2]] [:odds [3]]] > [[:odds [1]] [:evens [2]] [:odds [3]]]] > > (conform-test [1 2 2]) => > [false > [[:odds [1]] [:evens [2 2]]] > [[:odds [1]] [[:evens [2 2]]]]] > > (conform-test [1 2 2 3]) => > [false > [[:odds [1]] [:evens [2 2]] [:odds [3]]] > [[:odds [1]] [[:evens [2 2]] [:odds [3]]]]] > > They conform the same for the first, but on the second and third, the + > regex wraps all but the first group in a vector. I believe it has something > to do with nested regex ops, but I haven't figured out the pattern. > > Same conform value: > [1 2] > [1 2 3] > [1 1 2 3] > > Different conform values: > [1 2 2] > [1 2 2 3] > [1 2 3 3] > > I appreciate your time and any insight or ideas about why these sets of > cases conform differently. > Thanks, > Cole > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
