This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn atom? [x] | |
(not (list? x))) | |
(def car first) | |
(def cdr next) | |
(def add1 inc) | |
(def sub1 dec) | |
(defn lat? [lst] | |
(every? atom? lst)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'couchbase' | |
def transfer(source, destination, amount) | |
cb = Couchbase.bucket | |
# prepare transaction document | |
id = cb.incr("transaction:counter", :create => true) | |
trans_id = "transaction:#{id}" | |
cb.set(trans_id, {"source" => source, "destination" => destination, |