I’m trying to write several functions which each follow a similar kind of argument parsing.
In all cases the functions are unary functions.
However, there are three cases to consider. 1) the argument is not a list, 2) the argument is a singleton list, 3) the argument is a list with a head and non-empty tail.
I tried the following, but the compiler complains.
Can't have 2 overloads with same arity
What’s the correct way to do this?
(defn f ([expr] ;; case 1 1 ) ([[token & args]] (if (nil? args) ;; case 2 2 ;; case 3 3)))