Hi,
I wrote this code to redirect a repl to a JFrame.
I used the JConsole class from Beanshell
(def console (bsh.util.JConsole.))
(def frame (doto (javax.swing.JFrame.) (.add console) (.setSize 500
500) (.setVisible true) ))
(binding [*out* (java.io.OutputStreamWriter. (.getOut console))]
You could just write this yourself.
It's easier than it looks.
First start with an evaluator for rpn (reverse polish notation) expressions.
"x + sin(y)" in rpn would be "y sin x +".
First you split that string and make it into a list.
Then you can evaluate that with a few lines of code using a stac
Here is some example code
http://pastebin.com/HG2bWWms
This allows you to evaluate infix or rpn expressions. It also demonstrates
the use of eval to turn the expression into a clojure function which should
give more performance.
It is very simple though, so all the elements in the expressions hav
I was wondering what's a good way to use OO concepts in clojure. Just
using multimethods and maps? Or maybe protocols?
Let's say I write a program that deals with many graphical elements
e.g. a game or a vector graphic editor.
I could represent each graphic/sprite/shape etc. as a map and define
mul
Hi,
I tried experimenting with lazy sequences and wrote this program
(def nums (cons 2 (lazy-seq (map inc nums
(def primes (cons (first nums)
(lazy-seq (->>
(rest nums)
(remove
(fn [x]
(let [dividors (take-whil
Thank you all for explaining this to me but I still don't understand
clojures behavior in this case,
Try running this code:
(def nums (drop 2 (range)))
(def primes (cons (first nums)
(lazy-seq (->>
(rest nums)
(remove
(fn [x]
Hi,
I was wondering if there are any good examples that show what
advantages clojure/lisp has over most other programming languages.
I mean a piece of code that couldn't be easily translated into e.g.
scala or java. A program that would take much longer to develop in
other languages due to the uniq