Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread John Harrop
On Tue, Oct 27, 2009 at 2:17 PM, Emeka wrote: > John, > On Tue, Oct 27, 2009 at 6:10 PM, John Harrop wrote: > >> On Tue, Oct 27, 2009 at 1:39 PM, Emeka wrote: >> >>> On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson >>> wrote: >>> >>>&g

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread John Harrop
On Tue, Oct 27, 2009 at 2:33 PM, Emeka wrote: > John, > > That is why I asked that question because I figured out that the problem > has nothing to do with Vector but with #() read macro. I wanted to correct > the impression that the problem was from Vector. That was correct. I just wanted to a

Re: take-nth

2009-10-28 Thread John Harrop
On Tue, Oct 27, 2009 at 9:50 PM, Josh Daghlian wrote: > The docs could use clarification, but it looks like take-nth is doing > what's advertised. > I don't see anything odd about the behavior of take-nth in regards to indexing: user=> (take 10 (take-nth 1 (range 100))) (0 1 2 3 4 5 6 7 8 9) us

Re: take-nth

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 4:20 AM, Timothy Pratley wrote: > On Oct 28, 6:04 pm, John Harrop wrote: > > It always starts with the zeroth item and skips ahead however many > elements > > were specified. The second argument is the n in > > "every nth item". (You c

Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
and it's not hard to guess, and then prove, why: user=> (defn fibs [] (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))) #'user/fibs user=> (take 10 (fibs)) (1 1 2 3 5 8 13 21 34 55) user=> (.hashCode 12) 12 user=> (.hashCode "foo") 101574 user=> (.hashCode (take 10 (fibs))) -1796812414 user=>

Re: Constructing Java Interop calls

2009-10-28 Thread John Harrop
2009/10/28 Tiago Antão > > Hi, > > Sorry for the newbie question, but I am trying to understand how to > construct and call java dynamically from clojure. > As an example, imagine that there is a bean property called "Bla" and > one wants to set Bla to 1 on object x, which has that property. > So

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 12:05 PM, Mark Engelberg wrote: > This is basically the behavior I would expect. I expect that when I > put two sequences into a set, they are compared for equality, which is > clearly impossible if they are infinite. I don't think I'd want some > automatically truncated

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 3:56 PM, Tim Clemons wrote: > How about having hashCode() on infinite sequences drill down into the > composite infinite sequences until we arrive at the generative > function? Given that values are generated on demand, the generators > themselves can be compared. This

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 9:35 PM, Alex Osborne wrote: > John Harrop wrote: > > Probably the seq .hashCode should consider only the first N elements > > for some maximum N and if two longer (or even infinite) sequences > > collide so be it. > > I strongly disagree. Ch

Re: Constructing Java Interop calls

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 10:15 PM, Alex Osborne wrote: > > Tiago Antão wrote: > > Again, the point here is to be able to construct method names (full > > call signatures, really) on runtime. > > > > I am lost. As in newbie clueless :( > > As others have suggested you need to use either Java's refl

Re: Scientific computing

2009-10-29 Thread John Harrop
On Thu, Oct 29, 2009 at 4:49 AM, Konrad Hinsen wrote: > On 28 Oct 2009, at 22:21, Rock wrote: > > I honestly prefer your first case scenario. Seems much more efficient, > > less resource-consuming, and just straightforward. But I really would > > like to know what your preference is. If you had to

Re: Periodic tasks

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 12:05 AM, Stefan Arentz wrote: > What is a good and simple way to run periodic tasks in Clojure? I need > to run a simple function every couple of minutes. And make sure that > if it throws an exception that it won't kill the periodic task. > > I come from a Spring world w

Implementation of zipmap

2009-10-30 Thread John Harrop
What's up with this? (defn zipmap "Returns a map with the keys mapped to the corresponding vals." [keys vals] (loop [map {} ks (seq keys) vs (seq vals)] (if (and ks vs) (recur (assoc map (first ks) (first vs)) (next ks) (nex

Re: Implementation of zipmap

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 11:37 AM, Chouser wrote: > On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: > > > > John Harrop wrote: > >> Was something wrong with this?: > >> > >> (defn my-zipmap > >> "Returns a map with the k

Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
user=> (def x (int-array 3)) #'user/x user=> x [0, 0, 0] user=> (def y (seq x)) #'user/y user=> (first y) 0 user=> (aset x 1 3) 3 user=> x [0, 3, 0] user=> (second y) 3 user=> (aset x 0 2) 2 user=> x [2, 3, 0] user=> (first y) 2 Here, (first y) returned first 0, then 2 without y being rebound in b

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 12:40 PM, John Harrop wrote: > (defn lazy-array-seq > ([arr] > (lazy-array-seq arr 0)) > ([arr from-idx] > (lazy-array-seq arr 0 (count arr))) > ([arr from-idx end-idx] > (if-not (= from-idx end-idx) > (lazy-seq (aget arr f

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

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 3:15 PM, Paul Mooser wrote: > Is this behavior due to some artifact of destructuring I'm not aware > of (or something else I'm missing), or is there a bug? If it sounds > like a bug, can anyone else reproduce? > > Thanks! I vaguely remember something like this coming up

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 9:31 PM, Josh Daghlian wrote: > During the Boston Lisp Users meeting last November (?) I asked Rich > about whether seq's on mutable java.util.Collections were really > immutable if the underlying object (the Collection) was mutable. He > emphatically said that no, the seq

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 9:36 PM, Josh Daghlian wrote: > > Although I suppose this isn't too surprising: > > user> (second y) > --> ConcurrentModificationException Eeeuw. Guess it uses an Iterator to generate the elements for the lazy seq. For ArrayList, walking it by index would avoid this. For

Re: can I make this faster (and leaner) ?

2009-10-31 Thread John Harrop
On Fri, Oct 30, 2009 at 7:47 PM, DavidF wrote: > > Try this: > > (def *valid-chars* [ \a \b \c \d \e \f \g \h \i \j \k \l \m > \n \o \p \q \r \s \t \u \v \w \x \u \z > \0 \1 \2 \3 \4 \5 \6 \7 \8 \9 ] ) > > (defn generate-key [keylength] >(for [x (ra

Re: Memoize improvement

2009-10-31 Thread John Harrop
On Fri, Oct 30, 2009 at 7:57 PM, Stefan Arentz wrote: > This is some of my first Clojure code so it might not be the > greatest ... yet! > It's quite interesting. (defn my-memoize > "Returns a memoized version of a referentially transparent > function. The > memoized version of the function

Re: Memoize improvement

2009-10-31 Thread John Harrop
Actually, the code I posted might behave less well if the timing is less uniform. It's better to store wait times with queue entries rather than with cache entries: (defn my-memoize "Returns a memoized version of a referentially transparent function. The memoized version of the function keeps

Re: Generalizing -> & ->>

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 9:13 AM, Daniel Werner < daniel.d.wer...@googlemail.com> wrote: > > On Oct 29, 9:35 pm, "AndrewC." wrote: > > Here's a macro that generalizes the two 'threading' macros -> and ->>. > > There have been multiple discussions on this group where similar > operators have been p

Re: Generating Java and C# wrappers

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 12:44 AM, John Ky wrote: > Hi Stuart, > > I wasn't very clear. > > Essentially, the problem I have boils down to having to maintain two > separate code bases for my API - one in C# and one in Java. There is some > overhead in maitaining two different code bases - for inst

Write big numbers with thousands grouping.

2009-10-31 Thread John Harrop
(defn bignum [coll] (reduce #(+ %1 (apply * %2)) 0 (map vector (reverse coll) (iterate #(* 1000 %) 1 user=> (bignum [102 317 926]) 102317926 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: Periodic tasks

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 12:36 PM, Luke VanderHart wrote: > Why not just run an agent that does something, then calls sleep for N > seconds, then calls the next thing? > > Granted, it will eat up a thread in your agent thread pool, but if > you've only got one of these in the app it shouldn't be a

Re: Write big numbers with thousands grouping.

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 1:23 PM, Stuart Sierra wrote: > > For even more fun, you can take advantage of the fact that commas are > whitespace, and use a macro to do it at compile time: > > (defmacro bignum [& parts] > (read-string (apply str parts))) > > (bignum 99,871,142) > 99871142 Eh. Who ne

throw-if

2009-11-01 Thread John Harrop
There seems to be a bit of wasteful duplication in clojure: there's a private clojure.core/throw-if and there's clojure.contrib.except/throw-if. Making matters sillier, they have somewhat different argument lists. Probably they should be merged into a public clojure.core/throw-if. --~--~-

Re: Periodic tasks

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 3:20 PM, Emeka wrote: > John, > > Is like I am missing something? This thread mentioned making periodic > tasks, there was a java example to it. However, what you posted I am yet to > figure out how to make a periodic tasks possible. > Agents can perform periodic tasks, if

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 3:47 PM, Teemu Antti-Poika wrote: > > Hi folks, > > greetings from a beginning clojurian! > > Below a dilemma I noticed recently. I think/hope I've missed > something, since what I am trying to do does not sound too exotic. Any > clues are appreciated! > > I want to use my o

Re: Periodic tasks

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 7:39 PM, Jonathan Smith wrote: > > Maybe I'm confused, but can't you just do a regular java thread for > this? > > (defn periodicly [fun time] > "starts a thread that calls function every time ms" > (let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time) > (recur

Re: Is it possible to implement break or return in Lisp?

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 9:14 PM, Richard Newman wrote: > > > I've given it some thought and it seems it has to be a compiler level > > feature. Am I right? > > You could implement Common Lisp-style "return-from" with a custom > exception class: > > public class BlockException extends Exception { >

Re: Is it possible to implement break or return in Lisp?

2009-11-01 Thread John Harrop
On Mon, Nov 2, 2009 at 12:19 AM, Richard Newman wrote: > > > For this to work, you'd first have to implement Common Lisp style > > unquoting. :) > > Heh, good catch :) > > I've been switching between the two too much recently! > > At least I didn't miss out the semicolons in the Java code ;) I'

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 10:00 AM, Teemu Antti-Poika wrote: > > On Nov 1, 11:18 pm, John Harrop wrote: > > On Sun, Nov 1, 2009 at 3:47 PM, Teemu Antti-Poika >wrote: > > > > > I want to use my own exceptions to control program flow. > > > > That's usu

Re: Write big numbers with thousands grouping.

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 12:34 PM, Stuart Sierra wrote: > On Oct 31, 12:37 pm, John Harrop wrote: > > For some reason though changing "defmacro" here to "definline" doesn't > work. > > It says > > > > # this > > context (NO_SOURCE_FILE:

Re: Applying static java method to seq

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 12:29 PM, Thomas wrote: > How come I can do this > > user=> (map #(Integer/parseInt %) ["42" "100"]) > (42 100) > > but not this > > user=> (map Integer/parseInt ["42" "100"]) > java.lang.Exception: Unable to find static field: parseInt in class > java.lang.Integer (NO_SOURC

Re: ClojureCLR: out parameters

2009-11-02 Thread John Harrop
Wouldn't it be cleaner to just require that the ref/out parameters be passed an atom, a var with a thread-local binding, or a ref, and treat the CLR method as performing a swap!, set!, or alter as appropriate? (Complete with passing it a ref failing outside of a dosync block.) In other words, just

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

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 2:39 PM, Christophe Grand wrote: > Right now I can't see how loop can be made to support both cases. > Hopefully someone else will. In the meantime, remember that it's always worth trying to implement seq-processing in terms of map, reduce, filter, for, and friends if poss

Re: Cross platform clojure

2009-11-03 Thread John Harrop
On Tue, Nov 3, 2009 at 7:09 PM, dmiller wrote: > I have a few ideas for this, but welcome design input from anyone > with an interest. > > It's this, or write a a really nasty Perl script. :) You dare to threaten us??! :) --~--~-~--~~~---~--~~ You received this

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

2009-11-03 Thread John Harrop
On Tue, Nov 3, 2009 at 1:53 AM, Alex Osborne wrote: > The new loop uses the outer-let to get around this: > > (let [G__13697 s > [x & xs] G__13697 > y xs] > (loop* [G__13697 G__13697 > y y] > (let [[x & xs] G__13697 >y y] >...))) > Now

Re: Language feature request: auto-promote int to long with unchecked-divide

2009-11-04 Thread John Harrop
Aren't functions like unchecked-divide supposed to be used for extra speed in performance-critical areas? If unchecked-divide is a multimethod, that kind of defeats the purpose though doesn't it? --~--~-~--~~~---~--~~ You received this message because you are subscr

Code formatter

2009-11-05 Thread John Harrop
The following, which I relinquish into the public domain and certify is original to me, takes a string and reformats it as Clojure code, returning a string. It behaves similarly to the Enclojure reformatter, but: 1. Outside string literals and comments, it will take care of all spacing. 2. Comme

Re: Baffled by NPE

2009-11-05 Thread John Harrop
On Thu, Nov 5, 2009 at 3:53 PM, Meikel Brandmeyer wrote: > Hi, > > Am 03.11.2009 um 22:41 schrieb jan: > > > (defn for-each [f items] > > (when-not (empty? items) > > (f (first items)) > > (recur f (rest items > > And to not defeat the learning exercise... > > (defn for-each >

Re: Code formatter

2009-11-05 Thread John Harrop
On Thu, Nov 5, 2009 at 4:57 PM, jan wrote: > John Harrop writes: > > > The following, which I relinquish into the public domain and certify is > > original to me, takes a string and reformats it as Clojure code, > returning a > > string. It behaves similarly to the

Re: Q: Are the docs for next incorrect?

2009-11-05 Thread John Harrop
On Thu, Nov 5, 2009 at 7:24 PM, MarkSwanson wrote: > On Nov 5, 7:00 pm, MarkSwanson wrote: > > (def > > #^{:arglists '([coll]) > > :tag clojure.lang.ISeq > > :doc "Returns a seq of the items after the first. Calls seq on its > > argument. If there are no more items, returns nil."} > >

Re: [ANN] clj-iter, an iteration macro for Clojure inspired by Common Lisp's Iterate

2009-11-05 Thread John Harrop
On Thu, Nov 5, 2009 at 7:03 PM, Daniel Janus wrote: > To avoid citing the entire README blurb, I'll just give you some > examples: > >(iter (for x in [31 41 59 26]) > (for y from 1) > (collect (+ x y))) >==> (32 43 62 30) > >(iter (for s on [1 2 3 4 5]) >(for

Re: Recursion Problem?

2009-11-05 Thread John Harrop
On Thu, Nov 5, 2009 at 7:48 PM, Don wrote: > I'm having problems with a recursive call I make. The problem (as far > as I gather) is that I have two recursive calls within a condition and > I'm not sure if the second recursive call is being made. > It is, but some results are being discarded.

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz wrote: > But I'm using this in a bigger macro that takes a bunch of functions > as a parameter. Is there a way to make this work or should I > 'translate' the functions that I take by name with (var foo)? You'll need to translate the symbols into va

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:34 PM, Stefan Arentz wrote: > On 2009-11-07, at 8:28 PM, John Harrop wrote: > > > On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz > > wrote: > > But I'm using this in a bigger macro that takes a bunch of functions > > as a parameter.

Gensym collisions can be engineered.

2009-11-07 Thread John Harrop
user=> (def q 'G__723) #'user/q user=> (def r (gensym)) #'user/r user=> q G__723 user=> r G__723 user=> (= q r) true It's possible to anticipate the next gensym name that will be generated and then engineer a collision, and therefore possibly variable capture unintended by the author of a macro.

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 base

Re: Michael newbee challange nr 1

2009-11-08 Thread John Harrop
On Sun, Nov 8, 2009 at 7:33 AM, Michael Jaaka wrote: > 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 > large so it

Re: Converting to TCO

2009-11-08 Thread John Harrop
On Sun, Nov 8, 2009 at 1:39 PM, Robert Campbell wrote: > John: good catch. Thanks. > Can you confirm the difference between my original > defn and your letfn? Both work, but as I understand it from the > documentation, defn would actually define that local function > globally, while letfn act

Re: Gensym collisions can be engineered.

2009-11-09 Thread John Harrop
On Sun, Nov 8, 2009 at 5:56 PM, Kevin Tucker 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 gensym and hold o

Re: Iterative collections.

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 12:52 PM, Andrew Boekhoff wrote: > 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 > > element of

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 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 has long absences awa

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 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 type, hiding the

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

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 5:50 PM, Alex Osborne wrote: > Mark Engelberg wrote: > > 2009/11/9 Tiago Antão : > >> 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 false on a type error)? >

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 8:28 PM, John Harrop 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) ?

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 8:41 PM, John Harrop 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 > c

Re: Consistency of the API

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

Re: Consistency of the API

2009-11-09 Thread John Harrop
On Mon, Nov 9, 2009 at 10:37 PM, Mark Engelberg wrote: > 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 and all the other

Re: Gensym collisions can be engineered.

2009-11-10 Thread John Harrop
On Mon, Nov 9, 2009 at 10:04 PM, Kevin Tucker 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 making symbols that

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 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: (vec (appl

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 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 system can fully detec

Re: Using agents and blocking I/O.

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 10:41 AM, pmf wrote: > On Nov 10, 7:07 am, David Brown 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. > > > > This thing could easily

Re: Using agents and blocking I/O.

2009-11-10 Thread John Harrop
On Tue, Nov 10, 2009 at 11:41 AM, John Harrop 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

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?)) # (ns foo.bar.baz (use [clojure.contrib.core :only seqable?])) # (ns foo.bar.baz (:use [clojure.contrib.core :only seqable?])) # etc.

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 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, macro ca

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 wrote: > 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] >clojure.con

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 wrote: > 2009/11/11 Andrew Boekhoff : > >> > (:uses [clojure.core :exclude [read]) > >> > [clojure.contrib.graph] > >> > [clojure.contrib.fcase] > >> > [clojure.contrib.stream-utils :as su] > >> > [clojure.contrib.def

Re: Topological sort

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 2:04 PM, Nick Day 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' depends on '

Re: Gensym collisions can be engineered.

2009-11-11 Thread John Harrop
On Wed, Nov 11, 2009 at 10:46 PM, Kevin Tucker wrote: > 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 because you are subsc

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 wrote: > On Wed, Nov 11, 2009 at 4:24 PM, John Harrop 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

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 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 hilbert-ma

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread John Harrop
On Fri, Nov 13, 2009 at 8:50 PM, Mark Engelberg wrote: > 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 these new constructs a

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:45 AM, Mark Engelberg wrote: > On Fri, Nov 13, 2009 at 12:58 AM, Konrad Hinsen > wrote: > > Coming from a Python background, I don't think access restrictions are > > necessary. However, flagging fields as "not meant for use by > > outsiders" could be of interest for doc

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 wrote: > On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye > 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, def- would encourage gratuitous

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 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 wrote: > Dereferencing *persons* will result in: > {"Tina" #, > "Jeff" #, > "Karl" #} > Great so far. > > People can become friends, so we need > (defn add-friend [#^String person #^String friend] > (dosync >(let [p (get @*persons* person) >

Re: Deep deref

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 2:11 PM, John Harrop wrote: > On Sat, Nov 14, 2009 at 11:42 AM, André Thieme < > splendidl...@googlemail.com> wrote: > >> Dereferencing *persons* will result in: >> {"Tina" #, >> "Jeff" #, >> "Karl&

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 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)) > > However, when I run

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman 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 macros problem: 1

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 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 surprised your IDE

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 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 before. There's an extr

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 wrote: > On Sat, Nov 14, 2009 at 2:51 PM, Kevin Q 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 sneak

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 wrote: > On 15 Lis, 00:21, John Harrop wrote: > > On Sat, Nov 14, 2009 at 3:03 PM, ajuc wrote: > > > I have to install java one more time, when I try to start java - > > > server, I get: > > > Error: no `server

Re: Datatypes and Protocols - early experience program

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

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 eit

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 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 expan

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 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 func

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 8:17 PM, David Brown 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 > > &

Re: Datatypes and Protocols - early experience program

2009-11-16 Thread John Harrop
On Mon, Nov 16, 2009 at 2:16 AM, Michael Wood 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 Dav

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 wrote: > On Sun, Nov 15, 2009 at 4:49 AM, ajuc wrote: > > On 15 Lis, 00:21, John Harrop wrote: > >> On Sat, Nov 14, 2009 at 3:03 PM, ajuc wrote: > >> > I have to install java one more time, when I try to sta

Re: A Clojure Highlife

2009-11-16 Thread John Harrop
On Mon, Nov 16, 2009 at 12:42 AM, solussd 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, and jars can b

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 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 containi

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 wrote: > 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. > Probably "in": "whic

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 wrote: > 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 Google Groups "Clojure

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 wrote: > Hi, > > On Nov 17, 8:12 pm, John Harrop wrote: > > On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin >wrote: > > > > > I *THINK* what is meant by the "non-numeric" is anything that matches

<    1   2   3   4   >