Re: Experiment with named args

2009-07-16 Thread Laurent PETIT
2009/7/17 Mark Addleman > > "The "sufficiently smart compiler" argument > comes to mind: if the arglist of a function is known, then surely > the > compiler should be able to automatically translate named/keyword > arguments into an appropriate simple call?" > > That is exactly what motivated

Re: Experiment with named args

2009-07-16 Thread Laurent PETIT
Interesting ! BTW, I think you can simplify (eval `^(var ~fn)) into (meta (resolve fn)). Regards, -- Laurent 2009/7/17 Mark Addleman > > A few days ago, Chouser and I had a discussion on IRC about the > viability of named arguments (a la Smalltalk) for Clojure. In clojure- > contrib, there

Re: clojure-contrib

2009-07-16 Thread Meikel Brandmeyer
Hi, On Jul 17, 6:21 am, Wilson MacGyver wrote: > Can clojure-contrib be used with clojure-1.0? Or in order to use it, I also > need to build clojure from github? There is a 1.0-compat branch in clojure-contrib, which works with clojure 1.0. > come to think of it, with various libraries being

Re: Experiment with named args

2009-07-16 Thread Mark Addleman
"The "sufficiently smart compiler" argument comes to mind: if the arglist of a function is known, then surely the compiler should be able to automatically translate named/keyword arguments into an appropriate simple call?" That is exactly what motivated me to write this macro. I was pretty su

Re: How to achieve indirection?

2009-07-16 Thread Eric Tschetter
One other option is to use "binding" to overwrite the value in a certain context. I.e. you have (defn do-something-elegantly ...) (defn do-something-quickly ...) (def do-something do-something-elegantly) But, then you have some function that needs to be run quickly: (defn needs-to-be-fast []

clojure-contrib

2009-07-16 Thread Wilson MacGyver
Can clojure-contrib be used with clojure-1.0? Or in order to use it, I also need to build clojure from github? come to think of it, with various libraries being announced, are people targeting clojure 1.0? Thanks, Mac -- Omnem crede diem tibi diluxisse supremum. --~--~-~--~~--

Re: How to achieve indirection?

2009-07-16 Thread Adrian Cuthbertson
You can also pass functions (and closures) around in a map; (defn my-app-uses-do-something [map-with-cfg-stuff] ... ((:do-something map-with-cfg-stuff) 13 19)) ) (defn do-something-quickly [x y] ... (defn do-something-elegantly [x y] ... (my-app-uses-do-something {:do-something do-somet

Re: comment macro not ignoring contents

2009-07-16 Thread kkw
That makes really good sense. Thanks for the clear explanation! Kev On Jul 17, 1:56 pm, Richard Newman wrote: > > 1:24 com.kkw.ss=> (comment 1s) > > java.lang.NumberFormatException: Invalid number: 1s > > java.lang.Exception: Unmatched delimiter: ) > > 1:25 com.kkw.ss=> > > >    Kindly let me k

Re: comment macro not ignoring contents

2009-07-16 Thread Richard Newman
> 1:24 com.kkw.ss=> (comment 1s) > java.lang.NumberFormatException: Invalid number: 1s > java.lang.Exception: Unmatched delimiter: ) > 1:25 com.kkw.ss=> > >Kindly let me know if I've done something abnormal. comment is a macro, not a syntactic element. A macro is evaluated after read time (

comment macro not ignoring contents

2009-07-16 Thread kkw
Hi folks, Anyone get the following interesting messages? 1:19 com.kkw.ss=> (comment 1) nil 1:20 com.kkw.ss=> (comment s1) nil 1:21 com.kkw.ss=> (comment 1) nil 1:22 com.kkw.ss=> (comment s) nil 1:23 com.kkw.ss=> (comment s1) nil 1:24 com.kkw.ss=> (comment 1s) java.lang.NumberFormatException:

Re: Experiment with named args

2009-07-16 Thread Richard Newman
> Even if the macro isn't all that valuable, I learned a lot > about Clojure in the process. If anyone has any suggestions, I'd love > to hear them. This is definitely interesting to me. I currently use the keyword arg idiom -- (apply hash-map args) -- but I'm painfully aware of all the addit

Experiment with named args

2009-07-16 Thread Mark Addleman
A few days ago, Chouser and I had a discussion on IRC about the viability of named arguments (a la Smalltalk) for Clojure. In clojure- contrib, there is the macro "defnk" which provides this sort of capability, but it's performance characteristics are worse than than normal function call. I want

ANN: clj-mql

2009-07-16 Thread Richard Newman
Following hot on the heels of its dependency, here's clj-mql. clj-mql is a client library for Freebase (or any site that implements its API). It currently allows you to issue unauthenticated version, status, read, search, and reconcile request

ANN: clj-apache-http

2009-07-16 Thread Richard Newman
I've recently made public an HTTP client library, built atop the Apache HttpClient. The motivation for building my own was to expose more flexibility than most 'trivial' HTTP clients; that flexibility is necessary for some projects on

Re: Algorithm help

2009-07-16 Thread Mark Triggs
Hi there, I had a bit of a go at converting the Python version into Clojure and removed the need to mutate an array. Because the 'lcs' function was basically just mapping over a list of i/j pairs and accumulating the resulting matrix, it seemed like a good candidate for reduce: (defn lcs [x y]

Re: Algorithm help

2009-07-16 Thread Laurent PETIT
Hi, I didn't test what I'll say, but it seems to me there are more than one problem: * when having in cond long conditions followed by a long expression, you should consider switching to "miser" mode by placing the expression on a new line, indented 2 characters from the condition start column

Re: How to achieve indirection?

2009-07-16 Thread John Harrop
On Thu, Jul 16, 2009 at 11:34 AM, Dragan wrote: > Thanks for the tip, I meant something else. > Let's say that I want to write a function do-something. There could be > 2 implementations: do-something-quickly and do-something-elegantly. > The parameters are the same and there are no differences i

Re: How to achieve indirection?

2009-07-16 Thread Garth Sheldon-Coulson
One tactic I've used for this is function-generating functions or, in more complex situations, closure-generating functions. I'd appreciate thoughts from gurus on whether this is idiomatic. For instance: You have functions do-something-quickly and do-something-elegantly. You want to call these in

Re: How to achieve indirection?

2009-07-16 Thread Laurent PETIT
Hi, it looks more like a problem of dependency injection (which implementation for the interface, and who's responsible for choosing the implementation), so. (And now that I re-read the subject of your e-mail ... :-) If we're just talking about switching the implementation of one function indepen

Algorithm help

2009-07-16 Thread martin_clausen
Can anybody give me some hints on how to translate this: http://bit.ly/lcs_py (the backTrackAll function) from Python into Clojure? I have a pasted my attempt here: http://paste.lisp.org/+1SL7, but it doesn't work. For completeness I have included the functions required to test the traceback-all-l

Re: Performance question (newbie)

2009-07-16 Thread Wilson MacGyver
This link reminded me of this discussion. http://www.cnn.com/2009/US/07/15/quadrillion.dollar.glitch/index.html?iref=newssearch as Rich said, unchecked is generally a bad idea. :) On Wed, Jul 15, 2009 at 10:24 PM, Rich Hickey wrote: > > > > On Jul 15, 2:22 pm, John Harrop wrote: >> On Wed, Jul

Re: easiest JMX API ever, in Clojure...

2009-07-16 Thread Daniel
On Thu, Jul 16, 2009 at 10:20 PM, Michael Wood wrote: > > 2009/7/16 Daniel : >> >> On Thu, Jul 16, 2009 at 3:18 AM, Michael Wood wrote: > [...] >>> By the way, how does twiddle.sh (which appears to be a command line >>> tool for fiddling with JMX stuff in JBoss) work then?  Because it >>> works wi

Re: How to achieve indirection?

2009-07-16 Thread Dragan
Thanks for the tip, I meant something else. Let's say that I want to write a function do-something. There could be 2 implementations: do-something-quickly and do-something-elegantly. The parameters are the same and there are no differences in their "interface". I would like to be able to call it b

Re: turn off scientific notation?

2009-07-16 Thread Stephen C. Gilardi
On Jul 16, 2009, at 11:50 AM, Laurent PETIT wrote: what do you mean ? For what I know, the output streams have nothing to do with formatting ? You're right, Laurent, thanks for the correction. REPL output is printed using prn which (for Doubles) ultimately calls ".toString" on the Double

Re: turn off scientific notation?

2009-07-16 Thread Laurent PETIT
Hi Stephen, 2009/7/16 Stephen C. Gilardi > > On Jul 16, 2009, at 10:13 AM, flodel wrote: > > I have a Clojure script that reads numbers in a normal format like >> 0.012, but after processing, returns in a scientific format, for >> example, 8.03E-6 >> >> Is there a way to turn this scientifi

Re: turn off scientific notation?

2009-07-16 Thread Stephen C. Gilardi
On Jul 16, 2009, at 10:13 AM, flodel wrote: I have a Clojure script that reads numbers in a normal format like 0.012, but after processing, returns in a scientific format, for example, 8.03E-6 Is there a way to turn this scientific notation off? Numbers are stored internally in a binary

Re: easiest JMX API ever, in Clojure...

2009-07-16 Thread Michael Wood
2009/7/16 Daniel : > > On Thu, Jul 16, 2009 at 3:18 AM, Michael Wood wrote: [...] >> By the way, how does twiddle.sh (which appears to be a command line >> tool for fiddling with JMX stuff in JBoss) work then?  Because it >> works without having to use the >> -Dcom.sun.management.jmxremote.port=12

turn off scientific notation?

2009-07-16 Thread flodel
hello, I have a Clojure script that reads numbers in a normal format like 0.012, but after processing, returns in a scientific format, for example, 8.03E-6 Is there a way to turn this scientific notation off? Thank you. --~--~-~--~~~---~--~~ You received thi

Re: How to achieve indirection?

2009-07-16 Thread Laurent PETIT
Certainly multimethods : * introduction : http://clojure.org/runtime_polymorphism * detail : http://clojure.org/multimethods And, also, don't forget the power given to you by first class / higher order functions. With them, a lot of "variability" can be placed just in functions, where it was a p

How to achieve indirection?

2009-07-16 Thread Dragan
Hi, This is another one of my newbie questions, so please be patient if this is something out of the FP paradigm. I've noticed that there is a number of "duplicate" functions, functions that implement the same thing in a different way. In OO systems, I would use an interface to achieve the indire

Re: turn a seq into a list

2009-07-16 Thread Laurent PETIT
But in this particular case (calling (apply list seq)) since we want to create a data structure that will hold the whole seq at once, then apply will not prevent seq from being of a great length, it's the memory heap that will. (I think the question was more : does apply have some "hard coded" lim

Re: turn a seq into a list

2009-07-16 Thread Drew Raines
jvt wrote: > Doesn't apply have a limit on the length of the arguments passed, > too? Yes. http://groups.google.com/group/clojure/msg/34b9a170d36c5ab5 -Drew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojur

Re: turn a seq into a list

2009-07-16 Thread Meikel Brandmeyer
Hi, On Jul 16, 1:43 pm, jvt wrote: > Doesn't apply have a limit on the length of the arguments passed, too? apply is lazy. user=> (defn foo [& args] (take 5 args)) #'user/foo user=> (apply foo (iterate inc 0)) (0 1 2 3 4) Sincerely Meikel --~--~-~--~~~---~--~~

Clojure contrib in maven?

2009-07-16 Thread Mark Derricutt
'lo all, Now that we have clojure 1.0 in maven central, it'd be great to also have a release of closure contrib ALSO in central. I understand theres a 1.0-compat branch of contrib available, can we roll a release of that? Mark -- Discouragement is a dissatisfaction with the past, a distaste for

Re: turn a seq into a list

2009-07-16 Thread jvt
Doesn't apply have a limit on the length of the arguments passed, too? On Jul 16, 7:22 am, Jan Rychter wrote: > Jarkko Oranen writes: > > On Jul 15, 1:54 pm, Jan Rychter wrote: > >> I've been looking for a function that would take a seq and create a list > >> (a real clojure.lang.PersistentLis

Re: easiest JMX API ever, in Clojure...

2009-07-16 Thread Stuart Halloway
Good point, and added to the jmx.clj file comment. The JMX stuff is being built on edge and depends on post-1.0 Clojure, specifically the features added in ticket #131 (http://www.assembla.com/spaces/clojure/tickets/131-Move-Clojure-tests-from-contrib-into-Clojure ). Stu > 2009/7/14 Stuart

Re: Clojure vectors

2009-07-16 Thread Daniel
On Thu, Jul 16, 2009 at 1:52 AM, John Harrop wrote: > On Wed, Jul 15, 2009 at 12:58 PM, Mark Engelberg > wrote: >> >> It looks like stack-rot is going to be the bottleneck in your app >> since it requires traversing the whole vector to build the new one, >> but I think the list-based implementati

Re: easiest JMX API ever, in Clojure...

2009-07-16 Thread Daniel
On Thu, Jul 16, 2009 at 3:18 AM, Michael Wood wrote: > > 2009/7/15 Daniel : >> >> On Wed, Jul 15, 2009 at 3:43 AM, Michael Wood wrote: > [...] >>> I've never tried this sort of thing before, but I'm trying to connect >>> to a JBoss instance with it and not having much luck.  I think I need >>> to

Re: Examining performance on the JVM

2009-07-16 Thread Daniel
On Thu, Jul 16, 2009 at 11:00 AM, Glen Stampoultzis wrote: > Apparently it's possible to see the assembly instructions if you're running > a debug VM [1]. > > -XX:+PrintOptoAssembly dumps to the console a log of all assembly being > generated for JITed methods. The instructions are basically x86 a

Re: turn a seq into a list

2009-07-16 Thread Jan Rychter
Jarkko Oranen writes: > On Jul 15, 1:54 pm, Jan Rychter wrote: >> I've been looking for a function that would take a seq and create a list >> (a real clojure.lang.PersistentList), but haven't found one. The closest >> I got was: >> >> (apply list my-seq) >> >> Essentially, I'm looking for someth

Re: Examining performance on the JVM

2009-07-16 Thread Christian Vest Hansen
I haven't tried to look beyond the JIT to see what it does, so I wouldn't know which tools to use, but if you do not already know about it, you might find the HotSpot Internals wiki to be an interesting source of info: http://wikis.sun.com/display/HotSpotInternals/Home On Thu, Jul 16, 2009 at 5:3