Skip to content

Instantly share code, notes, and snippets.

@defp
Created November 12, 2012 15:18
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 defp/4059925 to your computer and use it in GitHub Desktop.
Save defp/4059925 to your computer and use it in GitHub Desktop.
4clojure
(fn [seq]
(map-indexed (fn [id val] (vector val id)) seq))
#(loop [coll % cnt 0]
(if (empty? coll)
cnt
(recur (next coll) (inc cnt))))
;;http://www.4clojure.com/problem/38
(fn [& more]
(reduce (fn [a b] (if (> a b) a b )) 0 more)
)
(fn [n]
(reduce #(* %1 %2) n (drop 1 (range n)))
)
;; or
#(reduce * 1 (range 1 (inc %)))
@defp
Copy link
Author

defp commented Nov 12, 2012

;;http://www.4clojure.com/problem/38

(fn [& more](reduce %28fn [a b] %28if %28> a b%29 a b %29%29 0 more)
)

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