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

Problem 32/46 #36

Open
beaverbrook opened this issue May 30, 2018 · 0 comments
Open

Problem 32/46 #36

beaverbrook opened this issue May 30, 2018 · 0 comments

Comments

@beaverbrook
Copy link

beaverbrook commented May 30, 2018

I keep getting the exception, "clojure.lang.ArityException: Wrong number of args (0) passed to: core//"

I've isolated it to the second recur line. Is this a bug? Thanks.

(ns group-a-sequence)

(defn my-group-by [f s]
  (loop [x (rest s)
            acc {(f (first s)) [(first s)]}]
    (if (not (empty? x))
      	(if (not (nil? (get acc (f (first x)))))
            (recur (rest x) (assoc acc (f (first x)) (conj (get acc (f (first x))) (first x))))
            
            ;*********************
            (recur (rest x) acc)) ; clojure.lang.ArityException: Wrong number of args (0) passed to: core//
            ;*********************

            ;(recur (rest x) (assoc acc (f (first x)) [(first x)])))
        ;acc)))
        3)))
      
(def s [[1 2] [2 4] [4 6] [3 6]])
(def f #(apply / %))

(my-group-by f s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant