Re: Clojure for financial applications

2010-03-09 Thread Konrad Hinsen
On 8 Mar 2010, at 19:22, Jonathan Shore wrote: For the sake of understanding, I'm not yet clear on how one *efficiently* binds multiple "pieces" of state together in clojure. How would one create a simple matrix for example where I want to bind dimension and a float-array into a tightly b

Re: Two potential map-util functions

2010-03-09 Thread Meikel Brandmeyer
Hi, On Mar 8, 2:59 pm, Luka wrote: > (defn leafs [m] >   (loop [vs (vals m), accum []] >     (if (empty? vs) >       accum >       (let [v (first vs)] >         (if (map? v) >           (recur (rest vs) (into accum (leafs v))) >           (recur (rest vs) (conj accum v))) How about this? (

Re: bounded memoize

2010-03-09 Thread Meikel Brandmeyer
Woops. And of course there should be the check for bound in the update functions of the lru and mu strategies... (defn lru-cache-strategy "Implements LRU cache strategy for memoize. At most bound number of argument lists are kept in the cache. They are dropped in LRU order." [bound] (let [

Re: Clojure for financial applications

2010-03-09 Thread Konrad Hinsen
On 09.03.2010, at 14:28, Jonathan Shore wrote: > Thanks. BTW, you may want to consider targeting ejml instead of colt if you > are targeting dense matrix operations. ejml does quite a bit better > performance-wise. Colt does support more matrix types though. Thanks for the pointer, I didn

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

2010-03-09 Thread Per Vognsen
Which is preferable depends on the nature of the changes that your matrices will undergo. For dense linear algebra, it's common for most of a matrix to change with every operation. Hence you won't reap any benefits from the persistence of Clojure's maps. The problem with your first implementation

Re: Two potential map-util functions

2010-03-09 Thread David Santiago
Hi, I actually wrote a sort of counterpart to leafs a while back: (defn- rmap   "Implementation core for map-at-levels."   [func obj lvls lvl]   (let [children-mapped (if (coll? obj) (for [c obj] (rmap func c lvls (inc lvl)))

Re: REPL in a browser

2010-03-09 Thread Jozef Wagner
Thank you. They seem to use java to generate (with GWT) both client-side html and javascript, and server-side REPL. Nice approach. I'm looking forward to the day when one will be able to do all that only with clojure :) We already have a nice clojrue web frameworks, so the only thing that is miss

Problem using count

2010-03-09 Thread Srini
Hi. I am completely new to clojure - my 3rd day or so. Need to go buy a book on the subject. So please help me with a couple of things: Item 1) I have two calls to count. One works, and the other does not. ; counts number of items in collection user=> (count (list 1 2 3 4 "er" 34) ) 6 ; count do

Re: Clojure for financial applications

2010-03-09 Thread Jonathan Shore
Thanks. BTW, you may want to consider targeting ejml instead of colt if you are targeting dense matrix operations. ejml does quite a bit better performance-wise. Colt does support more matrix types though. On Mar 9, 2010, at 3:00 AM, Konrad Hinsen wrote: > On 8 Mar 2010, at 19:22, Jonatha

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread jshore
Thanks The use of (int ...) works, avoiding the dispatch, but it has to be used everywhere there is a variable or literal. Starts getting very ugly and unreadable as expressions get longer.Is there any way to indicate an "int" or "double" literal short of (int 2). Here is the modified func

Re: Help with Vimclojure & cojure-1.2.0-SNAPSHOT

2010-03-09 Thread Mike Mazur
Hi, On Tue, Mar 9, 2010 at 22:55, Meikel Brandmeyer wrote: > On Mar 9, 3:49 pm, Mike Mazur wrote: > >> I tried to compile Vimclojure with clojure-1.2.0-SNAPSHOT, but the >> latest release fails to compile with a NoSuchMethodError. > > Can you be more specific on the failure? What method is tried

Help with Vimclojure & cojure-1.2.0-SNAPSHOT

2010-03-09 Thread Mike Mazur
Hi, I wanted to play with Stuart Sierra's lazytest[1] using Vimclojure. lazytest depends on clojure-1.2.0-SNAPSHOT (so it says in pom.xml), and my Vimclojure (compiled against an older clojure version) doesn't work when launched with clojure-1.2.0-SNAPSHOT on the classpath. I tried to compile Vim

Re: Problem using count

2010-03-09 Thread Srini
Thank you, Meikel and Christian! - Srini On Mar 9, 7:43 am, Christian Vest Hansen wrote: > On Tue, Mar 9, 2010 at 6:26 AM, Srini wrote: > > Hi. I am completely new to clojure - my 3rd day or so. Need to go buy > > a book on the subject. So please help me with a couple of things: > > > Item 1) I

clojure.core/compare and persistent lists

2010-03-09 Thread K.
Hello, It seems it's not possible to use the clojure.core/compare function with persitent lists : (compare '(1 2) '(3 4)) gives the following error "clojure.lang.PersistentList cannot be cast to java.lang.Comparable" Why don't PersistentLists implement Comparable? It works without problems for

Re: Help with Vimclojure & cojure-1.2.0-SNAPSHOT

2010-03-09 Thread Meikel Brandmeyer
Hi, On Mar 9, 3:49 pm, Mike Mazur wrote: > I tried to compile Vimclojure with clojure-1.2.0-SNAPSHOT, but the > latest release fails to compile with a NoSuchMethodError. Can you be more specific on the failure? What method is tried to be called on which object? I have VC running on all clojure

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

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 1:28 AM, Per Vognsen wrote: > Which is preferable depends on the nature of the changes that your > matrices will undergo. For dense linear algebra, it's common for most > of a matrix to change with every operation. Hence you won't reap any > benefits from the persistence of Clo

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Chouser
On Tue, Mar 9, 2010 at 1:44 AM, Timothy Pratley wrote: > 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 dispat

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Stuart Sierra
On Mar 9, 8:59 am, jshore wrote: > I suspect that on recursion a will become an object again and will > then need to be downcasted again as well.   Would be nice to be able > to do: > > (defn fib [#^int v] >         (if (< v 2) >                 v >                 (+ (fib (- v 1)) (fib (- v 2

Re: Problem using count

2010-03-09 Thread Christian Vest Hansen
On Tue, Mar 9, 2010 at 6:26 AM, Srini wrote: > Hi. I am completely new to clojure - my 3rd day or so. Need to go buy > a book on the subject. So please help me with a couple of things: > > Item 1) I have two calls to count. One works, and the other does not. > > ; counts number of items in collect

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Michael Wood
On 9 March 2010 15:59, jshore wrote: [...] > (defn fib [a] >        (let [v (int a)] >                (if (< v (int 2)) >                        v >                        (+ (fib (- v (int 1))) (fib (- v (int 2))) > > I suspect that on recursion a will become an object again and will > then n

Re: Problem using count

2010-03-09 Thread Meikel Brandmeyer
Hi, On Mar 9, 6:26 am, Srini wrote: > ; count does not work. I get an exception. Need to figure out what I > am doing wrong here. > user=> (count (list 23 "3er" oel" 5) ) ^^ unbalanced string > ; could not get it to work for lists. apparently works only for >

Menubar presentation on a Mac

2010-03-09 Thread WoodHacker
Hi All, Can anyone explain how I can get a traditional Mac OS menubar to appear at the top of the screen? Normally I would use (System/setProperty "apple.laf.useScreenMenuBar", "true") and then (.setJMenuBar ...) in my main frame. This does not appear to work. The menu shows up in the frame i

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

2010-03-09 Thread jshore
It looks like the new (deftype ..) may be what I am looking for in terms of binding heterogenous state efficiently. The matrix function was just a test case for how to bind state efficiently. Thanks for all of the responses. On Mar 8, 2:57 pm, Jonathan Shore wrote: > Hi, > > I'm still trying

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread jshore
Hmm, is there a notation to express an int literal. Better yet, clojure should try to infer that if I do (+ v 2) where v was hinted to be "int", 2 should be considered to be an int. The code starts getting really messy: (defn fib [a] (let [v (int a)] (if (< v (int 2))

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

2010-03-09 Thread Per Vognsen
By the way, I also noticed your logic is wrong. It should be (+ (* i ncol) j) rather than (* i j). -Per On Tue, Mar 9, 2010 at 2:57 AM, Jonathan Shore wrote: > Hi, > I'm still trying to work out the best way to deal with operations on > heterogenous data in clojure.   I have a complex applicatio

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

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 2:41 AM, Per Vognsen wrote: > By the way, I also noticed your logic is wrong. It should be (+ (* i > ncol) j) rather than (* i j). > > -Per Thanks -- I was just trying to explore how to deal with heterogeneous data. No plans to build my own matrix lib. Thanks for spotti

Re: bounded memoize

2010-03-09 Thread Meikel Brandmeyer
Hi again, On Mar 9, 8:51 am, Meikel Brandmeyer wrote: >            (dissoc cache args)) And of course this is also wrong. Bleh. I will clean this up and do a short blog post this evening... Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure

Re: Two potential map-util functions

2010-03-09 Thread Steve Purcell
On 8 Mar 2010, at 13:59, Luka wrote: > Other thing I would like to ask is how can I see what is different in > 40 github clones of clojure.contrib without clicking on every clone? Either: 1. Use the github network browser: http://github.com/richhickey/clojure-contrib/network (use left/ri

Re: Two potential map-util functions

2010-03-09 Thread cageface
On Mar 9, 12:09 am, Meikel Brandmeyer wrote: > How about this? > > (defn leafs >   ... This should be leaves, not leafs, right? Another one of those weird irregular English plurals. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Re: Clojure for financial applications

2010-03-09 Thread Constantine Vetoshev
On Mar 8, 11:50 am, Jonathan Shore wrote: > How would I encapsulate this into a data structure to be passed into > functions efficiently?    I could use a map of symbols to various structures, > but that would be inefficient in access and memory.   I could bind into a > closure but then how do

Re: Clojure for financial applications

2010-03-09 Thread Volkan YAZICI
On Mar 8, 8:22 pm, Jonathan Shore wrote: > It is a shame to have to dive down to Java or native (perhaps with the > exception of some of the massive numerical libraries one does not want to > rewrite). I'm hoping to use Clojure or something like clojure as a complete > replacement. Shame? Isn'

Re: Visual Studio plugin

2010-03-09 Thread mmwaikar
Is it possible to write a plug-in in Clojure CLR? And if it is, would you prefer it in Clojure CLR or C# is fine? Also do you want both REPL and syntax highlighting for clj files in Visual Studio? Thanks, Manoj. On Mar 8, 2:17 pm, Eric Thorsen wrote: > Is there/is anyone working on/is anyone int

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Richard Newman
I suspect that on recursion If you use plain function-calling recursion, yes. If you use (loop ... recur...) then (IIRC) locals are not boxed (as well as saving stack). Also bear in mind that JIT will come into play here; after a few tens of thousands of arithmetic ops, the common path wil

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 1:19 PM, Richard Newman wrote: >> I suspect that on recursion > > If you use plain function-calling recursion, yes. If you use (loop ... > recur...) then (IIRC) locals are not boxed (as well as saving stack). > > Also bear in mind that JIT will come into play here; after a f

Re: Visual Studio plugin

2010-03-09 Thread mmwaikar
Forgot to ask the below mentioned questions earlier - Which version of Visual Studio are you targeting - 2008 or 2010? Do you have a development road-map for your plug-in features? Thanks, Manoj. On Mar 9, 1:05 pm, mmwaikar wrote: > Is it possible to write a plug-in in Clojure CLR? And if it is

Re: clojure.core/compare and persistent lists

2010-03-09 Thread Mark Engelberg
My recollection is that when I posted this question several months ago, Rich's response was that there was no particular reason that PersistentLists don't implement Comparable, other than that it hadn't been done yet. So I assume a patch is welcome on this, but no one has stepped forward to do it

Re: symbolmacro tests fail under 1.3.2-SNAPSHOT

2010-03-09 Thread Mark Derricutt
Running late for work, but quickly, the plugin searches for namespaces and generates a run-test.clj file looking like: http://gist.github.com/326972 which is run. Interesting, just looking at that I see for some reason "(require 'clojure.contrib.test-macro-utils)" is duplicated (and also duplica

Re: bounded memoize

2010-03-09 Thread Eugen Dück
I totally agree, having different eviction strategies would be great and having memoizers with max capacities in clojure.contrib would probably be useful to a lot of developers. Also, a memory sensitive memoizer (using soft references?) would be nice. :) On Mar 9, 4:51 pm, Meikel Brandmeyer wrot

Re: apply-ing Java methods

2010-03-09 Thread Michael Gardner
On Mar 8, 2010, at 1:06 PM, Nurullah Akkaya wrote: > Using this, > > http://paste.lisp.org/display/67182 > > would allow you to do, > > (let [config {:str "fred" :beg 2 :end 3}] > (apply (jfn 'substring) (map config [:str :beg :end]))) That's quite nice. Thanks! -- You received this message

Re: apply-ing Java methods

2010-03-09 Thread Michael Gardner
On Mar 8, 2010, at 11:20 PM, Michał Marczyk wrote: > It's simple to write this way... And if you provide type hints, I'd > expect the resulting function to be quite performant. If you don't > care about that, here's a flexible alternative using eval: > > user> (defmacro methodfn [name] >`

call java main from clojure

2010-03-09 Thread TimDaly
I searched the archives and google but cannot find an example. How do I call main? packge thefoo; public class Foo { public static void main(String[] args) { System.out.println(args[0]); } } I tried (import '(thefoo Foo)) (. Foo (thefoo/main ["test"])) java.lang.ClassCastException: cloj

Re: Menubar presentation on a Mac

2010-03-09 Thread igorrumiha
On Mar 9, 2:57 pm, WoodHacker wrote: > Hi All, > > Can anyone explain how I can get a traditional Mac OS menubar to > appear at the top of the screen? > > Normally I would use  (System/setProperty > "apple.laf.useScreenMenuBar", "true") and then > (.setJMenuBar ...) in my main frame. > > This does

Re: call java main from clojure

2010-03-09 Thread Brendan Ribera
You need to turn that argument into a genuine Java array like so: (Foo/main (into-array ["yay"])) On Tue, Mar 9, 2010 at 1:15 PM, TimDaly wrote: > I searched the archives and google but cannot find an example. > How do I call main? > > packge thefoo; > > public class Foo { > public static voi

Re: Two potential map-util functions

2010-03-09 Thread Rick Moynihan
On 9 March 2010 08:09, Meikel Brandmeyer wrote: > Hi, > > On Mar 8, 2:59 pm, Luka wrote: > >> (defn leafs [m] >>   (loop [vs (vals m), accum []] >>     (if (empty? vs) >>       accum >>       (let [v (first vs)] >>         (if (map? v) >>           (recur (rest vs) (into accum (leafs v))) >>    

Re: enclojure install killed netbeans 6.8

2010-03-09 Thread Mark Nutter
On Sun, Mar 7, 2010 at 6:44 PM, strattonbrazil wrote: > 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 me

Re: bounded memoize

2010-03-09 Thread Meikel Brandmeyer
As threatened here a writeup. For this thread the Summary section is probably most interesting. http://kotka.de/blog/2010/03/The_Rule_of_Three.html#summary Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Armando Blancas
By listing the code above you've shown why the default must be so, since calling your function with any of those types will "just work" (at least before an stack overflow), which of course can't be done with primitive types. For an untyped language with a worry-free numeric abstraction, this seems

Re: bounded memoize

2010-03-09 Thread Michał Marczyk
On 9 March 2010 23:17, Meikel Brandmeyer wrote: > As threatened here a writeup. For this thread the Summary section is > probably most interesting. > > http://kotka.de/blog/2010/03/The_Rule_of_Three.html#summary > > Sincerely > Meikel In the way of early feedback -- that's looks super neat! I've

Re: Two potential map-util functions

2010-03-09 Thread Michał Marczyk
On 9 March 2010 22:58, Rick Moynihan wrote: > There a parity between this and clojure.contrib.seq-utils/flatten > (which doesn't work with maps)...  So how about this lazy non stack > consuming alternative? > > (defn leaves [m] > (filter >  (complement map?) >  (rest (tree-seq map? #(vals %) >    

Clojure / Lisp Developers job listings

2010-03-09 Thread Will Fitzgerald
Hello, I maintain a (free) listing of Lisp and Clojure jobs at lispjobs.wordpress.com If you have a Clojure job you'd like to advertise, please send it to one of the addresses found on the About page: http://lispjobs.wordpress.com/about/ Will Fitzgerald -- You received this message because yo

Re: call java main from clojure

2010-03-09 Thread Daniel Solano Gómez
Hello, On Tue, Mar 09, 2010 at 01:15:28PM -0800, TimDaly wrote: > I searched the archives and google but cannot find an example. > How do I call main? > > packge thefoo; > > public class Foo { > public static void main(String[] args) { > System.out.println(args[0]); > } > } > > I tried

What's an idiomatic translation of this CL data structure?

2010-03-09 Thread Mike K
In PAIP section 2.3, Norvig gives an example of a generative grammar: ;; common lisp (defparameter *simple-grammar* '((sentence -> (noun-phrase verb-phrase)) (noun-phrase -> (Article Noun)) (verb-phrase -> (Verb noun-phrase)) (Article -> the a) (Noun -> man ball woman table)

Re: What's an idiomatic translation of this CL data structure?

2010-03-09 Thread Meikel Brandmeyer
Hi, On Mar 10, 6:47 am, Mike K wrote: > (defparameter *simple-grammar* >   '((sentence -> (noun-phrase verb-phrase)) >     (noun-phrase -> (Article Noun)) >     (verb-phrase -> (Verb noun-phrase)) >     (Article -> the a) >     (Noun -> man ball woman table) >     (Verb -> hit took saw liked)) >