Re: Calling static methods without reflection?

2009-02-10 Thread Jason Wolfe
Never mind, silly me. Of course, the identity of the method is not the issue, it's the type of the argument. user> (defn abs [x] (let [x (double x)] (Math/abs x))) #'user/abs ; no reflection warning. -Jason --~--~-~--~~~---~--~~ You received this message because

Calling static methods without reflection?

2009-02-10 Thread Jason Wolfe
I was profiling my app today, and noticed lots of time being spent in Reflector.invokeStaticMethod. The cause was some calls to Math/abs, which was surprising to me since clojure.org says "Note that type hints are not needed for static members (or their return values!) as the compiler always has

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Tom Faulhaber
So rather than choosing between a stack depth and scanning through noise, it might be better to just filter out the (obvious) noise. This includes stuff that's down in the runtime (for most apps) and stuff that is up above the test. Shane Celis used that approach in his unit_test library. I forke

Re: is mod correct?

2009-02-10 Thread Timothy Pratley
I would have expected the mult to be a performance hit, but my overly simple tests show it performing better: user=> (time (dotimes [i 100] (zero? (* 5 11 "Elapsed time: 183.358706 msecs" user=> (time (dotimes [i 100] (or (< 5 0 11) (< 11 0 5 "Elapsed time: 682.586025 msecs" In pr

Re: anonymous functions

2009-02-10 Thread Timothy Pratley
> #(do ...) behaves the same way. Ah yes nice... I noticed that (do) is documented in 'special forms' but not in the API, whereas (let) is documented in both. Should do appear in the API section for completeness? --~--~-~--~~~---~--~~ You received this message beca

Re: anonymous functions

2009-02-10 Thread Timothy Pratley
Just syntactical convenience I believe: #((+ 1 %1)) looks silly :) #(+ 1 %1) is nicer but more restrictive. Notably you can still do multiple things: user=> (#(let [] (println "hi") (+ 1 %1)) 1) hi 2 On Feb 11, 3:09 pm, Mark Volkmann wrote: > Just checking my understanding of the rules for wri

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Eric Lavigne
> > > Why can't I use ensure inside of a dosync block? Is there another way to >> perform a transaction? >> > > You can, but "map" is lazy. It's not being evaluated within the dosync. One > way to fix the code is to force map to evaluate within the dosync using > "dorun": > >(dosync (dorun

Re: is mod correct?

2009-02-10 Thread Mark Engelberg
I was the source of this error, and I agree that the behavior is an error. I missed the case of a negative divisor and a 0 remainder among my test cases for the mod function. Thanks for noticing and fixing the problem. Although Chouser's version is slightly more compact than Pratley's, I wonder

Re: anonymous functions

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 11:09 PM, Mark Volkmann wrote: Just checking my understanding of the rules for writing anonymous functions ... (fn [args] ...) allows any number of expressions in its body. #(...) only allows a single expression in its body, correct? Why the difference? Because a single

Re: anonymous functions

2009-02-10 Thread Kevin Downey
fn has an implicit (do ...) #(do ...) behaves the same way. #(a b c) expands to (fn [] (a b c)) if you put in multiple forms you get #((a b)(c d)) expands to (fn [] ((a b) (c d))) note the (a b) in the operator position. On Tue, Feb 10, 2009 at 8:09 PM, Mark Volkmann wrote: > > Just checking my

Re: anonymous functions

2009-02-10 Thread Jeffrey Straszheim
No. You can do #(+ %1 %2 %3 %4) I don't know the max, but if you fear you'll hit it use fn. You, however, cannot nest #() forms. On Tue, Feb 10, 2009 at 11:09 PM, Mark Volkmann wrote: > > Just checking my understanding of the rules for writing anonymous functions > ... > (fn [args] ...) allows

anonymous functions

2009-02-10 Thread Mark Volkmann
Just checking my understanding of the rules for writing anonymous functions ... (fn [args] ...) allows any number of expressions in its body. #(...) only allows a single expression in its body, correct? Why the difference? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~-

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
Glad I could help. Enjoy coding. On Tue, Feb 10, 2009 at 10:43 PM, Onorio Catenacci wrote: > > On Feb 10, 10:14 pm, Jeffrey Straszheim > wrote: > > This one is easy: > > > >(and this that the-other-thing) > > > > and is short-circuting, e.g. it returns nil/false on reaching the first > > ni

Re: Logical And

2009-02-10 Thread Rayne
I literally asked this same question yesterday in #Clojure. The answer is and user/ (doc and) - clojure.core/and ([] [x] [x & rest]) Macro Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and do

Re: Logical And

2009-02-10 Thread Onorio Catenacci
On Feb 10, 10:14 pm, Jeffrey Straszheim wrote: > This one is easy: > >    (and this that the-other-thing) > > and is short-circuting, e.g. it returns nil/false on reaching the first > nil/false element, or the value of the last element. > > I used it tonight like this: > >    (and x (inc x)) > >

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Jeffrey Straszheim
My pleasure. BTW, thanks for Clojure! On Tue, Feb 10, 2009 at 10:32 PM, Rich Hickey wrote: > > > > On Feb 10, 10:24 pm, Jeffrey Straszheim > wrote: > > Say hello to laziness. > > > > Your code is returning a lazy seq (from the map), which is evaluated by > the > > reader outside of the dosync.

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Rich Hickey
On Feb 10, 10:24 pm, Jeffrey Straszheim wrote: > Say hello to laziness. > > Your code is returning a lazy seq (from the map), which is evaluated by the > reader outside of the dosync. > > Now what I don't understand is why, when I run: > > (dosync (dorun (map ensure [account1]))) > > I get: >

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Jeffrey Straszheim
Since we're on the subject, what exactly does ensure *do* that simply reading the ref does not? And then, how does it differ from writing. On Tue, Feb 10, 2009 at 10:24 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > Say hello to laziness. > > Your code is returning a lazy seq (

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Jeffrey Straszheim
Say hello to laziness. Your code is returning a lazy seq (from the map), which is evaluated by the reader outside of the dosync. Now what I don't understand is why, when I run: (dosync (dorun (map ensure [account1]))) I get: java.lang.RuntimeException: java.lang.IllegalArgumentException:

Re: Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 10:01 PM, Eric Lavigne wrote: Why can't I use ensure inside of a dosync block? Is there another way to perform a transaction? You can, but "map" is lazy. It's not being evaluated within the dosync. One way to fix the code is to force map to evaluate within the dosync

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
Oh, and for your specific example, try: (and (= a something) (= b another-thing) (foo)) It will return false or (foo). On Tue, Feb 10, 2009 at 10:08 PM, Onorio Catenacci wrote: > > Hi all, > > Still working on learning Clojure. I think I know the answer to this > question (because I seem to

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
This one is easy: (and this that the-other-thing) and is short-circuting, e.g. it returns nil/false on reaching the first nil/false element, or the value of the last element. I used it tonight like this: (and x (inc x)) This returns x+1, unless x is nil, in which case it returns nil. Ma

Logical And

2009-02-10 Thread Onorio Catenacci
Hi all, Still working on learning Clojure. I think I know the answer to this question (because I seem to have gotten it working) but I wanted to confirm that this is the right way to do this. In C++ I'd write something like this: if (a == something && b == anotherthing) { foo(); } Am I cor

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Chas Emerick
On Feb 10, 2009, at 8:52 PM, Stuart Sierra wrote: > Ok, new behavior in SVN rev. 449: Full stack traces are printed by > default. Bind *stack-trace-depth* to an integer to limit the depth. That's great, Stuart, thank you very much. >> On Feb 10, 2:01 pm, Jeffrey Straszheim >> wrote: >> >>> I

Using ensure in dosync - IllegalStateException: No transaction running

2009-02-10 Thread Eric Lavigne
The way I understand it, "transaction running" means that the code is executing inside a dosync block. So this should work: (def account1 (ref 1000)) (def account2 (ref 2000)) (dosync (map ensure [account1 account2])) However, I get the following error: java.lang.IllegalStateException: No tra

Re: is mod correct?

2009-02-10 Thread Chouser
On Tue, Feb 10, 2009 at 9:37 PM, Timothy Pratley wrote: > > Great! > > (> (* num div) 0) > could be (pos? (* num div)) too I guess... but is sadly slightly > longer! But simpler and clearer. Thanks for the catch. --Chouser --~--~-~--~~~---~--~~ You received thi

Re: is mod correct?

2009-02-10 Thread Timothy Pratley
Great! (> (* num div) 0) could be (pos? (* num div)) too I guess... but is sadly slightly longer! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Re: is mod correct?

2009-02-10 Thread Chouser
On Tue, Feb 10, 2009 at 8:55 PM, Timothy Pratley wrote: > > In the code I posted the let evaluated rem before checking the > arguments. Thanks for doing all the hard work. :-) How about: (defn mod42 "Modulus of num and div. Truncates toward negative infinity." [num div] (if-not (and (integ

Re: A Clojure documentation browser

2009-02-10 Thread Giancarlo Angulo
nice, thanks! = ANGOL = -|-^...@^_^, =|+^_^X++~_~,@- "The only thing worse than a hopeless romantic is a hopeful one" Magbasa bago Mamuna. Mag-isip bago mambatikos Without Truth there is no Justice, Without Justice, there is Tyranny Semper fi Proof of Desire is Pursuit www

Re: is mod correct?

2009-02-10 Thread Timothy Pratley
In the code I posted the let evaluated rem before checking the arguments. It would be better arranged like so: (defn mod2 "Modulus of num and div. Truncates toward negative infinity." [num div] (if (or (not (integer? num)) (not (integer? div))) (throw (IllegalArgumentException. "mod req

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Stuart Sierra
Ok, new behavior in SVN rev. 449: Full stack traces are printed by default. Bind *stack-trace-depth* to an integer to limit the depth. -Stuart Sierra On Feb 10, 8:25 pm, Jason Wolfe wrote: > I agree that I'd like to (have an option to) see a whole stack trace, > or barring that, bind the mo

Re: is mod correct?

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 8:34 PM, Timothy Pratley wrote: I spoke too soon. Apparently from the Lisp HyperSpec mod performs the operation floor on number and divisor and returns the remainder of the floor operation. Which would indicate that mod1 is not consistent with LISP. Seeing Java doesn't have a

Re: stacktrace/print-cause-trace swallows exceptions

2009-02-10 Thread Stuart Sierra
Thanks, Chas. Fixed in SVN rev. 448. -Stuart Sierra On Feb 10, 4:36 pm, Chas Emerick wrote: > In the process of tracking down some failing test-is tests, I believe > I discovered that it (via stacktrace) swallows exceptions. > Specifically, when an error occurs, it uses stacktrace/print-cause- >

Re: Is it possible to have Eclipse build an executable .jar with Clojure-dev

2009-02-10 Thread Rayne
Do you mean, just exporting it as a normal .jar file, and not an executable jar file? In Netbeans, which is what I've been using before trying Clojure-dev, there was just a build button that would build an executable .jar with a lib folder for Clojure.jar and whatever else the project depended on.

Re: is mod correct?

2009-02-10 Thread Timothy Pratley
I spoke too soon. Apparently from the Lisp HyperSpec mod performs the operation floor on number and divisor and returns the remainder of the floor operation. Which would indicate that mod1 is not consistent with LISP. Seeing Java doesn't have a proper mod, it would seem sensible to follow the LISP

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Jason Wolfe
I agree that I'd like to (have an option to) see a whole stack trace, or barring that, bind the most recent exception to some var so I can look at it later (c.f. *e). The limited trace hindered my debugging just yesterday. On Feb 10, 2:01 pm, Jeffrey Straszheim wrote: > I've found that, in gene

Re: newbie question on compilation

2009-02-10 Thread Shawn Hoover
On Tue, Feb 10, 2009 at 11:32 AM, Tzach wrote: > > Thanks for the response > Yes, I'm using Emacs SLIM. > > what should be the relation between the file (hello.clj) path to the > classpath? > Is the compile work on the file name, or on the function? in other > word, should I evaluate the function

Re: newbie question on compilation

2009-02-10 Thread Shawn Hoover
On Tue, Feb 10, 2009 at 10:07 AM, Lennart Staflin wrote: > > > > On Feb 10, 2:45 pm, Tzach wrote: > > > I got "error in process filter: Wrong number of arguments: nil, 3". > > What am I missing here? > > Are you using Emacs with slime? > > Psychic debugging skills in action :) --~--~-~--

Re: Is it possible to have Eclipse build an executable .jar with Clojure-dev

2009-02-10 Thread Laurent PETIT
Hello, Normally not currently, or, if it works, it would be unintentional :-) More seriously : this indeed is not an officially supported feature. The long answer is : it depends on what you mean by "jar". Eclipse + clojuredev seems capable of producing a very correct jar with what you want : e

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
2009/2/11 Laurent PETIT > > > 2009/2/10 Stephen C. Gilardi > >> >> On Feb 10, 2009, at 12:32 PM, Greg Harman wrote: >> >> Let me offer a perspective coming from a Java background: >>> >>> I know that there are subtle differences between a namespace and a >>> Java package, but I still tend to su

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
2009/2/10 Stephen C. Gilardi > > On Feb 10, 2009, at 12:32 PM, Greg Harman wrote: > > Let me offer a perspective coming from a Java background: >> >> I know that there are subtle differences between a namespace and a >> Java package, but I still tend to subconsciously consider them >> analogous:

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Rich Hickey
On Feb 10, 7:15 pm, Laurent PETIT wrote: > Hello, > > 2009/2/10 Stephen C. Gilardi > > > > > > > On Feb 10, 2009, at 11:46 AM, Laurent PETIT wrote: > > > If I understand correctly your proposal, can you verify the following is > >> true : > > >> (ns foo.bar) > >> (ns foo.bar.util) > >> (ns fo

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
Hello, 2009/2/10 Stephen C. Gilardi > > On Feb 10, 2009, at 11:46 AM, Laurent PETIT wrote: > > If I understand correctly your proposal, can you verify the following is >> true : >> >> (ns foo.bar) >> (ns foo.bar.util) >> (ns foo.bar.impl) >> (ns foo.bar.data) >> >> with foo.bar decomposed in tw

Re: is mod correct?

2009-02-10 Thread Timothy Pratley
Interesting! Based upon http://mathforum.org/library/drmath/view/52343.html mod might be modified to look like this (defn mod1 "modulus of num and div." [num div] (cond (or (not (integer? num)) (not (integer? div))) (throw (IllegalArgumentException. "mod requires two int

Re: A Clojure documentation browser

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 12:02 PM, Craig Andera wrote: 4) To ask if there's anything else people would particularly like to see added/changed. On my list are to make each namespace collapsible in the same way the source is. I like it a lot. I think it would be very cool if such an HTML file cove

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread John D. Hume
On Tue, Feb 10, 2009 at 5:01 PM, Jeffrey Straszheim wrote: > I've found that, in general, the stack dumps you get back from Java (into > Clojure-land) are pretty unhelpful. That may be, but I think Chas's point is valid. Typically there are pointers to your own source files, but they're often mo

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Mark Fredrickson
> > Maybe _ is appropriate? > > => (let-> _ (+ 1 2) (* 2 _) (+ _ 1)) > 7 > => (let-> _ [1 2 3] (map inc _) (reduce + _) (+ _ 3)) > 12 > > Or maybe ? ? Don't forget the wide variety of unicode symbols you have at your disposal: user=> (let-> ★ 2 (+ ★ 3) (- 10 ★ ) (map #(* ★ %) [2 3 4])) (10 1

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Meikel Brandmeyer
Hi, Am 10.02.2009 um 23:34 schrieb Michael Reid: Maybe _ is appropriate? => (let-> _ (+ 1 2) (* 2 _) (+ _ 1)) 7 => (let-> _ [1 2 3] (map inc _) (reduce + _) (+ _ 3)) 12 Or maybe ? ? I would not use _. _ is often used as "don't care" variable name. And this is certainly not what we want here

Is it possible to have Eclipse build an executable .jar with Clojure-dev

2009-02-10 Thread Rayne
I'm not sure, I've never really used Eclipse that much, and I was wondering if it is possible. I can't see a way how, but maybe I'm missing something. Sorry if this isn't quite the right place to post this, but I couldn't find another place. Thanks -Rayne --~--~-~--~~~---

Re: Clojure + Slick - "stylistic" questions

2009-02-10 Thread Timothy Pratley
Hi PH, > "Returns a map of the elements of col to the evaluation of function (zipmap keys (map fun keys)) http://groups.google.com/group/clojure/browse_thread/thread/8fe99ca560c4515/9721d59987207241?lnk=gst&q=zipmap#9721d59987207241 If you are following Matt's suggestion of a sorted map thoug

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Michael Reid
On Tue, Feb 10, 2009 at 5:02 PM, MattH wrote: > > The pipe macro is definitely not a new idea btw. It's taken from a > thread posted on another lisp group. > > Someone posted a silly inflammatory attack on lisp, contrasting unix: > "cat a b c | grep xyz | sort | uniq" > to how they'd imagine it

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread MattH
The pipe macro is definitely not a new idea btw. It's taken from a thread posted on another lisp group. Someone posted a silly inflammatory attack on lisp, contrasting unix: "cat a b c | grep xyz | sort | uniq" to how they'd imagine it in lisp: "(uniq (sort (grep xyz (cat a b c" A poster c

Re: Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Jeffrey Straszheim
I've found that, in general, the stack dumps you get back from Java (into Clojure-land) are pretty unhelpful. On Tue, Feb 10, 2009 at 4:52 PM, Chas Emerick wrote: > > test-is' :error implementation for the report method restricts the > printing of caught exceptions' frames to 5. I'm finding it

Suggestion: test-is should print *all* frames of exceptions caught while testing

2009-02-10 Thread Chas Emerick
test-is' :error implementation for the report method restricts the printing of caught exceptions' frames to 5. I'm finding it very inconvenient, as many common exceptions have as their first 5-10 frames essentially unhelpful source information. For example, a typical IllegalArgumentException thr

Re: Clojure + Slick - "stylistic" questions

2009-02-10 Thread phtrivier
Okay, can I ask exactly how you produce the map ? In my situation I know how to compute whether a cell [i,j] is blocked, I can generate the list of couples [i,j] that suits me ... and then I am stuck, not knowing with function / macro to call. I guess it's just the same problem as with cond, I am

Re: is mod correct?

2009-02-10 Thread Jeffrey Straszheim
I've seen different theories on how mod should treat negative divisors, but I've never seen that "solution". On Tue, Feb 10, 2009 at 4:30 PM, Chouser wrote: > > Is 'mod' working correctly? > > user=> (map #(mod % 3) (range -9 9)) > (3 1 2 3 1 2 3 1 2 0 1 2 0 1 2 0 1 2) > > It disagrees with, for

stacktrace/print-cause-trace swallows exceptions

2009-02-10 Thread Chas Emerick
In the process of tracking down some failing test-is tests, I believe I discovered that it (via stacktrace) swallows exceptions. Specifically, when an error occurs, it uses stacktrace/print-cause- trace in order to print a stack trace for the error encountered. That's fine, but unless I'm mistaken

is mod correct?

2009-02-10 Thread Chouser
Is 'mod' working correctly? user=> (map #(mod % 3) (range -9 9)) (3 1 2 3 1 2 3 1 2 0 1 2 0 1 2 0 1 2) It disagrees with, for example, Ruby: irb(main):002:0> (-9..9).map{|x| x % 3} => [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0] And python: >>> map( lambda x: x % 3, range(-9,9) )

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Greg Harman
I see that a "lib" section has been added to the Clojure site since I was last there, which is a good major step. I think that it may be useful to add a section there explicitly describing the differences from standard Java packaging, perhaps adding a Java package example to compare against the li

Re: A Clojure documentation browser

2009-02-10 Thread Craig Andera
> When I was writing it, > it sure seemed like I was missing a call to resolve somewhere, but > when it worked for some symbols, I got a) excited, and b) confused. :) Yep, that was basically it: I was calling get-source on the symbol that named the member, but I wasn't bothering to namespace-qual

Re: Got a Clojure library?

2009-02-10 Thread James Reeves
Since my Rend library made it a bit too late to catch the first iteration of the Clojure library page, I'll take the opportunity to change the name to something a little less ambiguous. "Rend" sounded too much like "render", so I've renamed it to "re-rand": Name:        re-rand URL:         htt

Re: Curious about Cells

2009-02-10 Thread Raffael Cavallaro
On Feb 10, 12:34 pm, Krešimir Šojat wrote: > > this errors on loading. Should that be "add-watch" instead? > > In revision 1194 add-watch was renamed to add-watcher. > > -- > Krešimir Šojat Ah, ok, the API docs don't reflect this. --~--~-~--~~~---~--~~ You recei

Re: A Clojure documentation browser

2009-02-10 Thread Craig Andera
> I see that "show source" links are missing on your page for some > functions -- does this indicate a failure of repl-utils/get-source? I think so. But I'm willing to believe that the error is elsewhere. It's just hard for me to see where it could be. > These seem to work fine for me: > > user=

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Meikel Brandmeyer
Hi, Am 10.02.2009 um 18:52 schrieb Stephen C. Gilardi: In clojure.contrib we have many unrelated libs under clojure.contrib. If lazy_seqs.clj (a lib) needed to load functions from fast_memoize.clj (a load file that defines functions in the lazy-seqs namespace), would it really be clearer/a

Atn: Konrad Hinsen -- suggested change to letfn in contrib

2009-02-10 Thread Jeffrey Straszheim
I suggested the following changed to letfn: http://code.google.com/p/clojure-contrib/issues/detail?id=26 and have been informed that you manage this code. Does this change look good to you? -- Forwarded message -- From: Date: Tue, Feb 10, 2009 at 12:31 AM Subject: Issue 26 in

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 12:32 PM, Greg Harman wrote: Let me offer a perspective coming from a Java background: I know that there are subtle differences between a namespace and a Java package, but I still tend to subconsciously consider them analogous: they are container structures for organizing c

Re: find first match in a sequence

2009-02-10 Thread Meikel Brandmeyer
Hi, Am 10.02.2009 um 18:00 schrieb Jeff Rose: Oh cool! I hadn't thought about this aspect of laziness before. I can see there is some zen here that is worth exploring... Many ways to Rome: (first (drop-while (complement predicate) coll)) :) Sincerely Meikel smime.p7s Description: S/

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 11:46 AM, Laurent PETIT wrote: If I understand correctly your proposal, can you verify the following is true : (ns foo.bar) (ns foo.bar.util) (ns foo.bar.impl) (ns foo.bar.data) with foo.bar decomposed in two files : foo/bar.clj and foo/bar1.clj just one file per ns, w

Re: A Clojure documentation browser

2009-02-10 Thread Chouser
On Tue, Feb 10, 2009 at 12:02 PM, Craig Andera wrote: > > 3) To ask specifically why clojure.contrib.repl-utils.get-source fails > so often. I can't figure out why so many of the members fail to > display the source, when some of the others do, sometimes even in the > same namespace. I see that

Re: Curious about Cells

2009-02-10 Thread Jeffrey Straszheim
Thanks! I look through those later. On Tue, Feb 10, 2009 at 12:11 PM, Frantisek Sodomka wrote: > > Cells - A dataflow extension to CLOS > http://common-lisp.net/project/cells/ > > Some discussions on this list (ordered by date): > > (discussed in) Clojure Poll 09/2008 > > http://groups.google.co

Re: Curious about Cells

2009-02-10 Thread Krešimir Šojat
> this errors on loading. Should that be "add-watch" instead? In revision 1194 add-watch was renamed to add-watcher. -- Krešimir Šojat --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Greg Harman
Let me offer a perspective coming from a Java background: I know that there are subtle differences between a namespace and a Java package, but I still tend to subconsciously consider them analogous: they are container structures for organizing code. The code itself (Java classes, or Clojure files

Re: Curious about Cells

2009-02-10 Thread Raffael Cavallaro
On Feb 9, 5:00 pm, Stuart Sierra wrote: > > My latest implementation, at clojure.contrib.auto-agents, does *not* > handle circular dependencies.  It uses Agents and Watchers to > implement the updates. from auto-agent.clj: (defmacro auto-agent "Creates an agent whose value is the result of

Re: Curious about Cells

2009-02-10 Thread Frantisek Sodomka
Cells - A dataflow extension to CLOS http://common-lisp.net/project/cells/ Some discussions on this list (ordered by date): (discussed in) Clojure Poll 09/2008 http://groups.google.com/group/clojure/browse_frm/thread/549696530ccbd0d/24a9c4b795f86ee6?lnk=gst&q=CELLs#24a9c4b795f86ee6 (discussed i

Re: newbie question on compilation

2009-02-10 Thread Laurent PETIT
Sorry, I can't help you concerning emacs and slime, I'm a noob concerning their configuration. BTW, if you don't want to bother with classpath considerations, ..., you should think about trying either netbeans with enclojure or eclipse with clojuredev or Intellij IDEA with the clojure plugin. Bein

A Clojure documentation browser

2009-02-10 Thread Craig Andera
One of the challenges with learning any new platform is learning the libraries. As a way to improve both that an my knowledge of Clojure itself, I whipped together doc-browse, a Clojure library that will spit out an HTML page that contains documentation for a set of Clojure libs. You can see an ex

Re: find first match in a sequence

2009-02-10 Thread Jeff Rose
Oh cool! I hadn't thought about this aspect of laziness before. I can see there is some zen here that is worth exploring... Thanks Mark and Stuart. -Jeff Mark Fredrickson wrote: > Filter is lazy: > > http://clojure.org/api#toc228 > > So you can implement find-first as (first (filter pred col

Re: Curious about Cells

2009-02-10 Thread Krešimir Šojat
Hi Jeffrey, Neman Cells can handle circular dependencies, its just for now I didn't need such a feature so its not exposed in clear way how to do it: (def a (Cell. {:value 5})) (def b (cell [a] [v] (dec v))) (add-trigger a (fn [old-v new-v] (println (str "Cell a changed from: " o

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
If I understand correctly your proposal, can you verify the following is true : (ns foo.bar) (ns foo.bar.util) (ns foo.bar.impl) (ns foo.bar.data) with foo.bar decomposed in two files : foo/bar.clj and foo/bar1.clj just one file per ns, would result in the following structure : /foo/bar.clj /foo

Re: newbie question on compilation

2009-02-10 Thread Tzach
Thanks for the response Yes, I'm using Emacs SLIM. what should be the relation between the file (hello.clj) path to the classpath? Is the compile work on the file name, or on the function? in other word, should I evaluate the function on the REPL before compile? Thanks Tzach On Feb 10, 5:25 pm

Re: find first match in a sequence

2009-02-10 Thread Stuart Sierra
On Feb 10, 11:18 am, Jeff Rose wrote: >   Is there a built-in function that will return the first item in a > collection that matches a predicate?  (Something equivalent to Ruby's > Enumerable#find...)  Seems pretty basic, but I can't find it in the docs. Hi, Jeff, here's how I do it: user> (de

Re: find first match in a sequence

2009-02-10 Thread Mark Fredrickson
Filter is lazy: http://clojure.org/api#toc228 So you can implement find-first as (first (filter pred coll)) -M On Feb 10, 2009, at 10:19 AM, Jeff Rose wrote: > > Well, in case someone else needs the same function and it isn't built- > in, here's what I'm using in the meantime. (Based off of

Re: find first match in a sequence

2009-02-10 Thread Jeff Rose
Well, in case someone else needs the same function and it isn't built- in, here's what I'm using in the meantime. (Based off of the some function that comes in core...) (defn find-first [pred coll] (when (seq coll) (if (pred (first coll)) (first coll) (recur pred (rest coll

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 10:04 AM, Rich Hickey wrote: On Feb 10, 9:45 am, "Stephen C. Gilardi" wrote: I came across this when updating the wikibook concepts page, Libraries section, to be correct for current Clojure behavior. In an early implementation of the code that handles libs, the reso

find first match in a sequence

2009-02-10 Thread Jeff Rose
Hi, Is there a built-in function that will return the first item in a collection that matches a predicate? (Something equivalent to Ruby's Enumerable#find...) Seems pretty basic, but I can't find it in the docs. Thanks, Jeff --~--~-~--~~~---~--~~ You receive

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
In fact, Rich had far better arguments than mines :-) But again, while I agree with you that it may be time to fix things before 1.0, alas, I have no better proposal to make, so I think it's better to stick with the current implementation, and move when the "click" happens in our heads :-) Regard

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 10:02 AM, Laurent PETIT wrote: Hello, Here are some (quick) thoughts : - The wikibook example could also be adapted to the new way of doing things : having add1, otherfunc and morefuncs files in the same directory as ourlib ? Yes it could. They are, however, logicall

Re: newbie question on compilation

2009-02-10 Thread Laurent PETIT
Hello, Can you be more specific about : what is in what file in your example, and what is the structure of the directories you use for the test ? Normally, this should be : (say src is the root source directory set in your classpath) :

Re: Curious about Cells

2009-02-10 Thread Jeffrey Straszheim
I looked at Neman Cells. It looks like a pretty straightforward implementation of the observer pattern. I only took a quick glance, but I see nothing that would handle circularity. The async cells look to me like one could have an inconsistent view of the data depending on *when* one looked at t

Re: newbie question on compilation

2009-02-10 Thread Lennart Staflin
On Feb 10, 2:45 pm, Tzach wrote: > I got "error in process filter: Wrong number of arguments: nil, 3". > What am I missing here? Are you using Emacs with slime? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Rich Hickey
On Feb 10, 9:45 am, "Stephen C. Gilardi" wrote: > I came across this when updating the wikibook concepts page, Libraries > section, to be correct for current Clojure behavior. > > In an early implementation of the code that handles libs, the resource > (file) for lib a.b.c was at the path "a/b/

Re: Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Laurent PETIT
Hello, Here are some (quick) thoughts : - The wikibook example could also be adapted to the new way of doing things : having add1, otherfunc and morefuncs files in the same directory as ourlib ? - if the other "parts" of the lib are not in the same directory/package as the "master lib file", whe

Request for Discussion: changing lib root directory calculation to improve load/:load

2009-02-10 Thread Stephen C. Gilardi
I came across this when updating the wikibook concepts page, Libraries section, to be correct for current Clojure behavior. In an early implementation of the code that handles libs, the resource (file) for lib a.b.c was at the path "a/b/c/c.clj" within classpath. At that time it was natural

Re: pmap issues

2009-02-10 Thread Jeffrey Straszheim
I tried out the new code last night and it worked perfectly. Thanks! On Mon, Feb 9, 2009 at 11:29 AM, Rich Hickey wrote: > > > > On Feb 7, 9:36 pm, Jeffrey Straszheim > wrote: > > With the help of the IRC folks I solved my own problem. > > > > I thought I'd share my findings: > > > > You canno

Re: Wiki -> Concepts -> Libraries -> clojure/ns

2009-02-10 Thread Stephen C. Gilardi
On Feb 10, 2009, at 8:29 AM, Jesse Aldridge wrote: I had to get rid of the "clojure/" part to make it work. Is the wiki wrong? If so, could somebody update it? Hi Jesse, Thanks for the report. I've updated that section to be correct (I believe) for current Clojure. Please let us know if

newbie question on compilation

2009-02-10 Thread Tzach
I try to use the following example (ns clojure.examples.hello (:gen-class)) (defn -main [greetee] (println (str "Hello " greetee "!"))) (compile 'clojure.examples.hello) I got "error in process filter: Wrong number of arguments: nil, 3". What am I missing here? Thanks --~--~-~

Re: ClassFormatError on compile

2009-02-10 Thread Chas Emerick
This turned out to be caused by a large code literal in some test code. Java classfiles have certain implementation limits -- in particular, limits on the size of the bytecode that implements methods (as well as other elements in classfiles). Rich discussed this briefly back in November here, wh

Wiki -> Concepts -> Libraries -> clojure/ns

2009-02-10 Thread Jesse Aldridge
Here in the wiki: http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Libraries The examples make use of the clojure/ns command, for example: (clojure/ns example.ourlib) I had to get rid of the "clojure/" part to make it work. Is the wiki wrong? If so, could somebody update it? --~--~

Re: patch to improve startup time on low end hardware

2009-02-10 Thread Remco van 't Veer
On Tue, Feb 10, 2009 at 1:33 PM, Rich Hickey wrote: > On Feb 10, 3:47 am, "Remco van 't Veer" wrote: >> Hi Rich, >> >> I've been working on getting clojure in a more usable state for android >> [1]. One of the challenges was to speedup startup time. A lot of >> time is spend in the lisp-reader

Re: patch to improve startup time on low end hardware

2009-02-10 Thread Rich Hickey
On Feb 10, 3:47 am, "Remco van 't Veer" wrote: > Hi Rich, > > I've been working on getting clojure in a more usable state for android > [1]. One of the challenges was to speedup startup time. A lot of > time is spend in the lisp-reader because all constants are stored as > lisp expressions.

  1   2   >