Is this a bug?(same key in map n times)

2010-03-08 Thread alux
Hi, if I put the same keyword in a map literal multiple times, it seems to stay there somehow: user=> {:a 1 :a 2 :a 3} {:a 1, :a 2, :a 3} The first entry wins here. user=> (def a {:a 1 :a 2 :a 3}) #'user/a user=> (:a a) 1 Is this a bug, or a feature? (tested with clojure 1.1 and yesterdays gi

Re: Is this a bug?(same key in map n times)

2010-03-08 Thread Meikel Brandmeyer
Hi, On Mar 8, 9:19 am, alux wrote: > if I put the same keyword in a map literal multiple times, it seems to > stay there somehow: > > user=> {:a 1 :a 2 :a 3} > {:a 1, :a 2, :a 3} This is an optimisation for small maps: the keys are not checked for uniqueness. One has to distinguish array maps f

Re: Is this a bug?(same key in map n times)

2010-03-08 Thread alux
Ah, up to 8, yes. Funny: user=> (def a {:a 1 :a 2 :a 3 :a 4 :a 5 :a 6 :a 7 :a 8}) #'user/a user=> a {:a 1, :a 2, :a 3, :a 4, :a 5, :a 6, :a 7, :a 8} user=> (def a {:a 1 :a 2 :a 3 :a 4 :a 5 :a 6 :a 7 :a 8 :a 9}) #'user/a user=> a {:a 9} Thank you. a. On 8 Mrz., 09:23, Meikel Brandmeyer wrote: >

Clojure for financial applications

2010-03-08 Thread jshore
Hi, Its been 19 years since I last wrote anything serious in lisp (and that was Scheme). In the intervening time I've mostly used OO languages, for lack of more practical functional ones. There are now a number of functional or hybrid functional languages available which have become practical.

Re: clojure slides

2010-03-08 Thread Terje Norderhaug
On Mar 6, 2010, at 5:27 PM, Sophie wrote: Re: Emacs + Slime + paredit. I did not see Clojure listed as supported for Slime and paredit. Do you know if: - Can you do all Slime stuff in Clojure? evaluate, macro-expand, docs, etc? You can do much of the SLIME stuff including the items listed,

Re: enclojure install killed netbeans 6.8

2010-03-08 Thread strattonbrazil
I am on Linux. I have a 6.6 and a 6.8 directory in my .netbeans folder. 6.6 still runs. I have tried moving individual jars in and out of that dir, but I still get the error. I even moved the entire 6.8 dir and still get the same message. On Mar 7, 10:25 am, Mark Nutter wrote: > On Fri, Mar 5

Problem with simple gui

2010-03-08 Thread stefanmuenchow
I tried to build a Swing gui with Clojure and get an error I don't understand. Perhaps it's more a swing-problem than a clojure-problem, but I'm sure the solution is simple and someone here will know the answer. I have two frames, one serves as the main-window of the app and the second one opens i

bounded memoize

2010-03-08 Thread Eugen Dück
In many real applications (I guess that rules out fibonacci), memoize will consume a lot of memory and create OutOfMemoryErrors sooner or later. Often you want to only keep the latest items in the cache and forget about older ones. I've seen a variant of memoize that evicts items based on a time-t

Shared symbol context and lazy dataflows

2010-03-08 Thread drrobot
Hi All, Timid coder here looking for some confirmation/advice on my understanding of math and concurrent dataflow in Clojure before I dive in. Clojure looks like a great language and I am enthusiastic to try it out on some light numerics programs. Basically, what I have now is around a hundred eq

apply-ing Java methods

