I am VERY green to Clojure. But I am trying to learn the syntax by creating some functions. I am having issues with the parentheses and syntax in general...
This function is supposed to take a list and a position and return the list with that position removed--but I am getting an error that I don't fully understand. I have done some reading and it seems like its an issue with nested parentheses.. but I'm not sure how to fix it.
Any feedback would be greatly appreciated.
The error:
ClassCastException java.lang.Long cannot be cast to clojure.lang.IPersistentCollection clojure.core/conj (core.clj:83)
The code:
(defn delete-at
"accepts a list and position--returns the list with
value at that position removed"
(
[L, pos]
(cond
(empty? L) nil
(zero? pos) (rest L)
:else (
delete-at (first L) (rest L) (- pos 1))
)
)
([L-new, L2, pos]
(cond
(zero? pos) (conj L-new (rest L2))
:else (
(delete-at (conj L-new (first L2)) (rest L2) (- pos 1))
)
)
)
)