Skip to content

Instantly share code, notes, and snippets.

; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
@pjstadig
pjstadig / calculate.clj
Created July 25, 2011 19:35 — forked from mjg123/calculate.clj
Why can't I recur here?
(defn calculate
"A list of coin-values from coins, which sum to target"
[coins target acc]
(let [coin (max-coin coins target)]
(recur coins
(- target coin)
(cond
(not coin) (js-alert "No solution")
(= coin target) (list coin)
(< coin target) (cons coin acc))))
-module(test_helper).
-export([riak_test/1]).
riak_test(Fun) ->
start_riak(),
{ok, Riak} = riak:local_client(),
Ret = (catch Fun(Riak)),
stop_riak(),
case Ret of
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
(defn domap [f & colls]
(let [num-colls (count colls)]
(doseq [args (partition num-colls (apply interleave colls))]
(apply f args))))
(domap println [1 2])
(domap println [1 2] [3 4])
(domap println [1 2] [3 4] [5 6])
(defn when-its-one []
(loop []
(if (= 1 (rand-int 2000))
1
(do
(println "foo")
(recur)))))