Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake in destructuring-pair?? #44

Closed
genovese opened this issue Apr 13, 2022 · 1 comment · Fixed by #45 or #48
Closed

Mistake in destructuring-pair?? #44

genovese opened this issue Apr 13, 2022 · 1 comment · Fixed by #45 or #48

Comments

@genovese
Copy link

The definition of destructuring-pair? looks like it is missing something in the second clause:

(defn- pair? [x] (and (vector? x) (= 2 (core/count x))))
(defn- destructuring-pair? [x]
  (and (pair? x) (not (or (keyword? x) (= '& x)))))

[Lines 30-32 in current version.]

If pair? x is true, then x is certainly not a keyword or a symbol, so the second clause is automatically true, obviating the need for the function. Should the second clause be replaced with (not (some #(or (keyword? %) (= '& %)) x)), or perhaps (not (or (some keyword? x) (= '& (first x)))) if preferred for your intent?

@imrekoszo
Copy link
Collaborator

It appears to me that the second clause in the and should check the first element of x. The only two-element destructuring vectors I currently am aware of are:

(let [[& foo] (range 10)
      [:as bar] (range 5)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants