Skip to content

Instantly share code, notes, and snippets.

View aravinds03's full-sized avatar

Aravind Santhanam aravinds03

View GitHub Profile
@aravinds03
aravinds03 / insertion_sort.clj
Created March 11, 2012 05:09
Insertion sort in clojure
(defn max_first [coll]
"Function which returns collection with firt number beign maximum of entire collection"
(loop [collection (rest coll) minimum (seq [(first coll)])]
(if (empty? collection) minimum
(recur (rest collection)
(if (> (first collection) (first minimum))
(cons (first collection) minimum)
;since first argument of cons is number,I need to split 'minimum' into two subsequences.
(cons (first minimum) (cons (first collection) (rest minimum))))))))