Re: super-lazy-seq

2009-06-15 Thread Daniel Lyons
On Jun 14, 2009, at 12:53 PM, James Reeves wrote: > > On Jun 14, 6:32 pm, Wrexsoul wrote: >> I wrote super-lazy-seq because repeatedly can't generate a finite >> sequence. It just spat out >> >> (File1 File2 File3 File4 nil nil nil nil nil nil nil ... > > Well, you could wrap it in take-while:

Re: super-lazy-seq

2009-06-15 Thread James Reeves
On Jun 15, 4:58 am, Wrexsoul wrote: > Eh. That didn't occur to me. It could be combined with the meta-nil > trick, too: > > (defn custom-lazy-seq [genfn] >   (map #(first %) >     (take-while (complement nil?) >       (repeatedly genfn > > where the genfn returns nil for no-next-item and [i

Re: super-lazy-seq

2009-06-15 Thread Daniel Lyons
On Jun 12, 2009, at 7:52 PM, Wrexsoul wrote: > Well, I did it. Made implementing lazy seqs that require stateful > generator functions easy, that is: > > (defn files-and-dirs-recursive [dir] > (super-lazy-seq [stack [(to-file dir)]] >(if-not (empty? stack) > (let [file (first stack) s

Re: Arraylist faster than primitive array?

2009-06-15 Thread evandi
I finally see what warn-on-reflection does. It wasn't working in netbeans, it works in emacs. On Jun 14, 2:48 pm, CuppoJava wrote: > It looks like a case of reflection being used. > I would set *warn-on-reflection* to true, and just check which method > is not being resolved. > > My guess is pr

Dynamically accessing static fields

2009-06-15 Thread James Koppel
I am trying to write a function to simplify working with GridBagConstraints -- that is, instead of writing (let [c (GridBagConstraints.)] (set! (.weightx c) 2.0) (set! (.gridwidth c) GridBagConstraints/REMAINDER) (let [button (JButton. "Hello, world!")] (.setConstraints (.getLayo

Re: Dynamically accessing static fields

2009-06-15 Thread Parth
On Jun 15, 7:08 am, James Koppel wrote: > I am trying to write a function to simplify working with GridBagConstraints > -- that is, instead of writing > > (let [c (GridBagConstraints.)] >     (set! (.weightx c) 2.0) >     (set! (.gridwidth c) GridBagConstraints/REMAINDER) >     (let [button (JB

Re: dosync ref-set and threads coordination problem

2009-06-15 Thread sross
On Jun 14, 12:20 am, vmargioulas wrote: > In the example below 256 clients threads put a byte (0-255) to server- > socket reference var "items", > then connect to server-socket, write the same byte to socket stream > and close the connection. > The server connections threads reads a byte from t

Re: Primitive char Type

2009-06-15 Thread tmountain
Wow, you really got to the bottom of this. Reading your post, it all makes sense, but it leads me to wonder why StringBuilder was designed in such a fashion and why the docs would go so far as to lie about it. Either way, thanks for taking the time to help me out. This community is a big part of w

Re: breaking early from a "tight loop"

2009-06-15 Thread Chouser
On Sun, Jun 14, 2009 at 4:00 AM, Sudish Joseph wrote: > > On Jun 13, 4:17 pm, Laurent PETIT wrote: >> So it really seems to me that the missing abstraction, here, is being >> able to do a reduce over the list of pixels, and being able, from the >> reduction function, to quit the reduction early.

Re: Performance Penalty Converting from Java Code

2009-06-15 Thread tmountain
Thanks for the replies guys. Both solutions outperform the original. The one using unchecked operations is about 60x faster, which is the kind of performance I was hoping for. It's good to see that Clojure has the capacity to do things very quickly. I just need to learn all the tricks to make it d

Universal Date utility

2009-06-15 Thread Sean Devlin
Hey everyone, There have been a couple of threads discussing date utilities in this group. http://groups.google.com/group/clojure/browse_thread/thread/d98e8efd8d5517b2# http://groups.google.com/group/clojure/browse_thread/thread/659503e698ede0b5/9dda25f36f102799?lnk=gst&q=joda#9dda25f36f102799

matlab like clojure

2009-06-15 Thread Bugs
Hi, everyone. I'm a newbie on Clojure and LISP, and I'm interasted in matlab replacement languages. It is just my hobby, but I'm trying to implement a matlab like language extension. I think that Clojure has ability enough to be numerical language like a Matlab or Mathematica. So, I'm finding e

Re: matlab like clojure

2009-06-15 Thread Parth
On Jun 15, 7:23 pm, Bugs wrote: > Hi, everyone. > > I'm a newbie on Clojure and LISP, and I'm interasted in matlab > replacement languages. > It is just my hobby, but I'm trying to implement a matlab like > language extension. > > I think that Clojure has ability enough to be numerical language

Re: matlab like clojure

2009-06-15 Thread Konrad Hinsen
On Jun 15, 2009, at 16:23, Bugs wrote: > I'm a newbie on Clojure and LISP, and I'm interasted in matlab > replacement languages. > It is just my hobby, but I'm trying to implement a matlab like > language extension. > > I think that Clojure has ability enough to be numerical language like > a Mat

Mnesia like?

2009-06-15 Thread Wilson MacGyver
Does clojure have anything like erlang's Mnesia? or is anyone working on such project? I know I can fall back to using JDBC+ various RDBMS, but I was curious if there is something that works like Mnesia. Thanks, Mac -- Omnem crede diem tibi diluxisse supremum. --~--~-~--~~-

Re: dosync ref-set and threads coordination problem

2009-06-15 Thread vmargioulas
Thanks for your reply, you are right, the server close before all clients completed. (i was suppose that dorun waits for the threads results before returning.) Anyway, i was trying to emulate the real problem with no success here. I 'll try to describe it. The clients connect to an extrernal ap

Re: Mnesia like?

2009-06-15 Thread Josh Daghlian
There's always using derby or hsqldb as a backend for Hibernate; and if a dumb distributed (disk-backed) cache is good enough for your purposes then you might try Oracle Coherence, which scales great and is incredibly easy to use but sort of expensive. It doesn't feel nearly as language-native as

Re: Mnesia like?

2009-06-15 Thread Daniel Lyons
On Jun 15, 2009, at 10:02 AM, Wilson MacGyver wrote: > > Does clojure have anything like erlang's Mnesia? or is anyone > working on such > project? I know I can fall back to using JDBC+ various RDBMS, but I > was curious if there is something that works like Mnesia. I don't think there is on

Re: Mnesia like?

2009-06-15 Thread Phil Hagelberg
Daniel Lyons writes: > I might throw up a bit for suggesting this, but you might also want to > look at CouchDB, which uses HTTP to provide a generic JSON "document" > store based on Mnesia. It would probably be easier to interface with > than Erlang directly and ought to have most of the

Re: matlab like clojure

2009-06-15 Thread hoeck
Hi, I've got a simple implementation of the Jacobi-method for approximating the solution of a linear system of equations, maybe your interested in this. (defn jacobi-x-step [m b x i] "Calculate a part of the solution of a jacobi-method step" ;; 1 ;; xi = --- (bi - ( sum aij *

Re: Mnesia like?

2009-06-15 Thread Wilson MacGyver
yea, I thought of couchDB. the nice thing about Mnesia in erlang is that it's completely self-contained. I didn't know if there is such a thing in clojure, or works underway to create one. On Mon, Jun 15, 2009 at 2:20 PM, Phil Hagelberg wrote: > > Daniel Lyons writes: > >> I might throw up a bit

multiple agents yielding flat performance

2009-06-15 Thread tmountain
Having learned about agents recently, I've created a pretty contrived program, which I believed would easily lend itself to parallel processing. The program takes a list of MD5 sums and then does brute force comparison the find the corresponding four character strings they were generated from. The

Re: multiple agents yielding flat performance

2009-06-15 Thread Richard Newman
> I'm testing on a quad-core box, and I'm seeing virtually identical > performance numbers switching between one agent and four agents. I've > also tried larger numbers like 12 agents, but the results are the > same. The load average also stays the same hovering around 1.0, and > the execution tim

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
I've tried this in lieu of the way I was generating the work units. (def work-units (for [x (range 100)] "88148433eeb5d372c0e352e38ac39aca")) I know that for is still lazy, so I did this after the binding of work- buckets: (println work-buckets) ; yielded expected result ((88148433eeb5d372c0e35

Re: multiple agents yielding flat performance

2009-06-15 Thread Richard Newman
Try doall: http://clojure.org/api#toc216 --~--~-~--~~~---~--~~ 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 -

Re: Mnesia like?

2009-06-15 Thread Stuart Sierra
On Jun 15, 12:02 pm, Wilson MacGyver wrote: > Does clojure have anything like erlang's Mnesia? or is anyone working on such > project? I know I can fall back to using JDBC+ various RDBMS, but I > was curious if there is something that works like Mnesia. I've dreamed about some kind of "durable R

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
Completely omitting work-buckets and spawn-agents, I've replaced with the following, but the CPU still sits at 100% usage, and the run time is still ~15 seconds. (def work-units (doall (for [x (range 15)] "88148433eeb5d372c0e352e38ac39aca"))) (def agents [(agent work-units) (agent wo

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
Nevermind, kindly ignore my last post ;-) You called it. The map inside my decode function returns a lazy seq, and it was being accessed on-demand by the doseq towards the end of the program. To make matters worse, I was consuming the agents in a serial fashion completely eliminating any parallel

Re: multiple agents yielding flat performance

2009-06-15 Thread Richard Newman
> After the change, it runs in 5 seconds on four cores as opposed to > 15 seconds on a single > core. Thank you for taking the time to help me with this. It's been a > learning experience. Great news! Happy to help. This stuff is pretty new to me, too :) --~--~-~--~~~--

always-merge-with

2009-06-15 Thread kyle smith
I needed the functionality of merge-with, but need f applied in all cases. This version only works for 2 maps, but you can use reduce for more maps. This lets me incrementally build up maps whose vals can be seqs. (defn always-merge-with [f amap bmap] "Like merge-with, but always applies f"

Runtime Compilation of Clojure from Android

2009-06-15 Thread George Jahad
Remco van't Veer has done a lot of great working porting Clojure to Android, but one thing remains missing, runtime compilation which would allow a fully functional Repl. The problem is that the Android VM doesn't use standard Java class files but rather Android specific ones. There is a host-si