Skip to content

Instantly share code, notes, and snippets.

@rasputnik
Created September 5, 2012 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasputnik/3634727 to your computer and use it in GitHub Desktop.
Save rasputnik/3634727 to your computer and use it in GitHub Desktop.
4clojure #23 : reversing a sequence
(defn widdershins [coll]
(letfn [(flip [tocoll fromcoll]
(if (empty? fromcoll)
tocoll
(flip (cons (first fromcoll) tocoll) (rest fromcoll))
)
)]
(flip [] coll)
)
)
; (widdershins [ 1 2 3] => (1 2 3)
; sigh.
; (into () %)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment