Skip to content

Instantly share code, notes, and snippets.

@simongray
Created September 12, 2018 19:24
Show Gist options
  • Save simongray/6fd9717026b644db7030b2986ddbf5a5 to your computer and use it in GitHub Desktop.
Save simongray/6fd9717026b644db7030b2986ddbf5a5 to your computer and use it in GitHub Desktop.
(defn enumerated
[xs]
(apply str (concat (interleave (drop-last 2 xs) (repeat ", "))
(interpose " og " (take-last 2 xs)))))
(do
(println (enumerated ["a"]))
(println (enumerated ["a" "b"]))
(println (enumerated ["a" "b" "c"]))
(println (enumerated ["a" "b" "c" "d"])))
@simongray
Copy link
Author

a
a og b
a, b og c
a, b, c og d

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