2010-03-08 Thread Michael Gardner
Given a Java instance 'store' with a .connect method that takes a host, port, user and password, and given a hash-map 'config' with corresponding keyword values, I wanted to do something like: (apply .connect store (map config [:host :port :user :password])) rather than: (.connect store (:host

Re: apply-ing Java methods

2010-03-08 Thread Volkan YAZICI
See memfn in Clojure API docs. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from

Re: Problem with simple gui

2010-03-08 Thread Meikel Brandmeyer
Hi, On Mar 8, 12:44 am, stefanmuenchow wrote: >     (.addActionListener convert-button >       (proxy [ActionListener] [] >         (actionPerformed [evt] >           (.show frame2) >           (complex-calc) >           (.setText temp-text "Calc1") >           (complex-calc) >           (.setTe

Re: I confused myself. How can I solve this simple problem?

2010-03-08 Thread James Reeves
I'd have thought the idiomatic way of doing this would be: (ns my-namespace (:refer-clojure :exclude [println])) (defn println [s] (clojure.core/println s) (clojure.core/println "tacked on")) - James On 8 March 2010 03:57, CuppoJava wrote: > So I just stumbled across this bug in my code,

Re: Clojure for financial applications

2010-03-08 Thread Stuart Halloway
Here are a few random thoughts: (1) You still have namespaces in Clojure, which correspond 1-1 with Java packages. (2) Multimethods are open, so you add to them from multiple places. (3) Protocols (a 1.2) feature give you an approach to your strategies that is more flexible than OO interfa

Re: Shared symbol context and lazy dataflows

2010-03-08 Thread Adrian Cuthbertson
Hi Ivar, > ;; Do things such as hash-map comprehensions exist? Should they? ;-) > (defn some-eqn3 [obj] > (let [{:a a :b b :c c} obj] > (/ (+ (- b) (sqrt (- (* b b) (* 4 a c > (* 2 a At least a partial stab at some of your questions... (def myhash {:a 1 :b 5 :c 6 :x nil}) (defn s

Re: Clojure for financial applications

2010-03-08 Thread Stuart Sierra
On Mar 8, 9:29 am, Stuart Halloway wrote: > (1) You still have namespaces in Clojure, which correspond 1-1 with   > Java packages. More or less. The namespace "foo.bar.baz" is actually a Class named "baz" in the package "foo.bar". -SS -- You received this message because you are subscribed to

Re: apply-ing Java methods

2010-03-08 Thread Adrian Cuthbertson
Maybe just; (let [{:keys host port user password} config] (.connect store host port user password)) On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner wrote: > Given a Java instance 'store' with a .connect method that takes a host, port, > user and password, and given a hash-map 'config' with co

Re: apply-ing Java methods

2010-03-08 Thread Meikel Brandmeyer
> (let [{:keys host port user password} config] >    (.connect store host port user password)) module missing [] around the keys. ;) And of course this does not work for non-constant keylists. However I think in the majority of cases the list should be constant. -- You received this message be

Re: apply-ing Java methods

2010-03-08 Thread Adrian Cuthbertson
There's a fundamental law of nature that says; if you don't try it at the repl before posting, you WILL get it wrong :-). On Mon, Mar 8, 2010 at 5:19 PM, Meikel Brandmeyer wrote: > >> (let [{:keys host port user password} config] >>    (.connect store host port user password)) > > module missing

monkeypatching in clojure

2010-03-08 Thread cageface
I've been reading about some of the clever things Scala does to allow safer monkeypatching and this started me thinking about Clojure's approach to this technique. Maybe I'm overlooking something but is this just a non-issue in Clojure? Since functions aren't attached to objects it seems to me you

Re: Clojure for financial applications

2010-03-08 Thread Volkan YAZICI
On Mar 7, 6:35 pm, jshore wrote: > Wondering whether anyone has done something very complex in the algo > space or comparable so can get an idea of how this sort of stuff is > structured idiomatically.   I will also be concerned with performance > and memory use, as one of my strategies creates a

Re: monkeypatching in clojure

2010-03-08 Thread Konrad Hinsen
On 8 Mar 2010, at 17:39, cageface wrote: this just a non-issue in Clojure? Since functions aren't attached to objects it seems to me you can just define a new function on an existing type or another method clause in a multi or if necessary. Maybe you have to be careful about messing around with

Job Fair

2010-03-08 Thread Jeff Straszheim
Howdy The company where I work, Velocitude, is hiring Clojure developers. We will be attending a job fair on March 11 in Cambridge, MA. Details are here: http://www.velocitude.com/info/2010/03/01/ Specific Clojure knowledge is not required. Anyone w/ a LISP or FP background would be an idea

Re: apply-ing Java methods

2010-03-08 Thread Nurullah Akkaya
On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner wrote: > Given a Java instance 'store' with a .connect method that takes a host, port, > user and password, and given a hash-map 'config' with corresponding keyword > values, I wanted to do something like: > > (apply .connect store (map config [:ho

Visual Studio plugin

2010-03-08 Thread Eric Thorsen
Is there/is anyone working on/is anyone interested in working on a Visual Studio plugin for a Clojure REPL for clojureCLR? My company might be interested in sponsoring this work. Thanks! eric -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Re: monkeypatching in clojure

2010-03-08 Thread cageface
The one potential downside I've seen to the function-oriented approach is that you often wind up encoding the argument type in the function name. For example, if I write a library to manipulate SQL databases I might write a lot of functions that start with db- and resultset- and statement- etc. So

Re: monkeypatching in clojure

2010-03-08 Thread Raoul Duke
On Mon, Mar 8, 2010 at 11:40 AM, cageface wrote: > The one potential downside I've seen to the function-oriented approach > is that you often wind up encoding the argument type in the function > name. uh, hey, wait a second, please note that is about type checking, not about OO vs. FP! sincerely

Re: monkeypatching in clojure

2010-03-08 Thread cageface
On Mar 8, 11:48 am, Raoul Duke wrote: > uh, hey, wait a second, please note that is about type checking, not > about OO vs. FP! Yeah I'm not talking about OO vs FP but about the function-centric approach that Lisps and languages like Haskell take as opposed to the object, or noun-centric approach

Re: monkeypatching in clojure

2010-03-08 Thread Richard Newman
Yeah I'm not talking about OO vs FP but about the function-centric approach that Lisps and languages like Haskell take as opposed to the object, or noun-centric approach of languages like Java or Ruby. Interesting reading from 2006: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-o

Re: monkeypatching in clojure

2010-03-08 Thread cageface
On Mar 8, 12:47 pm, Richard Newman wrote: > Interesting reading from 2006: > > http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns... Yeah I was just reading that this weekend actually. To be clear, I'm not knocking the verb-oriented approach. I guess I just think it's interest

Re: I confused myself. How can I solve this simple problem?

2010-03-08 Thread CuppoJava
Thanks for the responses. The let form is suitable enough as a workaround. The thing that really bothered me about this is because separation of responsibilities breaks down somewhat. Imagine I create a library of different println's for use in different circumstances. (defn fancy-println [] ) (

symbolmacro tests fail under 1.3.2-SNAPSHOT

2010-03-08 Thread Mark Derricutt
I posted this the other day to the clojure-maven-plugin list but had no response, so thought I'd ask here. I'm wanting to push out a new release of the maven plugin, but I noticed the other day that one of clojure-contrib's tests failed when running with it: Testing clojure.contrib.test-macro-uti

Hiccup 0.2.1 release

2010-03-08 Thread James Reeves
Hiccup is a library for generating a string of HTML from a tree of Clojure vectors. It supports dynamically generating HTML, but since 0.2.0 it statically compiles and optimizes where possible. This makes Hiccup very, very fast. Under some circumstances, it even outperforms clj-html. Here are some

Re: bounded memoize

2010-03-08 Thread Michał Marczyk
On 8 March 2010 05:31, Eugen Dück wrote: > And here's a variant that evicts elements when the size of the cache > exceeds some limit. In that case, the first item that was put in it > will be dissoc'ed. I'm using an array-map to accomplish this: I don't think this will work as you expect it to. T

Re: bounded memoize

2010-03-08 Thread André Ferreira
On 8 mar, 23:22, Michał Marczyk wrote: > I'd suggest a vector instead; they're countable in constant time and > you can use, say, conj and rest for add to end of queue / eject from > front of queue. Conj adds to the end of a vector in constant time, but rest will not return another vector, but a

Re: bounded memoize

2010-03-08 Thread Michał Marczyk
2010/3/9 André Ferreira : > Conj adds to the end of a vector in constant time, but rest will not > return another vector, but a sequence. Converting that sequence into > another vector will take O(n). If you want queueing behaviour, you > should use a clojure.lang.PersistentQueue: > (-> clojure.lan

Re: Hiccup 0.2.1 release

2010-03-08 Thread Wilson MacGyver
where is the library? I followed the link http://gist.github.com/326028 but it says it's been deleted. On Mon, Mar 8, 2010 at 8:44 PM, James Reeves wrote: > Hiccup is a library for generating a string of HTML from a tree of > Clojure vectors. It supports dynamically generating HTML, but since >

Re: apply-ing Java methods

2010-03-08 Thread Michał Marczyk
I find #(.connect %) to be the most pleasing form. Sincerely, Michał -- 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: Hiccup 0.2.1 release

2010-03-08 Thread James Reeves
On Mar 9, 3:27 am, Wilson MacGyver wrote: > where is the library? I followed the linkhttp://gist.github.com/326028 > > but it says it's been deleted. D'oh! Telling people where the library is would be kinda a good idea. The library can be found on GitHub: http://github.com/weavejester/hiccup An

Concurrent requests for Java's HTTP Server

2010-03-08 Thread Abhay
Hi All, I have created a small app using the java's base HTTP server shiped with JDK. I observed that the HTTP requests cannot execute simultaneously. For eg, my request 1 is blocking my request 2. As soon as I unblock the request, other request gets completed. Does this HTTP Server provides con

Two potential map-util functions

2010-03-08 Thread Luka
I'm aware of clojure-dev group, but being new to clojure, i thought I should start here first. These are two methods I've needed in my project and I didn't found better way to accomplish these tasks. First function returns vector of leaf nodes in a map, and second dissociates in nested map. First q

Re: apply-ing Java methods

2010-03-08 Thread Michael Gardner
On Mar 8, 2010, at 6:50 AM, Volkan YAZICI wrote: > See memfn in Clojure API docs. Thanks for the tip. After some experimentation: (apply (memfn connect a b c d) store (map config [:host :port :user :password])) but why does memfn require these "dummy" arguments? -- You received this message b

Re: apply-ing Java methods

2010-03-08 Thread Michael Gardner
On Mar 8, 2010, at 9:16 AM, Adrian Cuthbertson wrote: > Maybe just; > (let [{:keys host port user password} config] > (.connect store host port user password)) Having to repeat the variable names rather defeats the purpose, since this version is longer than the original and still feels redunda

Re: Clojure for financial applications

2010-03-08 Thread Jonathan Shore
Thanks for the reply. I could be wrong, but namespaces just provide a package / require mechanism, such that only required functionality is in the namespace of some code.This seems to be more of a mapping to the package / import mechanism of java or something similar in ruby or python. Ho

Clojure Implementation issues that may affect performance?

2010-03-08 Thread Jonathan Shore
Hi, I was stepping through a very simply test (not meant to be performant) and noticed the following: (ns test.performance.fibonachi) (defn fib [a] (if (< a 2) a (+ (fib (- a 1)) (fib (- a 2) (fib 45) Stepping into (if ...) noticed that (< a 2) called into the following Java c

Re: Clojure for financial applications

2010-03-08 Thread Jonathan Shore
On Mar 8, 2010, at 11:51 AM, Volkan YAZICI wrote: > On Mar 7, 6:35 pm, jshore wrote: >> Wondering whether anyone has done something very complex in the algo >> space or comparable so can get an idea of how this sort of stuff is >> structured idiomatically. I will also be concerned with perform

benchmarks on a poor-man's matrix concept

2010-03-08 Thread Jonathan Shore
Hi, I'm still trying to work out the best way to deal with operations on heterogenous data in clojure. I have a complex application which has such requirements. I wrote a simple toy matrix as a means to explore closure versus map based implementations. Note that in this case the "data str

Programming Clojure, index-filter & when

2010-03-08 Thread Martin Hauner
Hi, there is an example in programming clojure (Chapter 2.6, Where is my for loop? on page 52) that I don't really get. (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) The explanation in the book explains the for/:when but not the when. ;)

Re: bounded memoize

2010-03-08 Thread Eugen Dück
Good points! Testing array-map briefly led me to believe they can be used as the clojure equivalent of Java\s LinkedHashMaps. Here's a version that uses a vector to remember order of insertion - I guess I have to use refs and transactions now: (defn bounded-memoize [f bound] (let [mem (ref {}

Re: Shared symbol context and lazy dataflows

2010-03-08 Thread drrobot
On Mar 8, 11:57 pm, Adrian Cuthbertson wrote: > Hi Ivar, > > > ;; Do things such as hash-map comprehensions exist? Should they? ;-) > > (defn some-eqn3 [obj] > > (let [{:a a :b b :c c} obj] > >   (/ (+ (- b) (sqrt (- (* b b) (* 4 a c > >      (* 2 a > > At least a partial stab at some of y

Re: I confused myself. How can I solve this simple problem?

2010-03-08 Thread Armando Blancas
What about coding it as a hook? Though I realize you have to introduce a new name. user=> (defn myprintln [str] (println str) (println "tacked on")) #'user/myprintln user=> (let [print-hk myprintln] (print-hk "some code")) some code tacked on nil user=> (let [print-hk println] (print-hk "some

Re: Concurrent requests for Java's HTTP Server

2010-03-08 Thread Brendan Ribera
This seems to be more of a Java question than a Clojure one, but I'll take a stab at it anyway. I'm assuming you refer to com.sun.net.httpserver.HttpServer. Per the docs, "Management of threads can be done external to this object by providing a Executor<../../../../../../../../../api/java/util/con

Re: Programming Clojure, index-filter & when

2010-03-08 Thread Brendan Ribera
Should you pass in nil, the 'when' will guard against a NPE. On Mon, Mar 8, 2010 at 2:32 PM, Martin Hauner wrote: > Hi, > > there is an example in programming clojure (Chapter 2.6, Where is my > for loop? on page 52) > that I don't really get. > > (defn index-filter [pred coll] > (when pred >

Re: apply-ing Java methods

2010-03-08 Thread Michał Marczyk
On 8 March 2010 17:37, Michael Gardner wrote: > Thanks for the tip. After some experimentation: > > (apply (memfn connect a b c d) store (map config [:host :port :user > :password])) Oh right, you wanted more arguments. So I should have suggested #(.connect %1 %2 %3 %4). > but why does memfn re

Re: Two potential map-util functions

2010-03-08 Thread Timothy Pratley
>      true (update-in m (butlast v) #(dissoc % (last v)) No need for an unnamed function: true (update-in m (butlast v) dissoc (last v)) Regards, Tim. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: Clojure Implementation issues that may affect performance?

2010-03-08 Thread Timothy Pratley
On 9 March 2010 04:03, Jonathan Shore wrote: > (defn fib [#^Integer a] >   (if (< a 2) >     a >     (+ (fib (- a 1)) (fib (- a 2) > I'm just learning, so I may have overlooked something that mitigates or > otherwise avoids dispatch. You might want to experiment with something like (defn fib

Re: I confused myself. How can I solve this simple problem?

2010-03-08 Thread Meikel Brandmeyer
Hi, On Mar 8, 10:23 pm, CuppoJava wrote: > And yet, the writer of the library shouldn't have to be aware that the > user *might* bind fast-println to println. > And the user of the library shouldn't have to be aware of the > implementation details of fast-println to want to bind println. Maybe

Re: Interested in creating a Clojure course

2010-03-08 Thread Michael Kohl
The new Clojure course on RubyLearning has now officially been announced with a tentative starting date of mid to late April: http://rubylearning.com/blog/2010/03/09/clojure-101-a-new-course/ On Tue, Mar 2, 2010 at 12:54 PM, Michael Kohl wrote: > *) decide on a 8 curriculum for an 8 week course

Re: benchmarks on a poor-man's matrix concept

2010-03-08 Thread Timothy Pratley
On 9 March 2010 06:57, Jonathan Shore wrote: > the second because maps clearly are not "near the metal" maps are actually very very efficiently implemented. Small maps are especially efficient as they are implemented as array maps. user=> (type {:a 1, :b 2}) clojure.lang.PersistentArrayMap At te

Re: bounded memoize

2010-03-08 Thread Meikel Brandmeyer
Hi, On Mar 9, 4:41 am, Eugen Dück wrote: > Good points! Testing array-map briefly led me to believe they can be > used as the clojure equivalent of Java\s LinkedHashMaps. > > Here's a version that uses a vector to remember order of insertion - I > guess I have to use refs and transactions now: >

Re: symbolmacro tests fail under 1.3.2-SNAPSHOT

2010-03-08 Thread Konrad Hinsen
On 9 Mar 2010, at 01:01, Mark Derricutt wrote: I know we've changed around how clojure:test runs under 1.3.2-SNAPSHOT and I half expected the build to fail, but this wasn't the failure I expected to see. Anyone have any idea whats going on here? It has me stumped at the moment... Is this a pr