@Michael,
There is already a monitor mechanism available in Clojure via the
'locking' macro or more primitive monitor-enter, monitor-exit. So in
your case all you have to implement is the blocking behavior, I'm not
sure if it can be already done somehow using just Clojure elements.
The above code
I saw a post about this from June 2009 or thereabouts, but it did not
get much follow-up. I'm curious about AI libraries for Clojure,
partly since I imagine some Lisp AI code could be translated to
Clojure fairly easily. I am doing some work on using Clojure with
applications including some AI-in
Excellent! This is exactly what I'm looking for; thanks everyone for
their help.
On May 13, 10:13 pm, Justin Kramer wrote:
> clojure.contrib.string/partition does exactly what you're looking for.
>
> (require 'clojure.contrib.string)
> (clojure.contrib.string/partition #"\s+" "ab c de")
> ;; ("a
Hi,
On Fri, May 14, 2010 at 01:47:00PM -0700, ka wrote:
> Isn't ensure necessary? Because http://clojure.org/refs says that -
> "No changes will have been made by any other transactions to any Refs
> that have been ref-set/altered/ensured by this transaction." It
> doesn't guarantee that a ref
> You can get rid of the I/O in the transaction and still see a consistent
> snapshot by simply return the contents of the refs.
>
> (defn report-status
> []
> (apply println (dosync [...@my-hash @new-keys])))
>
> Sincerely
> Meikel
>
> --
Isn't ensure necessary? Because http://clojure.org/re
Thanks for help. I have just used synchronization mechanizm from Java.
Here is a code:
monitor.clj
(ns michael.ds.monitor
(:import [java.util.concurrent.locks ReentrantLock Condition ]))
(defn create-monitor[]
(ReentrantLock.))
(defn create-cond[m]
(.newCondition m
The problem with STM is that it adds significant overheads to modification
costs. In a "classic" imperative programming language like Java or C#,
stores to variables compile down to simple memory writes- very cheap. An
STM memory write, by contrast, is 10x or 100x more expensive (depending upon
p
Hi,
On Fri, May 14, 2010 at 10:59:34AM -0700, ka wrote:
> (defn report-status []
> (dosync
> (ensure my-hash)
> (ensure new-keys)
> (println @my-hash)
> (println @new-keys)
> ))
You can get rid of the I/O in the transaction and still see a consistent
snapshot by simply ret
Few notes -
1. report status is not particularly good as it has io in a dosync.
2. Spelling of consume fn.
3. The consumers are not at all fair as they always take the first of
the set.
Please let me know if anyone sees some issues with the above code or
how to make it better.
On May 14, 10:59 pm
If add-watch is not what you want because you want the consumers to
have a life of their own, then does something like this work? -
(def my-hash (ref {}))
(def new-keys (ref #{}))
(defn produce []
(let [new-key (rand-int 10)
new-val "P"]
(Thread/sleep 100)
(dosync
(alter
Hi people!
A 2008 paper, I just received today via twitter
*Software transactional memory**: why is it only a research toy?*
http://portal.acm.org/citation.cfm?id=1400228&coll=ACM&dl=ACM&CFID=90273999&CFTOKEN=67127907&ret=1#Fulltext
Angel "Java" Lopez
http://www.ajlopez.com
http://twitter.com/aj
sweet.
needs parenthesis match hilighting, tho ;-)
--
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 posts from new members are moderated - please be patient with your
first post.
Not directly related to Clojure but I thought this would be of interest to
folks:
http://www.infoq.com/news/2010/05/STM-Dropped
http://www.reddit.com/r/programming/comments/c4367/microsofts_experiments_with_software/
--
You received this message because you are subscribed to the Google
Groups "C
On 14 May 2010 13:50, Stuart Halloway wrote:
>> So if program runs from a particular directory and references files as
>> file:///some/file, then if someone can create a directory called file:
>> in that directory with some/file inside that, the program will
>> suddenly try to access the wrong thi
Ooo -- postwalk-replace, which I didn't know about, is much better than what I
was going to suggest! But since this still might be of some interest to the OP
here is the message I had composed before ajuc's message came through:
---
Setq doesn't do that in Lisp, but subst does.
I've defined su
Setq isn't functional - equivalent in clojure would be def, but it
isn't meant to be used in that way.
For your purpose there is better fit: postwalk-replace
http://richhickey.github.com/clojure/clojure.walk-api.html#clojure.walk/postwalk-replace
Greetings.
--
You received this message because
Hi all,
I'm new to this language and is working on a few problems on my own.
I have this deep list, (of arbitrary depth, because I am trying to
work out a genetic program..) and I want to change, say, all x's in
this list. Replace doesn't work. Do I really have to define a
recursive function to "
As a newbie, this is the biggest frustration i have with clojure.
Coming from a scheme background i regularly type
(defn (func a b v) .. )
That produces a completely non-specific and non-locatable error message.
I occasionally resort to cutting my files in halves until i locate the
offending li
Pretty cool. Been waiting for this. My main criticism is that it isn't very
pretty :) Is there a github repo for it so people can fork it and play
around with CSS? Also how difficult would it be to build a tutorial for it
like the ones that http://tryhaskell.org and http://tryruby.org have? Would
b
So if program runs from a particular directory and references files as
file:///some/file, then if someone can create a directory called file:
in that directory with some/file inside that, the program will
suddenly try to access the wrong thing? Seems suspicious to me.
Two points:
(1) This is n
> I think def should support docstrings, as ^{:doc "foo"} is 8
> characters longer then "foo" - not to mention consistency across
> definers as well as readability.
I agree that there should be consistency across definers and that the
default def should be the best. Removes unnecessary complexity
On May 13, 2010, at 9:11 , Michael Wood wrote:
> By the way, I don't get StackOverflowErrors when I expect to. e.g.:
>
> ((fn blah [] (+ 1 (blah
>
> just sits there, apparently doing nothing.
On May 13, 2010, at 10:10 , Wilson MacGyver wrote:
> Great work, but the tryhaskell link is wr
Hi,
On Thu, May 13, 2010 at 09:17:54PM -0700, MarkSwanson wrote:
> If there are problems, just switch buffers, edit, \ef, switch back to
> the REPL and call (higher-up 12) again. rinse, repeat...
Just some gotchas:
* With \ef the file buffer will be evaluated. That means the line
numbers are
2010/5/14 Michael Wood :
> On 14 May 2010 04:32, Stuart Halloway wrote:
>>> On 13 May 2010 03:02, Stuart Halloway wrote:
>
> * Decidedly, I have bad feelings when I read about the "magic" of
> "coercing" a String first as a URL, and if not possible, fall back and
> consider it a
24 matches
Mail list logo