Skip to content

Problem 32/46 #36

Description

@beaverbrook

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions