Re: simple journal-based persistenсe for Clojure

2009-12-05 Thread John Harrop
On Fri, Dec 4, 2009 at 7:40 PM, Luc Préfontaine lprefonta...@softaddicts.ca wrote: I was about to say that. There's no need for the id's to be contiguous, only to get them to grow to preserve ordering. If you can find a way in your design to increment the atom each time a transaction is

Re: Generalizing - -

2009-12-05 Thread John Harrop
On Fri, Dec 4, 2009 at 2:49 PM, Richard Newman holyg...@gmail.com wrote: The problem is that it is an unreasonably high barrier to entry. There MUST be an electronic-only way (and it must not require a cell phone, CC#, c.) if the full potential of this community is to be unleashed upon

Re: Generalizing - -

2009-12-04 Thread John Harrop
On Thu, Dec 3, 2009 at 10:41 AM, Stephen C. Gilardi squee...@mac.comwrote: On Dec 3, 2009, at 10:31 AM, Roman Roelofsen wrote: Are there any plans to add -$ to core or contrib? The rules on contrib are that the work must be original to the author. Even with Andrew's disclaimer that it be

Re: simple journal-based persistenсe for Clojure

2009-12-04 Thread John Harrop
On Thu, Dec 3, 2009 at 6:31 PM, Sergey Didenko sergey.dide...@gmail.comwrote: Well, I'm not fluent with git yet. I'll create the github project, that can not be hard. In comparison with Prevayler, the persister does not block the reads, because it relies on Clojure STM. However it blocks

Re: Getting Started in Mac OS X Snow Leopard

2009-12-04 Thread John Harrop
On Fri, Dec 4, 2009 at 4:41 AM, Lauri Pesonen lauri.peso...@iki.fi wrote: 2009/12/2 Matthew Williams matthew.d.willi...@gmail.com: Using the Cocoa build of Emacs 23 (http://www.emacsformacosx.com) I was able to get up and running extremely quickly with Technomancy's swank-clojure install.

Re: Generalizing - -

2009-12-04 Thread John Harrop
On Fri, Dec 4, 2009 at 6:51 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 4 Dez., 05:17, John Harrop jharrop...@gmail.com wrote: The rules on contrib are that the work must be original to the author. Even with Andrew's disclaimer that it be considered public domain, he would still

Re: Generalizing - -

2009-12-04 Thread John Harrop
On Fri, Dec 4, 2009 at 8:57 AM, Miron Brezuleanu mbr...@gmail.com wrote: On Fri, Dec 4, 2009 at 2:33 PM, John Harrop jharrop...@gmail.com wrote: The problem is that it is an unreasonably high barrier to entry. There MUST be an electronic-only way (and it must not require a cell phone, CC

Re: Minimum value in a vector

2009-12-02 Thread John Harrop
On Wed, Dec 2, 2009 at 5:43 PM, Don josereyno...@gmail.com wrote: I am having difficulty approaching this problem. I'm not sure if it can be done in one swoop, or requires a few steps. I have 5 vectors as such: a [2 4 6 7] b [1 3 9 2] c [2 4 5 6] d [6 1 3 8] e [4 8 2 1] And I want to

Re: Query blobs in clojure.contrib.sql?

2009-12-01 Thread John Harrop
On Mon, Nov 30, 2009 at 9:57 PM, Base basselsm...@gmail.com wrote: Hi I have a database that has a table with complex java objects stored in a binary field. In java i would do something like: protected Object read(byte[] buf){ Object obj = null; if (buf==null) return obj;

Re: Clojure as a first programming language?

2009-12-01 Thread John Harrop
On Tue, Dec 1, 2009 at 8:30 PM, Alex Osborne a...@meshy.org wrote: Clojure would be challenging language to start with, as (all?) the books and documentation are aimed at people who are already programmers. But if you like a challenge then perhaps that's even a good thing. If you're already

Re: reduce with-precision using BigDecimal

2009-11-30 Thread John Harrop
On Mon, Nov 30, 2009 at 7:07 AM, Joseph Smith j...@uwcreations.com wrote: setScale returns a new BigDecimal with a given scale, it does not change the original value. I did not claim otherwise. The effect of with-precision is like an implicit (.setScale foo) around every BigDecimal foo, only

One benefit of having a REPL

2009-11-28 Thread John Harrop
One benefit of having a REPL: it makes regular expressions usable. So easy to test and tweak your RE compared to the traditional compile/test/debug cycle! I never even bothered with the java.util.regex package before Clojure as it was too painful to use. -- You received this message because you

Re: A Clojure Highlife

2009-11-27 Thread John Harrop
On Thu, Nov 26, 2009 at 4:37 AM, Chris Jenkins cdpjenk...@gmail.com wrote: (defn flip-cell [b x y] (let [row (nth b y) cell (nth row x) new-cell (- 1 cell) new-row (assoc row x new-cell)] (assoc b y new-row))) (defn flip-cell [b x y] (update-in b [y x] #(- 1 %))) :) --

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 8:45 AM, Stefan Kamphausen ska2...@googlemail.comwrote: Why? Well because #^ attaches the metadata to the next read form. What's the next read form? It's 'greet. But in fact 'greet is just sugar for (quote greet). So we're actually affixing the metadata to a

Re: roll call of production use?

2009-11-27 Thread John Harrop
We're maintaining a large database of tagged images and had a need to perform fuzzy search of the database. The existing search tool takes exact queries only. So it was necessary to hack up a little tool to sit between the query source and the engine and transform the query into a fuzzy query. You

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman holyg...@gmail.com wrote: Maybe this ought to be fixed; i.e., if the reader sees #^{meta} 'foo it applies the metadata to foo first, then quotes it, resulting in the same thing as (quote #^{meta} foo). Why introduce that special case, when

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 1:23 PM, John Harrop jharrop...@gmail.com wrote: On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman holyg...@gmail.comwrote: Maybe this ought to be fixed; i.e., if the reader sees #^{meta} 'foo it applies the metadata to foo first, then quotes it, resulting

Re: Atomic reloads and snapshots of namespaces

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 7:48 PM, André Thieme splendidl...@googlemail.comwrote: Let‘s say we have the functions A, B, C, D, E, F and G. A is calling B, B is calling C, C is calling D, and so on. Now a request R1 comes in, function A is called and this chain continues to, say, E. Now a

Re: Recursions under lazy-seq - how does it work?

2009-11-25 Thread John Harrop
On Wed, Nov 25, 2009 at 12:40 PM, Gabi bugspy...@gmail.com wrote: Very interesting indeed. I am not sure I understand completely, but by intuition I presume that the recursive call actually creates a new heap allocated LazySeq (with the function definition inside) . Not quite; it creates a

Re: roll call of production use?

2009-11-24 Thread John Harrop
On Tue, Nov 24, 2009 at 1:04 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Nov 24, 6:06 am, John Harrop jharrop...@gmail.com wrote: Oh, I have no problem with making money by using open source software, when it's done in the manner that companies like Red Hat do it. It's the use

Re: problem with resolve

2009-11-24 Thread John Harrop
On Tue, Nov 24, 2009 at 6:01 AM, kony kulakow...@gmail.com wrote: Hi, I found that resolve does not work correctly (I guess) when it is called from other thread than main: e.g. let define (def zz 123) and afterwords call: (.start (new Thread #(println (resolve 'zz for me it

Re: Deep deref

2009-11-23 Thread John Harrop
On Mon, Nov 23, 2009 at 4:34 PM, Sergey Didenko sergey.dide...@gmail.comwrote: Hi, Andre, Danny's first approach is about syncing only on the root object, so that every piece of data is behind one deref: (def root (ref {:persons [ ... no other refs here... ])) This approach is simpler to

Re: roll call of production use?

2009-11-23 Thread John Harrop
On Mon, Nov 23, 2009 at 8:35 PM, Phlex ph...@telenet.be wrote: i'd be interested to hear who has successfully used clojure in production. Hello, 1- We have this license server, used to control the use of a professional software (this one written using delphi). What are the ethics of

Re: roll call of production use?

2009-11-23 Thread John Harrop
On Mon, Nov 23, 2009 at 9:47 PM, Richard Newman holyg...@gmail.com wrote: 1- We have this license server, used to control the use of a professional software (this one written using delphi). What are the ethics of using an open source product like Clojure to implement DRM restrictions for

Re: Oh, yeah, transients are fast!

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 6:05 AM, Michael Wood esiot...@gmail.com wrote: You've got some kind of system problem confounding your results, I'll bet. It got slower? One test actually hung? My suspicion, of course, lies with the emacs environment you've just confessed to using. Half the

Re: positions

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 7:54 AM, Emeka emekami...@gmail.com wrote: John, You should have added that you code came from Programming Clojure. It didn't. If it's the same as, or closely similar to, code from there, it's entirely coincidental. In Clojure there's usually several ways to do

Re: leiningen - a Clojure build tool

2009-11-22 Thread John Harrop
How is it pronounced anyway, at the start? LINE... or LANE...? -- 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

Re: How to make this a non-reflecting call?

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 12:55 PM, David Brown cloj...@davidb.org wrote: java.nio.channels.FileChannel contains some .write methods: [27] write : int (ByteBuffer) [28] write : int (ByteBuffer,long) [29] write : long (ByteBuffer[]) [30] write : long (ByteBuffer[],int,int) I have an array of

Re: Monad problems: finding an m-zero

2009-11-22 Thread John Harrop
Is there an explanation of monads out there that doesn't require the reader to know Haskell to understand it? One that's generic to any FP-capable language? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Does a standard function exist that acts like assoc except it applies fns to vals

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 4:32 PM, samppi rbysam...@gmail.com wrote: Does a function that does this: (vary coll :x fn-x, :y fn-y) ; Equivalent to (assoc coll :x (fn-x (:x coll)), :y (fn-y (:y coll))) exist in the core or contrib APIs? I'm surprised that I can't find any. It's a very

Re: Monad problems: finding an m-zero

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 4:25 PM, Martin DeMello martindeme...@gmail.comwrote: On Mon, Nov 23, 2009 at 2:40 AM, John Harrop jharrop...@gmail.com wrote: Is there an explanation of monads out there that doesn't require the reader to know Haskell to understand it? One that's generic to any FP

One place where interop needs improvement

2009-11-21 Thread John Harrop
One place where interop needs improvement: imports. This is ridiculous: #CompilerException java.lang.ClassNotFoundException: java.awt (NO_SOURCE_FILE:0) sandbox= #CompilerException java.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to clojure.lang.Symbol

Re: tree-shaking a jarred Clojure app?

2009-11-21 Thread John Harrop
On Sat, Nov 21, 2009 at 8:30 PM, David Brown cloj...@davidb.org wrote: On Fri, Nov 20, 2009 at 06:37:18PM +, Jim Downing wrote: I might have misunderstood, but isn't the problem the same as in Java; you can't know from a static analysis which classes are going to be loaded? Except that

Re: Weird Java Interop Behaviour

2009-11-21 Thread John Harrop
On Sat, Nov 21, 2009 at 8:47 PM, David Brown cloj...@davidb.org wrote: On Fri, Nov 20, 2009 at 03:54:45PM -0800, Mike Hinchey wrote: It's the . special form that makes the difference. In (. System (getProperty)), the dot interprets System as a class and looks for a static method (at

Re: tree-shaking a jarred Clojure app?

2009-11-21 Thread John Harrop
On Sat, Nov 21, 2009 at 8:57 PM, David Brown cloj...@davidb.org wrote: On Sat, Nov 21, 2009 at 08:42:26PM -0500, John Harrop wrote: Are you talking about binding things like String.class to vars referenced by symbols like String? Not just String.class, every single class referenced

Re: tree-shaking a jarred Clojure app?

2009-11-21 Thread John Harrop
On Sat, Nov 21, 2009 at 11:21 PM, David Brown cloj...@davidb.org wrote: On Sat, Nov 21, 2009 at 11:14:52PM -0500, John Harrop wrote: 1 second instead of 1/6 of a second. Yeah, like users will notice that difference in startup times. :) I'm not actually complaining, but I do notice every

Re: One place where interop needs improvement

2009-11-21 Thread John Harrop
On Sat, Nov 21, 2009 at 11:43 PM, Alex Osborne a...@meshy.org wrote: John Harrop wrote: On Sat, Nov 21, 2009 at 9:03 PM, Alex Osborne a...@meshy.org (:import package1 class class class) (:import package2 class class) I am. Especially since the latter already works. Alternatively

Re: tree-shaking a jarred Clojure app?

2009-11-20 Thread John Harrop
On Fri, Nov 20, 2009 at 2:28 PM, Richard Newman holyg...@gmail.com wrote: But I should be able to know, through class inspection, whether my 'main' program depends on a class which uses, say, the clojure.zip namespace, and decide whether or not to include it. Or so I am wondering. There

Re: Oh, yeah, transients are fast!

2009-11-20 Thread John Harrop
On Fri, Nov 20, 2009 at 5:16 PM, Raoul Duke rao...@gmail.com wrote: Try with a 1.6 JVM... wow. it actually got worse than when i was using 1.5. ... so much for hallowed write-once-run-the-same-anywhere-ish of the jvm, d'oh. Clojure 1.1.0-alpha-SNAPSHOT user= (load-file /tmp/test.clj)

Re: swap two elements in an arbitrary collection

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 4:31 AM, Lauri Pesonen lauri.peso...@iki.fi wrote: (clojure.walk/macroexpand-all '(cond (even? 2) :foo (odd? 2) :bar :else :baz)) (if (even? 2) :foo (if (odd? 2) :bar (if :else :baz nil))) Eeeuw. Perhaps the cond macro should check if the last condition is

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 1:23 PM, Sean Devlin francoisdev...@gmail.comwrote: Try clojure.contrib.seq-utils :) As a learning exercise, I'd recommend re-writing it to be lazy. Your version is eager because it uses loop. In order to make it lazy, you'd want to construct a lazy-seq. See the

Re: unsubscribe

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 2:39 PM, Timothy McDowell tmcdow...@gmail.comwrote: unsubscribe Interesting. Most mailing lists I subscribe to get one of these a week, or even a day. This is the first missent unsubscribe the clojure list's had in months. -- You received this message because you are

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin francoisdev...@gmail.comwrote: That's why there are two separate functions do do what you suggest user=(interleave [1 2 3 4] [1 2 3 4]) (1 1 2 2 3 3 4 4) user= (concat [1 2 3 4] [1 2 3 4]) (1 2 3 4 1 2 3 4) Poor choice of example. I think he

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:15 PM, Alex Osborne a...@meshy.org wrote: John Harrop wrote: On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin francoisdev...@gmail.com mailto:francoisdev...@gmail.com wrote: That's why there are two separate functions do do what you suggest user

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:51 PM, Alex Osborne a...@meshy.org wrote: John Harrop wrote: This is just (sort (concat [1 2 3 4 5 6 7] [3 2 7])) though. I think he also wants the original order of the first input coll to be preserved, though. Sort wouldn't do that. Hmmm.. that's

Re: take repeatedly alternative?

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 9:17 PM, Mark Triggs mark.h.tri...@gmail.comwrote: A good example is: (take 10 (repeatedly #(rand-int 100))) to get a bunch of random integers. I actually quite like this idiom, even if there's a bit of ascii involved :) Why not abstract it some, though? (defn

Re: A typo on the website about vars

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 8:40 AM, Jacek Laskowski ja...@laskowski.net.plwrote: Hi, I'm wondering what part is missing in which provides a means for nested contexts to communicate with code before it the call stack. at http://clojure.org/vars? I think the wording is broken at the end.

Re: No names with trailing % allowed but with a leading one?

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin francoisdev...@gmail.comwrote: I *THINK* what is meant by the non-numeric is anything that matches #[a-zA-z] Nah, it'll be anything that's allowed elsewhere AND is not a digit. -- You received this message because you are subscribed to the

Re: No names with trailing % allowed but with a leading one?

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 2:17 PM, Stefan Kamphausen ska2...@googlemail.comwrote: Hi, On Nov 17, 8:12 pm, John Harrop jharrop...@gmail.com wrote: On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin francoisdev...@gmail.com wrote: I *THINK* what is meant by the non-numeric is anything

Re: A typo on the website about vars

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 2:31 PM, Chouser chou...@gmail.com wrote: On Tue, Nov 17, 2009 at 8:40 AM, Jacek Laskowski ja...@laskowski.net.pl wrote: I'm wondering what part is missing in which provides a means for nested contexts to communicate with code before it the call stack. at

Re: def a generated symbol?

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 3:59 PM, nchubrich nicholas.chubr...@gmail.comwrote: How do you def a symbol that you make using (symbol)? I.E. if I try to do (def (symbol x) 2) I get: java.lang.Exception: Second argument to def must be a Symbol. (And why does it say the \second argument must be a

Re: def a generated symbol?

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 4:22 PM, Chouser chou...@gmail.com wrote: On Tue, Nov 17, 2009 at 4:11 PM, John Harrop jharrop...@gmail.com wrote: On Tue, Nov 17, 2009 at 3:59 PM, nchubrich nicholas.chubr...@gmail.com wrote: How do you def a symbol that you make using (symbol)? I.E. if I try

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 5:06 PM, Sean Devlin francoisdev...@gmail.comwrote: Heh. Learn something new every day. This also works (into {} (System/getProperties)) And I'd much prefer it. Passing a mutable Java map around to functions that expect a map but assume it will never change out

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread John Harrop
On Tue, Nov 17, 2009 at 6:24 PM, Richard Newman holyg...@gmail.com wrote: I wonder if perhaps (into {} a-java-map) should work but no other substitutions of a potentially-mutable map for a Clojure map. Baby, bathwater. Making a persistent map out of a Java map is expensive. Not everything

Re: Datatypes and Protocols - early experience program

2009-11-16 Thread John Harrop
On Mon, Nov 16, 2009 at 2:16 AM, Michael Wood esiot...@gmail.com wrote: This is what I get with or without rlwrap from the command line. No IDE or anything like that: Clojure 1.1.0-alpha-SNAPSHOT user= ; some comment user= #! something (println blah) blah nil user= i.e. the same as

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-16 Thread John Harrop
On Sun, Nov 15, 2009 at 8:28 PM, Rich Hickey richhic...@gmail.com wrote: On Sun, Nov 15, 2009 at 4:49 AM, ajuc aju...@gmail.com wrote: On 15 Lis, 00:21, John Harrop jharrop...@gmail.com wrote: On Sat, Nov 14, 2009 at 3:03 PM, ajuc aju...@gmail.com wrote: I have to install java one more

Re: A Clojure Highlife

2009-11-16 Thread John Harrop
On Mon, Nov 16, 2009 at 12:42 AM, solussd solu...@gmail.com wrote: I just finished an implementation of the Conway's Game of Life derivative, Highlife, in Clojure. It consists of a simple swing GUI and makes good use of Refs for coordinating grid updates. A more detailed description, source,

Re: Remote REPL problem when connecting to RMI Client VM

2009-11-16 Thread John Harrop
On Mon, Nov 16, 2009 at 7:20 PM, Kent squi...@aol.com wrote: Hi, I am trying to use clojure to implement a plugin for some vendor supplied software. Here is a little background on the vendor supplied software. It expects me to implement a particular interface and then put the jar file

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 4:49 AM, ajuc aju...@gmail.com wrote: On 15 Lis, 00:21, John Harrop jharrop...@gmail.com wrote: On Sat, Nov 14, 2009 at 3:03 PM, ajuc aju...@gmail.com wrote: I have to install java one more time, when I try to start java - server, I get: Error: no `server' JVM

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 8:45 AM, Michael Wood esiot...@gmail.com wrote: 2009/11/14 John Harrop jharrop...@gmail.com: On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman holyg...@gmail.com wrote: I like CL's package support for this kind of situation, where unexported symbols can still

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
Interesting. It looks like Clojure's missing a few obvious optimizations, and is reconstructing the literal structure each time the function is called, or each time the value is used if the literal is directly at point of use. On the other hand, deref of a global is not exactly blindingly fast

Re: Map a list of agents to a list of their values

2009-11-15 Thread John Harrop
On Sat, Nov 14, 2009 at 6:03 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 14.11.2009 um 20:31 schrieb John Harrop: For situations like this, I find it handy to discover what reader-macros are expanding to. This works well: user=(defmacro expand [arg] (println arg)) #'user/expand

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 7:32 PM, Alex Osborne a...@meshy.org wrote: ajuc wrote: I would like to somehow hide the global hilbert-map into my function, but I can't see how to do that. Is this possible? I know that I can just inert literal into my let, but that degrades performance, when

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 8:17 PM, David Brown cloj...@davidb.org wrote: On Sun, Nov 15, 2009 at 04:20:19PM -0500, John Harrop wrote: That's weird. It's not documented anywhere on the site. And it seems to hang the REPL: user= nil #!foo and nothing. Enter doesn't print nil and a fresh

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:45 AM, Mark Engelberg mark.engelb...@gmail.comwrote: On Fri, Nov 13, 2009 at 12:58 AM, Konrad Hinsen konrad.hin...@fastmail.net wrote: Coming from a Python background, I don't think access restrictions are necessary. However, flagging fields as not meant for use by

Re: why a defn- but not a def- ?

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 8:55 AM, Albert Cardona sapri...@gmail.com wrote: On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye stacktra...@gmail.com wrote: Why is there an easy way to def a private function (defn-), but no similarly easy way to def an arbitrary var as private? The way I see it,

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 6:19 AM, ajuc aju...@gmail.com wrote: I would like to somehow hide the global hilbert-map into my function, but I can't see how to do that. Just put the literal directly into the function. Is this possible? I know that I can just inert literal into my let,

Re: Deep deref

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 11:42 AM, André Thieme splendidl...@googlemail.comwrote: Dereferencing *persons* will result in: {Tina #r...@7ae6d: {:name Tina, :age 19, :friends []}, Jeff #r...@125d92c: {:name Jeff, :age 22, :friends []}, Karl #r...@14fa0ef: {:name Karl, :age 20, :friends []}}

Re: Deep deref

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 2:11 PM, John Harrop jharrop...@gmail.com wrote: On Sat, Nov 14, 2009 at 11:42 AM, André Thieme splendidl...@googlemail.com wrote: Dereferencing *persons* will result in: {Tina #r...@7ae6d: {:name Tina, :age 19, :friends []}, Jeff #r...@125d92c: {:name Jeff, :age

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 12:49 PM, Kevin Q kevin.jing@gmail.com wrote: I have a list of agents, each of which has a hasmap state. I want to get a list of values from the list of agents, naturally I used the map function and print the result of the map: (println (map #(@%) agents))

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman holyg...@gmail.com wrote: I like CL's package support for this kind of situation, where unexported symbols can still be reached via foo::bar, at the cost of an obvious code smell. This suggests an alternate fix for the private functions in

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:03 PM, ajuc aju...@gmail.com wrote: I have to install java one more time, when I try to start java - server, I get: Error: no `server' JVM at `F:\Program Files\Java\jre6\bin\server \jvm.dll You need to use the one in F:\Program Files\Java\jdk6 instead. I'm

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 2:51 PM, Kevin Q kevin.jing@gmail.com wrote: Hi, Thanks for the hint. I tried (map deref agents) and it did work. I don't know if this is a bug? Nah, it's just being really sneaky. (fn* [p1__6536] ((clojure.core/deref p1__6536))) Even I didn't notice it

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:24 PM, John Harrop jharrop...@gmail.com wrote: On Sat, Nov 14, 2009 at 2:51 PM, Kevin Q kevin.jing@gmail.com wrote: Hi, Thanks for the hint. I tried (map deref agents) and it did work. I don't know if this is a bug? Nah, it's just being really sneaky

Re: Better documentation and error messages are needed for the ns macro

2009-11-13 Thread John Harrop
On Fri, Nov 13, 2009 at 1:23 PM, Chouser chou...@gmail.com wrote: On Wed, Nov 11, 2009 at 4:24 PM, John Harrop jharrop...@gmail.com wrote: One question: how would Java class imports be dealt with? I think it should be unified: (ns foo (uses java.io :only [File FileInputStream] :as io

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-13 Thread John Harrop
On Fri, Nov 13, 2009 at 6:48 PM, ajuc aju...@gmail.com wrote: Hello. I've tried to translate nice Hilbert-curve-index calculating function to clojure (http://blog.notdot.net/2009/11/Damn-Cool-Algorithms- Spatial-indexing-with-Quadtrees-and-Hilbert-Curves). I've got sth like that: (def

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread John Harrop
On Fri, Nov 13, 2009 at 8:50 PM, Mark Engelberg mark.engelb...@gmail.comwrote: Rich, thanks for the extended explanation of the overlap between the old and new constructs; I found this explanation much clearer than what is currently on the wiki. Basically, the key for me was realizing that

Re: Better documentation and error messages are needed for the ns macro

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 1:12 PM, Stephen C. Gilardi squee...@mac.comwrote: Before: (:refer-clojure :exclude [read]) (:require (clojure.contrib [graph :as graph] [fcase :as fcase]) [clojure.contrib.stream-utils :as su]) (:use [clojure.contrib def except server-socket]

Re: Better documentation and error messages are needed for the ns macro

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 3:54 PM, Laurent PETIT laurent.pe...@gmail.comwrote: 2009/11/11 Andrew Boekhoff boekho...@gmail.com: (:uses [clojure.core :exclude [read]) [clojure.contrib.graph] [clojure.contrib.fcase] [clojure.contrib.stream-utils :as su]

Re: Topological sort

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 2:04 PM, Nick Day nicke...@gmail.com wrote: Hi, I've been trying to implement a topological sort and have been struggling a bit. I have a map of symbol vs collection of symbols like: {a [b c], b [c], c [nil]} which can be read as 'a' depends on 'b' and 'c', 'b'

Re: Gensym collisions can be engineered.

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 10:46 PM, Kevin Tucker tuckerke...@gmail.comwrote: Yeah, sorry, missed that. How does making the gensyms unreadable make things worse for macroexpand than they are in CL? It doesn't. Just worse than they currently are in Clojure. :) -- You received this message

Re: Gensym collisions can be engineered.

2009-11-10 Thread John Harrop
On Mon, Nov 9, 2009 at 10:04 PM, Kevin Tucker tuckerke...@gmail.com wrote: I in CL they can be read but aren't interned in any package so every time you read it you get a different symbol. Yes, I know; I said that myself in the first post. But your first post inspired in me the idea of simply

Re: Vector manipulation problem, possible function for a solution.

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 1:00 AM, Richard Newman holyg...@gmail.com wrote: I have a vector a [ [2 3] [4 5] [6 7] ] And I want to be able to get [2 3 4 5 6 7] user= (reduce into [ [2 3] [4 5] [6 7] ]) [2 3 4 5 6 7] This and another solution have already been posted, but there's also:

Re: Running out of memory when using loop/recur and destructuring

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 7:21 AM, Rich Hickey richhic...@gmail.com wrote: Right - pervasive locals clearing will definitely do the trick here. Interestingly, when I was at Microsoft and asked them about handling this issue for the CLR they stated plainly it wasn't an issue at all - their

Re: Using agents and blocking I/O.

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 10:41 AM, pmf phil.fr...@gmx.de wrote: On Nov 10, 7:07 am, David Brown cloj...@davidb.org wrote: Ok. So, it's the existence of this future-like entity that blocks upon deref until filled is indeed somewhat missing. It's not particularly difficult to implement.

Re: Using agents and blocking I/O.

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 11:41 AM, John Harrop jharrop...@gmail.com wrote: user= (take 10 (p-lazy-seq 3 true (thread-local-rand 10))) (1 2 6 1 5 1 7 8 4 3) This should generate the random numbers on multiple threads, using multiple RNGs. In the limit, on multicore hardware and with a slow

Better documentation and error messages are needed for the ns macro

2009-11-10 Thread John Harrop
So I have (ns foo.bar.baz) and I want to grab clojure.contrib.core/seqable? What do I do? (ns foo.bar.baz (use clojure.contrib.core :only seqable?)) #CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: Boolean (NO_SOURCE_FILE:0) (ns foo.bar.baz (use

Re: Better documentation and error messages are needed for the ns macro

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 9:11 PM, Richard Newman holyg...@gmail.com wrote: (ns foo.bar.baz (:use [clojure.contrib.core :only (seqable?)])) (and thus violates the usual clojure rule of using vectors rather than lists for groupings that are not invocations -- that is, function calls,

Re: Gensym collisions can be engineered.

2009-11-09 Thread John Harrop
On Sun, Nov 8, 2009 at 5:56 PM, Kevin Tucker tuckerke...@gmail.com wrote: This is something that I have been wondering about too. In CL the symbols gensym produces can not be read by the reader so there can be no collision cause the only way to get a handle on the symbol is to create it with

Re: Iterative collections.

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 12:52 PM, Andrew Boekhoff boekho...@gmail.comwrote: Hi. And gives very different results. 'for' iterates over it's sequences in a nested fasion. For your particular example, it will return the sequence from (+ 31 1) (+ 31 2) and so on, and never get to the second

Re: Running out of memory when using loop/recur and destructuring

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 4:31 PM, Rock rocco.ro...@gmail.com wrote: I've been following this thread, and I must say I'm puzzled that Rich hasn't said anything at all about this issue yet. It seems important enough to hear his own opinion. My observation over the past few months is that Rich

Re: ANN: Autodoc for clojure core, first rev

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 4:28 PM, Howard Lewis Ship hls...@gmail.com wrote: It looks very nice ... still I'd love to see something like what clj-doc does (http://github.com/mmcgrana/clj-doc) ... it adds a text field that you can type into and it matches the available names against what you

Re: Consistency of the API

2009-11-09 Thread John Harrop
Even more interesting is the behavior of contains? when passed strings: user= (contains? foo \o) false user= (contains? foo 2) true user= (contains? foo 3) false user= (contains? 'foo 2) false It seems to treat strings as it does vectors, seeing if an index is in bounds or not. It doesn't treat

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 5:50 PM, Alex Osborne a...@meshy.org wrote: Mark Engelberg wrote: 2009/11/9 Tiago Antão tiagoan...@gmail.com: What is the rationale for even? and contains? having different behaviors for the exact same error (ie, one throws the other works fine and just returns

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 8:28 PM, John Harrop jharrop...@gmail.com wrote: Why not: static public Object contains(Object coll, Object key){ if(coll == null) return F; else if(coll instanceof Map) return ((Map) coll).containsKey(key) ? T : F

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 8:41 PM, John Harrop jharrop...@gmail.com wrote: In the meantime, the main thing still missing from Clojure is a convenient queue. Lists and vectors both add and remove efficiently only at one end, and at the same end for add and remove in both cases. Doubly-linked lists

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 8:53 PM, Mark Engelberg mark.engelb...@gmail.comwrote: On Mon, Nov 9, 2009 at 5:41 PM, John Harrop jharrop...@gmail.com wrote: In the meantime, the main thing still missing from Clojure is a convenient queue. What's wrong with clojure.lang.PersistentQueue

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 10:37 PM, Mark Engelberg mark.engelb...@gmail.comwrote: Yes, it's in Clojure 1.0, it just doesn't have a convenient name. So give it a convenient name like this: (def empty-queue clojure.lang.PersistentQueue/EMPTY) and then you're ready to go. conj, peek, pop, into

Re: Converting to TCO

2009-11-08 Thread John Harrop
You have a bug: (defn exp-mod [base exp m] (cond (zero? exp) 1 (even? exp) (mod (Math/sqrt (exp-mod base (/ exp 2) m)) m) :else (mod (* base (exp-mod base (inc exp) m)) m))) should be (defn exp-mod [base exp m] (cond (zero? exp) 1 (even? exp) (mod (Math/sqrt (exp-mod

Re: Michael newbee challange nr 1

2009-11-08 Thread John Harrop
On Sun, Nov 8, 2009 at 7:33 AM, Michael Jaaka michael.ja...@googlemail.comwrote: Hi! How would you solve such problem: I have a collection of pairs (key, value) - [ [ tom 32 ] [ tom 2333 ] [ anne 12 ] [ anne 55 ] ] As you can see keys can occur more than once, also that collection is very

  1   2   3   4   >