Observing namespace changes

2009-01-14 Thread lpetit
Hello, Is it possible for my code to "subscribe" to events of type "namespace change" which would inform of deltas on top level namespaces : - added symbol - removed symbol - changed root var binding of a symbol Indeed, I'm currently implementing a little "namespace browser" View for clojuredev

*1 *2 isn't working properly

2009-01-14 Thread HB
Hey, I'm trying to run my first Clojure example user=> (defn hello [name] (str "Cool! " name)) #'user/hello user=> (hello "Google") "Cool! Google" user=> (hello "Wicket") "Cool! Wicket" user=> (str *1) "Cool! Wicket" user=> (str *2) "Cool! Wicket" Isn't (str *2) supposed to return "Cool! Google"

Re: *1 *2 isn't working properly

2009-01-14 Thread Stephen C. Gilardi
By the time you evaluated *2, the second most recent result was what it showed you. All top level evaluations count. In short, you were Heisenberged. --Steve On Jan 14, 2009, at 3:59 AM, HB wrote: > > Hey, > I'm trying to run my first Clojure example > > user=> (defn hello [name] (str "Cool

Re: *1 *2 isn't working properly

2009-01-14 Thread Brian Doyle
Here's an example of *1 *2 *3 1:1 user=> (str "gavin") "gavin" 1:2 user=> (str "teri") "teri" 1:3 user=> (str "brian") "brian" 1:4 user=> (str-join " " [*1 *2 *3]) "brian teri gavin" On Wed, Jan 14, 2009 at 2:29 AM, Stephen C. Gilardi wrote: > > By the time you evaluated *2, the second most rec

Re: *1 *2 isn't working properly

2009-01-14 Thread HB
I didn't get you, would you please hold my hand and walking me as you explain line by line what is happening in my code? On Jan 14, 11:29 am, "Stephen C. Gilardi" wrote: > By the time you evaluated *2, the second most recent result was what   > it showed you. All top level evaluations count. > >

question about understanding/exploring agents

2009-01-14 Thread bOR_
Hi all. I am trying to figure out what the effect of the agent-function is on the efficiency of concurrency. Here is something I do not really understand. I've a fibonacci function and a simple multiplication, both are wrapped in their respective dotimes 100k loop. However, on this 4core machine

Re: Learning Clojure WikiBook

2009-01-14 Thread Rock
On Jan 13, 11:35 am, Rock wrote: > I've added some info regarding the backquote expansion mechanism in > the Reader section here: > > http://en.wikibooks.org/wiki/Learning_Clojure#The_Reader > > I tried to answer the author's question regarding the possible > expansion order in nested backquote

Re: *1 *2 isn't working properly

2009-01-14 Thread Martin Wood-Mitrovski
On Wed, 14 Jan 2009 02:47:23 -0800 (PST) HB wrote: > > I didn't get you, would you please hold my hand and walking me as you > explain line by line what is happening in my code? the simple way to work it out is to count up from where you are running the code, so if you use *2, count up to see

Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Paul Drummond
Hi all, I realised today that my "work" machine still has the old Sourceforge version of clojure-contrib but when I try to get the latest version from google-code it falls over - most likely due to a proxy: >svn checkout http://clojure-contrib.googlecode.com/svn/trunk/clojure-contrib svn: REPORT

Re: *1 *2 isn't working properly

2009-01-14 Thread HB
Lets say that the result of each method invocation will be saved in a stack. The stack now contains, Google and Wicket When I run (str *1) , I will get the last item in the stack which it is "Wicket" and the result of the method invocation iteself (which it is also "Wicket") will be pushed into th

Re: *1 *2 isn't working properly

2009-01-14 Thread Martin Wood-Mitrovski
On Wed, 14 Jan 2009 04:15:18 -0800 (PST) HB wrote: > > Lets say that the result of each method invocation will be saved in a > stack. > The stack now contains, Google and Wicket > When I run (str *1) , I will get the last item in the stack which it > is "Wicket" and the result of the method inv

Re: detecting running as script

2009-01-14 Thread Grunde
Hi all, I managed to make this work by first making a clj script as instructed here: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started (thanks, great stuff!) But there is still one small thing: Is there an elegant way to "unwrap" the passed command line arguments? And is there any

Re: *1 *2 isn't working properly

