Hi
I am having fun learning Clojure but have a problem with the following
code. If you run the code with the ;OK removed then it works. If you
run the code with ;ERROR removed then it doesn't.
The code is my own implementation of splitting a string into
individual words (just a learning exercise
Yes that does indeed fix the problem :-)
Thanks Shawn!
Cheers
Morten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe fro
Hi
The following agent code works fine:
(defn html-write-cmd [out cmd]
(doseq [key (keys cmd)]
(.write out
(format "\"%s\" => \"%s\"" key (cmd key)
but if I change (keys cmd) to (sort (keys cmd)) then the following
runtime exception is trigger
Thanks Steve. The code is called by another function that handles the
agent state so no it is not called directly. Here is the additional
code (it is a simple Newbie web server learning project):
Here is how the web server is run:
(ws-run 3000 wh-handler)
The web server:
Hi,
I am new to Clojure and I am wondering if there is anything similar to
the following macro already built in:
(defmacro let-while
"Makes it easy to continue processing an expression as long as it is
true"
[[name expr] & forms]
`(loop []
(let [~name ~exp
Congratulations everybody.
Clojure is the answer.
On Oct 17, 3:12 am, Rich Hickey wrote:
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
I think I understand what you are trying to do John but it doesn't
have the same semantics though.
If you use the first definition, the following expression:
(let-while [x (if (> (rand) 0.2) "Yep!" nil)] (println x) (println
(str x
will work correctly (it will print "Yep!" and "Yep!Yep!" ze
> I don't think the multiple evaluation matters in this case, since it's
> the name parameter, which will in all sane cases be a simple symbol.
> gensyms are needed when multiple evaluation could cause side-effects
> or an expensive function to be computed multiple times, which is not
> the case h
That's a nice improvement Christophe. Exactly the kind of answer I was
looking for.
Thanks!
Morten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googleg
If you want to print to stdout from multiple threads without getting
the printing garbeled you can do something like the following (it also
logs all printed values):
(def wa-debug-agent)
(defn wa-debug-make []
(def wa-debug-agent (agent [])))
(defn wa-debug-print
"This makes it
It would be great to have while-let in contrib. Then I don't have to
maintain let-while myself :-)
Morten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@
Hi all,
Is there a way to ensure that only one dedicated thread is used for an
agent?
The same question was asked some time ago but I don't think it was
resolved.
My specific problem is that SWT throws an exception if I use different
threads to call it even though I am using an agent to avoid r
I don't know SWT well enough to answer that. I am new to the JVM
platform (after 20+ years of writing native C++ code).
However, the question is not SWT specific. There will be other cases
(for example OpenGL) where something like InvokeLater doesn't exist.
Cheers
Morten
--~--~-~--~
Hmmm...it works with the normal Clojure REPL. So it must be an Emacs
thingy.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that post
> SWT's equivalent to Swing's SwingUtilities.invokeLater is
> Display.asyncExec; the equivalent of SwingUtilities.invokeAndWait is
> Display.syncExec (all four take a Runnable as an argument).
Thanks pmf! That at least solves the immediate problem.
--~--~-~--~~~---~--
Using atoms is not a good idea. Unless you don't mind if the same
message is sometimes printed more than once. Atoms are implemented
using spin locks with automatic retry.
Cheers
Morten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
> Using atoms is not a good idea. Unless you don't mind if the same
> message is sometimes printed more than once. Atoms are implemented
> using spin locks with automatic retry.
Hmmm...unless add-watch => observer is called only once.
So I might be wrong :-)
Interesting. Anybody knows more abou
Good point about the thread pools.
I would have preferred to do it in a more platform neutral way but yep
that looks like a good solution :-)
Thanks Christophe!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Cloju
Currently (into) takes 2 parameters (destination and source)
(into [] [1 2]) => [1 2]
but not more than 2:
(into [] [1 2] [3 4]) => Wrong number of args...
It would be nice to have (into) work for more parameters:
(into [] [1 2] [3 4]) => [1 2 3 4]
--~--~-~--~~~--
Currently (into) takes 2 parameters (destination and source):
(into [] [1 2]) => [1 2]
but not more than 2:
(into [] [1 2] [3 4]) => Wrong number of args...
It would be nice to have (into) work for more parameters:
(into [] [1 2] [3 4] [5 6 7]) => [1 2 3 4 5 6 7]
--~--~-~--~~
A quick question about how closures work in Clojure.
In this simple recursive expression:
(def t (fn [x] (if (zero? x) 0 (+ x (t (dec x))
The fn special form is evaluated within a context where t is not yet
bound.
t is only bound AFTER fn has captured its environment.
In other words, the c
(using alter-var-root!) at any time. The Var
> remains the same but the contents of the Var are changed.
>
> Because of how Clojure is structured, the Var object need only be
> resolved from the symbol once (in the generated Java bytecode, the Var
> appears as a static final field).
Great answer Alex. Thanks!
Morten
On Nov 12, 12:34 am, Alex Osborne wrote:
> mbrodersen wrote:
> > In this simple recursive expression:
>
> > (def t (fn [x] (if (zero? x) 0 (+ x (t (dec x))
>
> > The fn special form is evaluated within a context where t is not yet
I use an internal DSL (Domain Specific Language) in Clojure to
generate C++ and C# code.
Cheers
Morten
On Nov 24, 10:00 am, Raoul Duke wrote:
> hi,
>
> i'd be interested to hear who has successfully used clojure in
> production. i know of some, as some folks have been vocal; any other
> interes
There is nothing "wrong" about objects in Clojure as long as the
objects are immutable.
Some people tend to think that "functional" is anti-"object oriented".
That is IMHO the wrong way to think. They complement each other. Why
limit the tools in your toolbox? F# (for example) shows how it can be
Cleaned it up a bit:
(defmacro ? [object value]
"Get an object value - same as object.value; in C# but immutable"
`(get ~object (keyword (str '~value
(defmacro ! [object method & args]
"Call an object method - same as object.method(args); in C# but
immutable"
`
abuse of macro, where regular functions would do the job very
> well ?
>
> 2009/12/13 mbrodersen
>
> > There is nothing "wrong" about objects in Clojure as long as the
> > objects are immutable.
>
> > Some people tend to think that "functional" i
Everything looks the same if you use a loose enough equality function
I guess.
Using a loose enough equality function, you can argue that Clojure is
just Lisp running on top of a mutable, Object Oriented framework (the
JVM). Immutable data structures and controlled changes of immutable
values is n
Paul Graham might be correct that main stream languages will
incorporate features that Lisp had many years ago but the result won't
be Lisp.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
29 matches
Mail list logo