Skip to content

Instantly share code, notes, and snippets.

@rasputnik
Created September 5, 2012 10:30
Show Gist options
  • Select an option

  • Save rasputnik/3634727 to your computer and use it in GitHub Desktop.

Select an option

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