Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn head-and-tail
[[x & xs]] ; Destructuring of the input container
{:head x ; `x` contains the first element
:tail xs}) ; `xs` contains the remaining elements
; Example call
(head-and-tail [1 2 3])
=> {:head 1, :tail (2 3)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment