R-nREPL is “an implementation of nREPL client and server for R“.
It lets them communicate with each other quite easily.
Via ess-help.
Tag: Clojure
Mímir is an experimental rule engine written in Clojure
It looks nice; details here.
Which power function is right for Clojure?
(ns power.examples)
(defn non-acc-pow [base exp]
(if (zero? exp)
1
(* base (non-acc-pow base (dec exp)))))
(defn acc-pow [base exp]
(letfn [(loop [base exp acc]
(if (zero? exp)
acc
(recur base (dec exp) (* base acc))))]
(loop base exp 1)))
(defn lazy-pow [base exp]
(letfn [(loop [cur]
(cons cur (lazy-seq (loop (* cur base)))))]
(nth (take exp (loop base)) (dec exp))))
(defn iter-pow [base exp]
(nth (take exp (iterate (partial * base) base)) (dec exp)))
(defn apply-pow [base exp]
(apply * (repeat exp base)))
(= 16
(non-acc-pow 2 4)
(acc-pow 2 4)
(lazy-pow 2 4)
(iter-pow 2 4)
(apply-pow 2 4))
Calling Java Under Cygwin
While trying to set up Clojure under Cygwin I found that doing mixed-mode between Cygwin and Java isn’t very happy due to the ‘;’ vs ‘:’ in the classpath.
This post (via this post) provided an obfuscated Ruby program to take care of that for you… thanks!
#!/bin/ruby
# Slightly obfuscated cygwin + windows java wrapper, automate cygpath
cpi = ARGV.index("-cp") + 1
cp = ARGV[cpi] if cpi
XBCP = "-Xbootclasspath/a:"
xbcpi = ARGV.index{|i|i=~/^#{XBCP}.*/}
xbcp = ARGV[xbcpi] if xbcpi
if cp or xbcpi
def convert_paths(paths)
paths = paths.gsub(':', ';').split(';')
paths.map{|p|`cygpath -aw #{p}`.strip}.join ';'
end
ARGV[cpi] = convert_paths(cp) if cp
ARGV[xbcpi] = XBCP + convert_paths(xbcp.sub(XBCP, '')) if xbcp
end
java = '/cygdrive/c/Program Files/Java/jdk1.6.0_18/bin/java'
cmd = .concat ARGV
def e(s); "\"#{s.strip.gsub('"','\"')}\""; end
exec(cmd.map{|a|e a}.join(' '))
ParEdit for Editing Lispy Languages
ParEdit (paredit.el) is a minor mode for performing structured editing of S-expression data. The typical example of this would be Lisp or Scheme source code.
ParEdit helps keep parentheses balanced and adds many keys for moving S-expressions and moving around in S-expressions.
That quote from EmacsWiki really undersells Paredit, though.
Paredit makes it virtually impossible to un-balance parentheses (aka round, square, and curly brackets).
This mode would be especially interesting for folks avoiding Lisp because of the nightmare of balancing parentheses is too much of an obstacle to overcome (in practice of course it really isn’t, even if you don’t use Paredit).
Funny Java Standards
Swing is the GUI standard for Java. Clojure is the awesomeness standard for Java.
(via Stuart)
Adding Clojure support to listings
Clojure's Approach to Identity and State
Here is an article about a “position paper of sorts that Rich Hickey has posted on Clojure’s Approach to Identity and State”. (via LtU)