SHARE
TWEET

Untitled

a guest Jan 12th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn lazy-qs [[pvt & rst]]               ; deconstruct array, first element is pivot
  2.   (when pvt                               ; if pivot is not nil
  3.     (let [smaller #(< % pvt)]             ; define helper function
  4.       (lazy-cat
  5.         (lazy-qs (filter smaller rst))    ; re-run fn with all elements smaller than pivot
  6.         [pivot]                           ; center of list is pivot
  7.         (lazy-qs (remove smaller rst)))))); re-run fn with all elements bigger than pivot
RAW Paste Data
Top