2009-01-14 Thread e
is that just for fun or can it be used in programs? HB, how'd you even learn about that so fast? do I suck at reading? On Wed, Jan 14, 2009 at 7:20 AM, Martin Wood-Mitrovski wrote: > > On Wed, 14 Jan 2009 04:15:18 -0800 (PST) > HB wrote: > > > > > Lets say that the result of each method invoca

Re: *1 *2 isn't working properly

2009-01-14 Thread HB
>> is that just for fun or can it be used in programs? Consider it a shenanigan :) >> HB, how'd you even learn about that so fast? do I suck at reading? I'm reading the beta version of "Programming Clojure" ; Am I doing fine Stu? :D On Jan 14, 2:31 pm, e wrote: > is that just for fun or can it

Re: detecting running as script

2009-01-14 Thread Grunde
Hi folks, I'm almost there. My small script: -- #! /usr/bin/env clj (defn somefunc [& args] (println "somefunc!" args)) (defn main [& args] (somefunc args)) ; Only run the application automatically if run as a script, ; not if loaded in a REPL with load-file. (when *command-line-args*

Re: Patch: Arbitrary Symbols between ||

2009-01-14 Thread Rich Hickey
On Jan 13, 4:56 pm, "Robert Pfeiffer" wrote: > Hello everybody, > > this patch implements a pipe-delimited syntax for symbols. The Reader > parses |this symbol| and one symbol. Symbols containing clojure syntax > are printed in this form, so they can be printed and read in again. > > example: (

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Mark Feeney
I did the same thing after the switch. Then I read the directions more carefully: http://code.google.com/p/clojure-contrib/source/checkout. --- # Non-members may check out a read-only working copy anonymously over HTTP. svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ clojure- cont

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Paul Drummond
2009/1/14 Mark Feeney > > (no /clojure-contrib on the end of the URL now) > Thanks for your reply Mark but I don't get what you mean. Can you elaborate? You say "no /clojure-contrib on the end of the URL" but it's not on there anyway. The url is exactly as it is on the google-code checkout pa

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Mark Feeney
I was just referring to the svn command you posted in your original message: > svn checkout http://clojure-contrib.googlecode.com/svn/trunk/clojure-contrib What it should be is: svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ clojure- contrib (note the space at the end before clo

Re: Patch: Arbitrary Symbols between ||

2009-01-14 Thread Christian Vest Hansen
On Wed, Jan 14, 2009 at 1:59 PM, Rich Hickey wrote: > > I am interested in symbols with arbitrary names, > Why is this interesting? -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: IntelliJ Plugin

2009-01-14 Thread Peter Wolf
Hi Aria, Actually, I am just in the process of writing up the install instructions. Watch this space! aria42 wrote: > Did you ever get around to posting the notes on getting the IntelliJ > plugin to work? I sorely would love IDE support for Clojure in either > Eclipse or IntelliJ. Is the Inte

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Rich Hickey
On Jan 14, 8:44 am, Mark Feeney wrote: > I was just referring to the svn command you posted in your original > message: > > > svn checkouthttp://clojure-contrib.googlecode.com/svn/trunk/clojure-contrib > > What it should be is: > > svn checkouthttp://clojure-contrib.googlecode.com/svn/trunk/clo

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Paul Drummond
2009/1/14 Rich Hickey > I think the salient difference is http, not https, for non-members. Hi Rich, The point is that I could use https on Sourceforge to get around the proxy issue. I've had the same problem before when using SVN for Clojure (sourceforge) and assembla (a personal repos). W

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Paul Drummond
2009/1/14 Mark Feeney > > I was just referring to the svn command you posted in your original > message: > > > svn checkout > http://clojure-contrib.googlecode.com/svn/trunk/clojure-contrib > > What it should be is: > > svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ clojure- > con

Re: when performance matters

2009-01-14 Thread Rich Hickey
For those interested in numeric performance, Clojure lets you use arrays of primitives, has primitive math support, primitive local support, and has higher-level macros for dealing with them (amap, areduce) which can also serve as models for your own. You can also use :inline to wrap arithmetic pr

How To Load Source File

2009-01-14 Thread Onorio Catenacci
Hi all, I'm new to Clojure and new to Lisp but not new to software development. And I feel very dumb for having to ask what seems like a very noob question but I can't seem to figure this out. If I want to load a source file into REPL it seems that I should be able to do this: (load-file "file

Re: How To Load Source File

2009-01-14 Thread Tom Ayerst
This works for me in every configuration I could think of (at worst I get java.io.FileNotFoundException). Are you running a plain cmd prompt? (not MSys or cygwin) How did you launch clj? Rgds. Tom 2009/1/14 Onorio Catenacci > > Hi all, > > I'm new to Clojure and new to Lisp but not new to

Re: when performance matters

2009-01-14 Thread Peter Wolf
Rich, I must apologize-- I worded my question *far* too harshly. I knew it as I pushed the send button. I am a huge fan of Clojure, and plan to use it as often as possible. My question was really looking for hints, so that I can use it in more places. You gave me a great one, thanks! Is th

Re: IntelliJ Plugin

2009-01-14 Thread HB
I'm an IntelliJ 8 user and I can test the plugin on my own machine if this helps the plugin's development. On Jan 14, 3:52 pm, Peter Wolf wrote: > Hi Aria, > > Actually, I am just in the process of writing up the install > instructions.  Watch this space! > > aria42 wrote: > > Did you ever get a

Trying to define next-agent function

2009-01-14 Thread Justin Johnson
Hello, I'm trying to create a list of agents and a function called next-agent that always gives me the next agent and restarts at the beginning when the list is exhausted. For my purposes the agent is serving as a thread that will do some work. I don't much care about its value at this time. I'

Re: How To Load Source File

2009-01-14 Thread Onorio Catenacci
On Jan 14, 9:56 am, "Tom Ayerst" wrote: > This works for me in every configuration I could think of (at worst I get > java.io.FileNotFoundException). >   Are you running a plain cmd prompt? (not MSys or cygwin) >   How did you launch clj? > Hi Tom, Thanks for the response. I'm running Repl fro

Re: Trying to define next-agent function

2009-01-14 Thread Justin Johnson
I found my problem. I wasn't calling agents. I was doing this. => (defn next-agent [] (nth agents (next-counter))) and should have been doing this. => (defn next-agent [] (nth (agents) (next-counter))) Still, I would like feedback. Is there a cleaner way to do this? Thanks. Justin On Wed,

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Cosmin Stejerean
On Wed, Jan 14, 2009 at 8:16 AM, Paul Drummond wrote: > 2009/1/14 Rich Hickey > >> I think the salient difference is http, not https, for non-members. > > > Hi Rich, > > The point is that I could use https on Sourceforge to get around the proxy > issue. > > I've had the same problem before when

Re: How To Load Source File

2009-01-14 Thread Greg Harman
For more than just experimentation with one file, you might also want to look into lib packaging so that you can 'require' or 'use' rather than have to go down to the level of 'load' or 'load-file'. Quick summary, if your file has namespace "foo.bar" then package it in file / foo/bar.clj (relative

Re: Patch: Arbitrary Symbols between ||

2009-01-14 Thread Robert Pfeiffer
On 14 Jan., 13:59, Rich Hickey wrote: > [...] the toString in the patch is quite > inefficient. Because symbols are immutable, they could cache the printable representation in an extra field, but this would double the space occupied by them. > Second, it would be better not to replicate the lo

Re: typo near http://clojure.org/API#toc248

2009-01-14 Thread Chouser
On Mon, Jan 12, 2009 at 10:26 PM, .Bill Smith wrote: > > The gen-class documentation at http://clojure.org/API#toc248 has a > minor typo: the description of the :state keyword begins at the end of > the :factory paragraph instead of beginning a new paragraph. Not a > big deal but it makes the :s

Re: Can't get clojure or clojure.contrib via SVN over https

2009-01-14 Thread Paul Drummond
2009/1/14 Cosmin Stejerean > You could try moving to something like git and checking out the source code > from one of the unofficial mirrors, like http://*github*.com/kevinoneill/* > clojure* > Works perfectly - thanks! I considered trying git but didn't have a clue where to look for mirrors -

Re: How To Load Source File

2009-01-14 Thread Tom Ayerst
Glad to help. If you haven't found it yet the wiki is very helpful, especialyy: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started If you want to spend some money Stuart Halloway's book is excellent http://www.pragprog.com/titles/shcloj/programming-clojure Cheers Tom 2009/1/14 On

Re: Trying to define next-agent function

2009-01-14 Thread bOR_
Also a newbie wrestling with agents.. but perhaps you could do something with lazy-cons or cycle? An endless cycle of your agents: (def running true) (while running (doseq [a (cycle agents)] (send-off a somefunction)) On Jan 14, 4:48 pm, Justin Johnson wrote: > I found my problem.  I wasn

Re: Designing a Performance Vector Math library in Clojure.

2009-01-14 Thread Chouser
On Tue, Jan 13, 2009 at 5:54 PM, Timothy Pratley wrote: > > I'm not sure how to "cpu frequency set > to not change" or how significant that is on my results. I was afraid that was too vague a reference, sorry. My laptop usually slows down the CPU when its idle or nearly so. Specifically, the li

Re: when performance matters

2009-01-14 Thread Asbjørn Bjørnstad
On Jan 14, 12:20 pm, "Mark H." wrote: > I humbly propose that folks shouldn't complain about Clojure being > slow for their apps until they have at least one of the following: > > 1. A targeted benchmark for an important bottleneck in their > application, implemented in both Clojure and the cur

Re: Observing namespace changes

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 3:07 AM, lpetit wrote: > > Hello, > > Is it possible for my code to "subscribe" to events of type > "namespace change" which would inform of deltas on top level > namespaces : > - added symbol > - removed symbol > - changed root var binding of a symbol > > Indeed, I'm cur

newbie question!!

2009-01-14 Thread wubbie
Hi, Earlier Stuart Sierra replied as follows: Hi Patrick, Here's one way to do it: (defn new-person [name] (ref {:name name, :friends #{}})) (defn are-friends [a b] (dosync (commute a assoc :friends (conj (:friends @a) b)) (commute b assoc :friends (conj (:friends @b) a (def bi

Re: when performance matters

2009-01-14 Thread Greg Harman
Asbjxrn, One thing that leaps out to me performance-wise is the 3 nested loops (dotimes, dotimes, loop/recur). Whatever's inside the inner loop is getting run a lot of times! General advice about reducing loop depth and computation required inside the innermost loop aside... have you looked at cl

Re: Observing namespace changes

2009-01-14 Thread MikeM
There's no event mechanism to monitor namespace changes. I accomplish this by taking a snapshot before and after any possible namespace- changing execution, using ns-map. Not as efficient as an event callback, but I haven't had any performance issues (map lookups are plenty fast for me). You can

Re: newbie question!!

2009-01-14 Thread David Nolen
(:name @(first (:friends @bill))) You need to dereference before trying to access name. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroup

Re: Learning Clojure WikiBook

2009-01-14 Thread Rock
Here's an update on syntax-quote in the WikiBook (Reader Macro section): The most complicated reader macro is syntax-quote, denoted by ` (back- tick). When used on a symbol, syntax-quote is like quote but the symbol is resolved to its fully-qualified name: `meow; (quote cat/meow) ...assuming

Re: Learning Clojure WikiBook

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 6:07 AM, Rock wrote: > [snip] > > #^{:ack bar} foo ; (clojure/with-meta foo {:ack bar}) This is not correct, and a common misunderstanding. "#^ is not sugar for with-meta. It does not expand into a call to with- meta. They are not equivalent." http://groups.google.

Re: detecting running as script

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 5:58 AM, Grunde wrote: > > Now, it these some elegant way to parse and use the passed command > line arguments in my program? Is there any lib like Ruby/Pythons > optparse to assist parsing of command line arguments? There is clojure.contrib.command-line I don't know if

Re: newbie question!!

2009-01-14 Thread wubbie
Thanks David. -sun On Jan 14, 11:55 am, David Nolen wrote: > (:name @(first (:friends @bill))) > > You need to dereference before trying to access name. > > David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "C

Re: Learning Clojure WikiBook

2009-01-14 Thread Rock
On 14 Gen, 17:58, Chouser wrote: > On Wed, Jan 14, 2009 at 6:07 AM, Rock wrote: > > [snip] > > > #^{:ack bar} foo      ; (clojure/with-meta foo {:ack bar}) > > This is not correct, and a common misunderstanding. > > "#^ is not sugar for with-meta. It does not expand into a call to > with- meta

Is there any way to dereference %1 %2 etc?

2009-01-14 Thread wubbie
(map #(println %) [1 2 3 4]) prints 1 2 3 and 4 But what if the vector element is a hash with [ {:a 1 :b 11} {:a 2 :b 22} {:a 3 :b 33}]? can we dereference :a using %1, like (:a %1)? If not, any alternative? maybe destructuring or something? thanks -sun --~--~-~--~~~-

Re: How To Load Source File

2009-01-14 Thread Onorio Catenacci
On Jan 14, 10:50 am, Greg Harman wrote: > For more than just experimentation with one file, you might also want > to look into lib packaging so that you can 'require' or 'use' rather > than have to go down to the level of 'load' or 'load-file'. Quick > summary, if your file has namespace "foo.bar

Re: Delays and their efficiency

2009-01-14 Thread Michael Reid
On Tue, Jan 13, 2009 at 12:39 PM, samppi wrote: > > Recently, I asked how to make a function evaluate its arguments lazily > (http://groups.google.com/group/clojure/browse_thread/thread/ > cd01ef39c2b62530), and I was given a good solution: use Delay objects > (with the delay and force functions)

Re: Is there any way to dereference %1 %2 etc?

2009-01-14 Thread Stuart Halloway
It doesn't make sense to mix map and println. If you want side effects, use doseq instead of map: (doseq [{a :a} [ {:a 1 :b 11} {:a 2 :b 22} {:a 3 :b 33}]] (println a)) {:a 1, :b 11} {:a 2, :b 22} {:a 3, :b 33} If you don't want side effects, use str instead of println (you could also use id

Expanding args in (fn [& args]...) to actual args, not ArraySeq

2009-01-14 Thread Justin Johnson
Is there a way to have args expanded to the actual arguments, not an ArraySeq? I need the actual args to pass to a multimethod so it knows how to dispatch appropriately. Code similar to this (send-off (next-agent) (fn [v & args] (somefn args)) arg1 arg2 arg3) Give me an error like this. ... Ca

Re: Utilities for clojure.contrib?

2009-01-14 Thread Chouser
I also think it's unhelpful for codebases to stray further from the builtin functions than needed, because it makes that code harder to read as well. So I will consider each of these more carefully. My comments below are of course highly influence by my personal experiences using Clojure. I'm q

Re: Utilities for clojure.contrib?

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 12:11 AM, GS wrote: > > On Jan 13, 7:17 pm, "Nick Vogel" wrote: >> seq returns nil when a collection has no items. According to the >> documentation for empty?, empty? is the same as (not (seq coll)) so you >> should use seq for expressing the opposite of empty? > > Acco

Re: Parameterized query with clojure.contrib.sql

2009-01-14 Thread Greg Harman
Steve, Thanks much for your work. The new with-query-results seems to work quite well. Your timing is impeccable with this set of changes: I had just finished hacking out a (much uglier) version of update-values as well. (I'll switch over to using the clojure.contrib.sql versions now for a numbe

Re: Expanding args in (fn [& args]...) to actual args, not ArraySeq

2009-01-14 Thread Stuart Halloway
Hi Justin, Use apply: (send-off (next-agent) (fn [v & args] (apply somefn args)) arg1 arg2 arg3) Cheers, Stuart > Is there a way to have args expanded to the actual arguments, not an > ArraySeq? I need the actual args to pass to a multimethod so it > knows how to dispatch appropriately.

Re: Expanding args in (fn [& args]...) to actual args, not ArraySeq

2009-01-14 Thread Justin Johnson
Ah, that's right! Thank you. I'm having a hard time thinking functionally. On Wed, Jan 14, 2009 at 12:31 PM, Stuart Halloway wrote: > > Hi Justin, > > Use apply: > > (send-off (next-agent) (fn [v & args] (apply somefn args)) arg1 arg2 > arg3) > > Cheers, > Stuart > > > Is there a way to have a

Re: detecting running as script

2009-01-14 Thread Grunde Løvoll
Thanks! I'll have a look at clojure.contrib.command-line. I don't need anything super-powerfull, just something that make it easy to define and parse command line arguments in the "normal manner". Sorry about my previous double post :( Grunde On Wed, Jan 14, 2009 at 6:00 PM, Chouser wrote: >

Re: clojure.contrib.command-line patch: multiple option format

2009-01-14 Thread Chouser
On Tue, Jan 13, 2009 at 8:08 PM, Perry Trolard wrote: > > Hi Chouser & list, > > I like clojure.contrib.command-line -- thanks for it! -- but I wanted > to be able to specify multiple forms for an option, e.g. --help, -h, > -?, etc. Here (in the Files section) > > http://bit.ly/fIVH > > is a pa

Re: when performance matters

2009-01-14 Thread Mark H.
On Jan 14, 8:27 am, Asbjørn Bjørnstad wrote: > Anyway, here is a core part of the algorithm. It's a diffusion > step, this gets called 3 times and in total this takes up more than > one second of cpu time on my machine which makes framerates very > slow. If anyone got any improvements I'd be hap

Re: Observing namespace changes

2009-01-14 Thread lpetit
OK thank you both Chris & Mike for your answer. What I've done for the moment is similar to what Mike did: at any place where there is a chance for something to change namespaces, I reload a new snapshot (and I throw the old). Registering watchers for Vars seems very interesting, I'll investigat

Re: Delays and their efficiency

2009-01-14 Thread Rich Hickey
On Jan 13, 12:39 pm, samppi wrote: > Recently, I asked how to make a function evaluate its arguments lazily > (http://groups.google.com/group/clojure/browse_thread/thread/ > cd01ef39c2b62530), and I was given a good solution: use Delay objects > (with the delay and force functions). > > I wante

Re: when performance matters

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 11:27 AM, Asbjørn Bjørnstad wrote: > > Anyway, here is a core part of the algorithm. It's a diffusion > step, this gets called 3 times and in total this takes up more than > one second of cpu time on my machine which makes framerates very > slow. If anyone got any improve

Re: question about understanding/exploring agents

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 6:00 AM, bOR_ wrote: > > However, on this 4core machine, the fib behaves as I would expect when > I scale up the number of threads, while the multiplication barely > seems to benefit from the 4 cores. The only difference I see between > the two functions is that the fib is

Re: when performance matters

2009-01-14 Thread chris
For a completely different way of doing this, you could certainly use GPGPU programming to speed this up. This section: (aset diffused-grid c (float (/ (+ (aget grid c) (* a (+ (+ (aget diffused-gr

Re: when performance matters

2009-01-14 Thread Rich Hickey
On Jan 14, 11:27 am, Asbjørn Bjørnstad wrote: > On Jan 14, 12:20 pm, "Mark H." wrote: > > > > > I humbly propose that folks shouldn't complain about Clojure being > > slow for their apps until they have at least one of the following: > > > 1. A targeted benchmark for an important bottleneck i

Re: Utilities for clojure.contrib?

2009-01-14 Thread Michael Harrison (goodmike)
I agree with Chouser that an uncluttered library is a great virtue. I too have been turned off by CL in part because of the enormous number of subtly distinct built-in functions. I'm partial to Scheme, though, so maybe I'm best viewed as a fanatic on this point. :-) That said, it does seem pleasa

Re: update-values for clojure.contrib.sql

2009-01-14 Thread budu
Good, anyway it was only a relatively minor modification of insert- values function. I'm sending my contributor agreement today, hoping to contribute further in a near future. Thanks On Jan 14, 12:13 am, "Stephen C. Gilardi" wrote: > On Jan 11, 2009, at 10:42 AM, Stephen C. Gilardi wrote: > > >

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
On Jan 14, 10:10 am, Chouser wrote: > I also think it's unhelpful for codebases to stray further from the > builtin functions than needed, because it makes that code harder to > read as well.  So I will consider each of these more carefully. Thanks for your detailed response! To keep this manag

Re: clojure.contrib.command-line patch: multiple option format

2009-01-14 Thread Perry Trolard
Hi Chouser, Thanks for checking out the patch. > It's a good idea.  Any sane way to allow the single-letter variety to > be specified with a single leading dash, instead of a double-dash? Single or double dashes should work for both kinds of options (long- or short-style), based on your code. T

Re: Utilities for clojure.contrib?

2009-01-14 Thread GS
> > So, either: > > >  1. My experiment was wrong, and seq? is not a valid stand-in > >     for seq in the above code. > > Right on the first try!  :-) Well, that's something :) > user=> (seq-chunk 2 [1 2 3 4 5]) > ((1 2) (3 4) (5)) > user=> (seq?-chunk 2 [1 2 3 4 5]) > nil > > This is because a

Re: Clojure now running in production

2009-01-14 Thread budu
Congratulation, this is quite amazing to see Clojure mature so fast and already working in production system. Sorry but I need to get back at finding that damn bug in a 10 years old VB legacy application :-( On Jan 13, 10:38 am, Luc Prefontaine wrote: > Hi everyone, > > as of yesterday pm, Cloju

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
> Sigh, I wish the API docs were more helpful in this case. > > clojure.core/seq? > ([x]) > Return true if x implements ISeq > > It's asking a lot from me to know whether vectors implement ISeq. If you don't know, you can always just ask the language :) user> (ancestors (class [1 2 3])) #{cloju

Re: Utilities for clojure.contrib?

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 4:26 PM, Jason Wolfe wrote: > > user> (contains? (ancestors (class [1 2 3])) clojure.lang.ISeq) > false Also there's 'isa?': user=> (isa? (class [1 2 3]) clojure.lang.ISeq) false user=> (isa? (class (seq [1 2 3])) clojure.lang.ISeq) true And 'instance?': user=> (instan

Re: Delays and their efficiency

2009-01-14 Thread Rich Hickey
On Jan 14, 2:57 pm, Rich Hickey wrote: > On Jan 13, 12:39 pm, samppi wrote: > > > > > Recently, I asked how to make a function evaluate its arguments lazily > > (http://groups.google.com/group/clojure/browse_thread/thread/ > > cd01ef39c2b62530), and I was given a good solution: use Delay objec

Re: By Example - another Clojure introduction wiki page

2009-01-14 Thread Mark Volkmann
On Tue, Jan 13, 2009 at 8:12 PM, GS wrote: > > On Jan 14, 1:12 am, Timothy Pratley wrote: >> I've written small wiki article which dives right into the look and >> meaning of common Clojure constructs with examples. Personally I find >> I learn best by examples and when starting out they were ha

Re: Parameterized query with clojure.contrib.sql

2009-01-14 Thread Stephen C. Gilardi
On Jan 14, 2009, at 1:26 PM, Greg Harman wrote: Thanks much for your work. The new with-query-results seems to work quite well. You're quite welcome. I'm glad to hear it! Your timing is impeccable with this set of changes: I had just finished hacking out a (much uglier) version of update-va

Re: Parameterized query with clojure.contrib.sql

2009-01-14 Thread Greg Harman
You're my personal Santa Claus today! :-) Confirmed present and working for both insert and update, using a 2 field where clause. On Jan 14, 5:14 pm, "Stephen C. Gilardi" wrote: > I've added update-or-insert-values. I'd appreciate hearing how it   > works for you. --~--~-~--~~

Only 9 agent "send-off"s complete?

2009-01-14 Thread Justin Johnson
Will someone please help me understand what I'm doing wrong? The code below is *supposed* to do the following. 1) Checkout the top level directory of a Subversion repository with empty depth. 2) Update the project directories (the ones right under the root of the repository) with depth immediates

Re: Utilities for clojure.contrib?

2009-01-14 Thread Rich Hickey
On Jan 14, 5:02 pm, Chouser wrote: > On Wed, Jan 14, 2009 at 4:26 PM, Jason Wolfe wrote: > > > user> (contains? (ancestors (class [1 2 3])) clojure.lang.ISeq) > > false > > Also there's 'isa?': > > user=> (isa? (class [1 2 3]) clojure.lang.ISeq) > false > user=> (isa? (class (seq [1 2 3])) clo

Pre-Alpha of IntelliJ plugin for Clojure

2009-01-14 Thread Peter Wolf
Hey Randall, Justin, Aria, HB, and all other IntelliJ enthusiasts Pre-Alpha of IntelliJ plugin for the Clojure is open for testing... Plugin currently provides editing with syntax coloring, syntax error high-lighting, folding, and brace matching. Also provides run configuration for Clojure scr

Re: Only 9 agent "send-off"s complete?

2009-01-14 Thread Timothy Pratley
Your omission of (apply await agents) is allowing the program to terminate before all your created threads finish I think. If I might further comment, your threading model is not quite right to me... You've created 5 agents and then used them to 'send-off' as many threads as there are projects. I

Re: question about understanding/exploring agents

2009-01-14 Thread Timothy Pratley
Hi Chris > What exactly are you trying to measure? I think what Boris is expecting is that for 4 CPUs, running 1,2,3,4 equal work threads will take the same amount of time. This is true when he calls loopfib, but not true when he calls loopmult: threads: 1 "Elapsed time: 205.458949 msecs" "Ela

Re: when performance matters

2009-01-14 Thread Mark H.
On Jan 14, 12:29 pm, chris wrote: > For a completely different way of doing this, you could certainly use > GPGPU programming to speed this up. > ... > You want this for a game engine anyway; do it in opengl or directx > using shaders. I recommend OpenCL or CUDA instead for less pain ;-) (Well,

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
>>> user> (= '(1) [1]) >>> true >> >>> user> (= '() []) >>> false >> >> Hm. That does seem rather odd. > > Fixed - svn 1208. Oh, I always assumed this was intentional ... I guess I never tried switching the order of arguments. Well, that makes a bit more sense then :). --~--~-~

Multiple hashing functions? (+ bug in PersistentHashMap.java?)

2009-01-14 Thread Jason Wolfe
I've already posted here [1] and on the issue board [2] about hashing. In particular, .hashCode for seqs/colls break the Java contract that whenever (.equals x y), (= (.hashCode x) (.hashCode y)). (let x = [1] and y = (seq [1])). As I've mentioned earlier, I hope that eventually .hashCode and .

Re: Suggested functions for core: any? none?

2009-01-14 Thread rzeze...@gmail.com
On Jan 14, 12:01 am, GS wrote: > On Jan 14, 2:27 pm, "Mark Engelberg" wrote: > > > I also find the choice of some/not-any? as opposites to be hard to > > remember.  I'd rather it be some/not-some? or any/not-any? > > I think some and any? both have their place. > > (let [foo  (some prime? numseq

Re: when performance matters

2009-01-14 Thread Asbjørn Bjørnstad
On Jan 15, 3:38 am, "Mark H." wrote: > On Jan 14, 8:27 am, Asbjørn  Bjørnstad wrote: > > > Anyway, here is a core part of the algorithm. It's a diffusion > > step, this gets called 3 times and in total this takes up more than > > one second of cpu time on my machine which makes framerates very

Re: when performance matters

2009-01-14 Thread Asbjørn Bjørnstad
On Jan 15, 8:42 am, "Mark H." wrote: > On Jan 14, 12:29 pm, chris wrote: > > > For a completely different way of doing this, you could certainly use > > GPGPU programming to speed this up. > > ... > > You want this for a game engine anyway; do it in opengl or directx > > using shaders. > > I re

Re: when performance matters

2009-01-14 Thread rzeze...@gmail.com
On Jan 13, 8:04 am, Mark P wrote: > > A macro cannot depend on runtime information. A macro is a function   > > that is called at compile time, its argument is an expression (as   > > written by the programmer, or as returned by another macro), and its   > > result is a modified expression. There

Re: when performance matters

2009-01-14 Thread Asbjørn Bjørnstad
On Jan 15, 4:33 am, Rich Hickey wrote: > Try this (and make sure you are using -server): > > (defn diffuse [grid diff-ratio dt] >   (let [a (float (* dt diff-ratio grid-size grid-size)) >         a4-1 (float (+ 1 (* 4 a))) >         grid #^floats (deref grid) >         diffused-grid #^floats (ma

Re: Why aren't lists callable?

2009-01-14 Thread Ethan Herdrick
Makes sense, but (#{:a :b :c} :b) doesn't return 'true', it returns :b. So it's not really acting like an object to boolean mapping. Doesn't much matter, though. By the way, I'd like to see map-map in the core. -Ethan On Jan 12, 5:30 pm, Stuart Sierra wrote: > A set is, in a sense, a functio

Re: Utilities for clojure.contrib?

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 4:03 PM, Jason Wolfe wrote: > > To keep this manageable, I'll cut out the parts where I don't think > comments are needed. Good idea! >> > (defn concat-elts "Lazily concatenate elements of a seq of seqs." [s] >> > (when (seq s) (lazy-cat (first s) (concat-elts (rest s))

Re: Why aren't lists callable?

2009-01-14 Thread Chouser
On Wed, Jan 14, 2009 at 10:23 PM, Ethan Herdrick wrote: > > By the way, I'd like to see map-map in the core. If you're referring to Jason Wolfe's suggested function, I think you may be pretty satisfied with (into {} (map ...)) instead. --Chouser --~--~-~--~~~---~--~

Re: clojure.contrib.command-line patch: multiple option format

2009-01-14 Thread Perry Trolard
A thought: if you end up using the patch, I gave the 'justify' function an inappropriate name. It should be 'align' or 'align-cols' or some such. (No one in their right mind would justify text on the console!) Perry On Jan 14, 3:16 pm, Perry Trolard wrote: > Hi Chouser, > > Thanks for checking

test-is: set! *e

2009-01-14 Thread Allen Rohner
Here's a trivial patch that I've found useful. After catching an uncaught exception in a test, set! *e so you can examine the stack trace afterward. === --- src/clojure/contrib/test_is.clj (revision 314) +++ src/clojure/contrib/t

  1   2   >