Original text from http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html
From: Mark Jason Dominus <[email protected]>
Date: Jul 28, 2005 11:16 PM
Subject: Re: HOP -vs- SICP
function curry(f) { | |
return function(x) { | |
var g = f.bind(this, x); | |
if(g.length == 0) return g(); | |
if(arguments.length > 1) return curry(g).apply(this, [].slice.call(arguments, 1)); | |
return curry(g); | |
}; | |
} | |
var sum = curry(function(x, y) { |
(defpallet | |
;; you can specify global data in the :environment key here | |
;; | |
:environment { | |
:algorithms | |
{:lift-fn pallet.core/parallel-lift | |
:converge-fn | |
pallet.core/parallel-adjust-node-counts}} | |
:admin-user | |
{:username "ubuntu" |
; Proper namespaces | |
(ns app-utils) | |
; JavaScript interop | |
(defn -alert [message] | |
(js/alert message)) | |
(defn -log [message] | |
(.log js/console message)) |
Vagrant::Config.run do |config| | |
config.vm.box = "omnios" | |
config.vm.box_url = "http://omnios.omniti.com/media/omnios-latest.box" | |
config.vm.provision :shell do |shell| | |
shell.inline = <<-EOH.gsub(/^ {6}/, '') | |
cp -R /opt/omni/lib/ruby/gems/1.9/* /opt/omni/lib/ruby/gems/1.9.1 | |
for ruby_binary in chef-client knife ohai shef erubis | |
do | |
ln -sf /opt/omni/lib/ruby/gems/1.9.1/bin/${ruby_binary} /opt/omni/bin/${ruby_binary} |
;; based on core.logic 0.8-alpha2 or core.logic master branch | |
(ns sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) |
(ns queries | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic]) | |
(:use [datomic.api :only [q]])) | |
(defn query [rule xs] | |
(let [prule (prep rule)] | |
(map #(binding-map* prule (prep %)) xs))) | |
;; --- |
Original text from http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html
From: Mark Jason Dominus <[email protected]>
Date: Jul 28, 2005 11:16 PM
Subject: Re: HOP -vs- SICP
(ns lucenalog.core | |
"Lucenalog = Datalog interface to Lucene in 10 lines. | |
Simple but powerful. | |
Use | |
(db/add (index) {:a \"foo\" :b \"bar\"}) | |
to index a map with Lucene. Then you can use the relation |
(use '[clojure.core.match :only [match]]) | |
(defn evaluate [env [sym x y]] | |
(match [sym] | |
['Number] x | |
['Add] (+ (evaluate env x) (evaluate env y)) | |
['Multiply] (* (evaluate env x) (evaluate env y)) | |
['Variable] (env x))) | |
(def environment {"a" 3, "b" 4, "c" 5}) |
#!/bin/bash -ex | |
# Paste this into ssh | |
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
# When forking, you can get the URL from the raw (<>) button. | |
### Set some command variables depending on whether we are root or not ### | |
# This assumes you use a debian derivate, replace with yum, pacman etc. | |
aptget='sudo apt-get' | |
chsh='sudo chsh' |