I know that I can destroy the vector "from the front" as follows:
(fn [[ab & rest]] (+ ab))
Is there a (short) way to access the last two elements instead ?
(fn [[rest & ab]] (+ ab)) ;;Not legal
My current alternative is
(fn [my-vector] (let [[ab] (take-last 2 my-vector)] (+ ab)))
and he was trying to figure out if there is a way to do this in a more convenient way directly in function arguments.
source share