Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Mon, Oct 19, 2009 at 12:39 AM, Gorsal wrote: > > So now that the future is working, I'm attempting to print from an > actual java thread. Like this > > (defmacro with-thread [nm & body] > `(let [thread# (Thread. #(fn [] (do ~...@body)))] > ~@(if nm `((.setName thread# ~nm))) > (.start

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Thanks. I think now that i recall i have made that mistake before. I must differentiate - fn and #()! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: deftest metadata

2009-10-18 Thread Phil Hagelberg
Phil Hagelberg writes: > Would it be a good idea to change deftest so that it accepts an optional > metadata map just like defn? I can implement it if it's wanted. Here's the ticket and patch: https://www.assembla.com/spaces/clojure/tickets/201-Make-deftest-keep-var-metadata I ran into a very

Re: Using 'future' ?

2009-10-18 Thread Adrian Cuthbertson
Just an addendum to my last post - without the .start you can test it better; (defmacro with-thread [nm & body] `(let [thread# (Thread. (fn [] (do ~...@body)))] (if ~nm (.setName thread# ~nm)) ;(.start thread#) thread#)) (def th (with-thread "foo" (println "Hasdfasdfasdfasdfasdfasdf

Re: Printing to *out* in another thread

2009-10-18 Thread Alex Osborne
mbrodersen wrote: >> 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. Looking in clojure/lang/Atom.java:

college courses

2009-10-18 Thread cej38
Does anyone know of any college courses that are using Clojure? For example, instead of LISP in an AI course? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: Using 'future' ?

2009-10-18 Thread Adrian Cuthbertson
The following seems to do it; (defmacro with-thread [nm & body] `(let [thread# (Thread. (fn [] (do ~...@body)))] (if ~nm (.setName thread# ~nm)) (.start thread#) thread#)) (with-thread "foo" (println "HasdfasdfasdfasdfasdfasdfasdfasdfI")) # user=> HasdfasdfasdfasdfasdfasdfasdfasdfI

Re: Using 'future' ?

2009-10-18 Thread Timothy Pratley
On Oct 19, 3:39 pm, Gorsal wrote: > Except no output! Eeek!!! What am i doing wrong? Looks like #(fn ... is meant to be #(do ~...@body) #(fn declares a function which creates a function, so your thread is returning a function instead of executing it. user=> (macroexpand-1 '(with-thread nil (pr

Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Sun, Oct 18, 2009 at 10:22 PM, Gorsal wrote: > > Hey, is there any way to separate the out view from the repl view so i > don't have to switch back and forth? > In Enclojure? Unfortunately, apparently not. It's possible to undock the REPL and make it a free-floating window, but all three of th

Re: Printing to *out* in another thread

2009-10-18 Thread mbrodersen
> 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

Re: Printing to *out* in another thread

2009-10-18 Thread mbrodersen
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

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-18 Thread mbrodersen
> 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. --~--~-~--~~~---~--

Re: Using 'future' ?

2009-10-18 Thread Gorsal
So now that the future is working, I'm attempting to print from an actual java thread. Like this (defmacro with-thread [nm & body] `(let [thread# (Thread. #(fn [] (do ~...@body)))] ~@(if nm `((.setName thread# ~nm))) (.start thread#) thread#)) (with-thread nil (println "Hasdfasd

Re: Clojure Cheat Sheet

2009-10-18 Thread Gorsal
lo, never looked at the bottom. I shall do that next time! Thanks! --~--~-~--~~~---~--~~ 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

Re: Clojure Cheat Sheet

2009-10-18 Thread ngocdaothanh
The bottom of that page says: Original source (pdf, tex). So it is probably TeX. On Oct 19, 8:06 am, Gorsal wrote: > All right, so this is probably way off topic, but what software was > used to create the clojure cheat sheet?http://clojure.org/cheatsheet > I really like the format and would li

Re: deftest metadata

2009-10-18 Thread Stuart Halloway
+1, we'd use this immediately. > On Oct 19, 9:32 am, Phil Hagelberg wrote: >> It's a fairly common idiom in other languages to have your test suite >> broken up into unit tests and higher-level integration tests. >> >> I've implemented this for one of my projects using metadata on each >> test

Re: Using synchronized keyword

2009-10-18 Thread Alex Osborne
Gorsal wrote: > I was wondering how to used the java keyword synchronized in clojure? http://clojure.org/api#locking Java: synchronized(foo) { ... } Clojure: (locking foo ...) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Using synchronized keyword

2009-10-18 Thread Gorsal
I was wondering how to used the java keyword synchronized in clojure? --~--~-~--~~~---~--~~ 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

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Hey, is there any way to separate the out view from the repl view so i don't have to switch back and forth? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Dmitry Kakurin wrote: > I actually like your "tag them then group them" approach. > But what if the same record can have multiple tags? > E.g. :sales and :upgrades? > Hmmm. the first way that occurred to me is just make your tagging function return a set: (defn record-types [x] (disj #{(w

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Thanks, this works. --~--~-~--~~~---~--~~ 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

Re: Using 'future' ?

2009-10-18 Thread Timothy Pratley
> Most likely, though, it's an unfortunate effect of how futures print > themselves: > > user=> (future (* 3 4)) > # I agree - this is the cause, if you really wanted to do this at the REPL maybe you can get around it like this: user=> (do (future (* 3 4)) nil) nil --~--~-~--~~---

Re: deftest metadata

2009-10-18 Thread George Jahad
Seems like a good idea to be able to set metadata on test vars. I work on the project Phil mentions above, and it does come in handy for categorizing tests. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"

Re: deftest metadata

2009-10-18 Thread Timothy Pratley
On Oct 19, 9:32 am, Phil Hagelberg wrote: > It's a fairly common idiom in other languages to have your test suite > broken up into unit tests and higher-level integration tests. > > I've implemented this for one of my projects using metadata on each test > var. Unfortunately the current impleme

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Timothy Pratley
On Oct 19, 4:54 am, Alex Osborne wrote: > (reduce-by record-type >             (fn [count data] (+ count (units data))) >             0 (get-idata)) Wow - that is a really nice abstraction! Kind of leads to SQLalike queries: (defn select-count [grouper coll] (reduce-by grouper (fn [x _]

Re: La Clojure plugin for IntelliJ IDEA moved to Git

2009-10-18 Thread eyeris
Once I build the plugin with the latest clojure, can I use it to write code targeting 1.0? On Oct 17, 11:21 am, Ilya Sergey wrote: > Hi all. > > After the long silence we resume work on `La Clojure' plugin for IntelliJ > IDEA. It is still open-source and available now for IntelliJ IDEA 9 > Com

Re: ANN: Clojure live-repl

2009-10-18 Thread David Powell
> and I can attach, but if the process I attach to exits, I get a > never-ending stream of \xef \xbf \xbf characters: > > 75 73 65 72 3d 3e 20 ef bf bf ef bf bf ef bf bf |user=> > .| > 0010 ef bf bf ef bf bf ef bf bf ef bf bf ef bf bf ef > || > 0020

Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Sun, Oct 18, 2009 at 5:59 PM, Gorsal wrote: > > I'm attempting to use the function future to start something in > another thread. However, in the netbeans enclojure plugin, when i type > it into the repl, it becomes non-responsive. Is this just a bug in the > enclojure plugin or would this be

Re: La Clojure plugin for IntelliJ IDEA moved to Git

2009-10-18 Thread Wilson MacGyver
One thing I'd really like to see for the plugin is to support a way to "expand" macros. Sometimes it's hard to understand the macros. It would be great if from the IDE, you can "expand" the macro to the normal form. I don't think I've ever see this in any lisp IDE before. On Sun, Oct 18, 2009 at

Clojure Cheat Sheet

2009-10-18 Thread Gorsal
All right, so this is probably way off topic, but what software was used to create the clojure cheat sheet? http://clojure.org/cheatsheet I really like the format and would like to make one for my own utilities so that I can actually remember what general utility functions i have written! --~--~--

Re: La Clojure plugin for IntelliJ IDEA moved to Git

2009-10-18 Thread Mark Derricutt
Where should we raise tickets/issues for the plugin? One thing I'm really still missing with it is auto completion of aliased namespaces: (ns foo (:require foo.bar.test :as test)) (defn hello [] (test/do-something)) Having the completion of a) the test alias, and b) the contents of test ins

A-Star Search Implementation

2009-10-18 Thread Josh
Hi, To teach myself Clojure and A-Star search, I mocked up a quick demo program. I don't know if anyone else would be interested in seeing it, but it demos a few things, including calling Clojure from Java, building / running from a Maven environment, and of course A-Star. I'd appreciate any cri

Re: What do you use for asdf-like functionality?

2009-10-18 Thread Gorsal
Now that I think about it im guessing ant is used. Though if i don't want to compile the clojure files, i guess i might be able to use lancelet to simply define a series of loading? Perhaps... --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: What do you use for asdf-like functionality?

2009-10-18 Thread Richard Newman
> What i need is to load the package.clj file and for that to then load > all the other files in order based on dependency. See clojure.contrib.immigrate. It doesn't do dependency tracking, but it doesn't need to: each sub-package should require or use those it needs. --~--~-~--~

deftest metadata

2009-10-18 Thread Phil Hagelberg
It's a fairly common idiom in other languages to have your test suite broken up into unit tests and higher-level integration tests. I've implemented this for one of my projects using metadata on each test var. Unfortunately the current implementation of deftest does not provide a way to set meta

Using 'future' ?

2009-10-18 Thread Gorsal
I'm attempting to use the function future to start something in another thread. However, in the netbeans enclojure plugin, when i type it into the repl, it becomes non-responsive. Is this just a bug in the enclojure plugin or would this be normal? (future (let [input-stream (:input-stream *li

Re: La Clojure plugin for IntelliJ IDEA moved to Git

2009-10-18 Thread Ilya Sergey
Hi all. The repository git://git.jetbrains.org/idea/clojure-plugin.git must work now. Sorry for the inconvenience. Cheers! Ilya 2009/10/18 Kurman Karabukaev > > Hi Ilya, it is asking for password for > git.labs.intellij.net:idea/clojure-plugin URL. > > Kurman > > On Sat, Oct 17, 2009 at 12:19

Re: Contrib (1.0 compatible) succeeds (but fails :-)

2009-10-18 Thread Michael Wood
2009/10/18 Joubert Nel : > > Hi, > > When I try to build the 1.0 compatible branch of clojure.contrib using > Clojure 1.0 I get the following two FileNotFoundExceptions: > > 1) [java] java.io.FileNotFoundException: Could not locate clojure/ > stacktrace__init.class or clojure/stacktrace.clj on cla

What do you use for asdf-like functionality?

2009-10-18 Thread Gorsal
Coming from lisp, i am used to an asdf like functionality. Recently I have been reorganizing my code and placing all my general utilities under one package, utils. Under it i have a file for each time of utility, string, macro, etc. Then i have a package.clj file. Basically, I want the user to be

Re: ANN: Clojure live-repl

2009-10-18 Thread Gorsal
That's very slick. I'm going to use this:) --~--~-~--~~~---~--~~ 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 -

Re: ANN: Clojure live-repl

2009-10-18 Thread Michael Wood
2009/10/18 David Powell : > I just posted a project at . > > It uses the Java Attach API to let you connect a Clojure REPL to any running > Java or Clojure process, without them requiring any special startup. That's very cool :) > It probably requires a Sun 1

Re: Printing to *out* in another thread

2009-10-18 Thread Gorsal
Dang, you're ri ght, I didn't even notice. This is a nice feature, separating everything. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Contrib (1.0 compatible) succeeds (but fails :-)

2009-10-18 Thread Joubert Nel
Hi, When I try to build the 1.0 compatible branch of clojure.contrib using Clojure 1.0 I get the following two FileNotFoundExceptions: 1) [java] java.io.FileNotFoundException: Could not locate clojure/ stacktrace__init.class or clojure/stacktrace.clj on classpath: (jmx.clj:10) 2) [java] java.io.

Re: -> vs comp

2009-10-18 Thread Robert Fischer
The F# language does partial application through calling the function: if you don't supply enough arguments, they're partially applied. The |> syntax is for "backwards" (object-y) partial application: let f x y = ... let g = f 1 let h = 1 |> f The |> operator is built-in in F#, but in OCaml

Re: -> vs comp

2009-10-18 Thread Sean Devlin
I've been using & and p, respectively. On Oct 18, 2:21 pm, B Smith-Mannschott wrote: > On Sun, Oct 18, 2009 at 20:04, Stuart Halloway > > wrote: > > > I find the suite of ->, ->>, anonymous functions, partial, and comp > > sufficient for my needs, with each having its place. > > > My only grumb

Re: Discuss: Add a :let "special expression" to cond

2009-10-18 Thread Howard Lewis Ship
Seem to be hitting a problem. (defmacro cond "Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate any of the other tests or exprs. As a special case, a te

Re: ANN: Clojure live-repl

2009-10-18 Thread Alex Osborne
David Powell wrote: > It uses the Java Attach API to let you connect a Clojure REPL to any running > Java or Clojure process, without them requiring any special startup. Exceedingly cool! > It probably requires a Sun 1.6 JDK. And currently the startup script is a > batch file, so if anyone ca

Re: -> vs comp

2009-10-18 Thread B Smith-Mannschott
On Sun, Oct 18, 2009 at 20:04, Stuart Halloway wrote: > > I find the suite of ->, ->>, anonymous functions, partial, and comp > sufficient for my needs, with each having its place. > > My only grumble is that "partial" is a lot of characters. I would love > a one-character alternative, if it coul

Re: -> vs comp

2009-10-18 Thread Stuart Halloway
I find the suite of ->, ->>, anonymous functions, partial, and comp sufficient for my needs, with each having its place. My only grumble is that "partial" is a lot of characters. I would love a one-character alternative, if it could be reasonably intuitive. Stu > On Oct 16, 10:22 pm, Sean D

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Alex Osborne wrote: > If the three output lists themselves are too large, I'd just explicitly > sum your units with reduce: > > (reduce > (fn [counts data] > (let [type (record-type data)] > (assoc counts type (+ (units data) > (get counts type 0) >

ANN: Clojure live-repl

2009-10-18 Thread David Powell
Hi, I just posted a project at . It uses the Java Attach API to let you connect a Clojure REPL to any running Java or Clojure process, without them requiring any special startup. It probably requires a Sun 1.6 JDK. And currently the startup script is a ba

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Meikel Brandmeyer wrote: > Maybe you can do: > > (reduce (fn [[sales upgrades demo :as v] data] >(cond > (is-sales? data) [(conj sales data) upgrades demo] > (is-upgrade? data) [sales (conj upgrades data) demo] > (is-demo? data)[sales upgra

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-18 Thread pmf
On Oct 18, 6:27 am, mbrodersen wrote: > 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'

Re: difference between into & concat

2009-10-18 Thread Alex Osborne
DemAS wrote: > I'm just wondering if there is any difference between 'into' and > 'concat' ? There are actually more differences than similarities in my opinion. For starters, 'concat' can take more than 2 arguments: (concat [1 2] [3 4] [5 6]) => (1 2 3 4 5 6) 'into' returns whatever col

difference between into & concat

2009-10-18 Thread DemAS
Hi all, I'm just wondering if there is any difference between 'into' and 'concat' ? (def x (range 1 100 5)) (def y (range 1 100 10)) (concat x y) (into x y) I have found only one difference - the 'concat'-functon sorts resulted list. --~--~-~--~~~---~--~~ You rec

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Meikel Brandmeyer
Hi, Am 18.10.2009 um 09:48 schrieb Dmitry Kakurin: > Here is what I have right now: > (let [idata ... something ... >sales > (filter >#($ (% "Product Type Identifier") = "1" && > % "Vendor Identifier" = "01010012" >) >idata >

Re: Bug: -main function corrupts applet

2009-10-18 Thread Rich Hickey
On Oct 18, 5:47 am, Andreas Wenger wrote: > *push* > Can please anybody verify this bug? Should take only 3 minutes or so. A NullPointerException in sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel isn't enough to go on. This could be anyone's bug, just because you can change something in

Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Dmitry Kakurin
I need to run 3 separate filters on the same collection. Can I do this in a single pass thru collection (as opposed to 3 separate passes)? Basically I don't want to bind the head of 'idata' collection because it holds the whole thing in memory. Also collection itself is coming from a file. Here i

Re: JVM Language Summit talk on state, identity, time

2009-10-18 Thread Garth Sheldon-Coulson
Nice, thanks. On Sat, Oct 17, 2009 at 2:24 AM, Timothy Pratley wrote: > > The slides match this: > http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey > [good recording - one of the best I've come across, gives a very > persuasive reasoning of why Clojure 'has it right'] > > > On

Re: Bug: -main function corrupts applet

2009-10-18 Thread Andreas Wenger
*push* Can please anybody verify this bug? Should take only 3 minutes or so. --~--~-~--~~~---~--~~ 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

Re: Printing to *out* in another thread

2009-10-18 Thread John Harrop
On Sun, Oct 18, 2009 at 2:04 AM, Gorsal wrote: > > I just tried this on the eclipse clojure repl, it works. So i guess it > is an enclojure thing! (.println System/out "HI") also doesn't work on > the netbeans repl, but does on the enclojure. I'll ask on the > enclojure mailing group. Thanks for t

Re: Printing to *out* in another thread

2009-10-18 Thread Volkan YAZICI
On Sat, 17 Oct 2009, mbrodersen writes: > 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 (agen