Re: Bug - Clojure -e disables stdin

2010-04-16 Thread Phil Hagelberg
On Fri, Apr 16, 2010 at 7:00 AM, Aaron Cohen wrote: > This is actually a fairly good bug report, I think. > > If you look in clojure.main, the "eval-opt" fuction uses > "with-in-str", which unnecessarily interferes with using *in* within > the expression you are trying to evaluate. I was actually

Re: Java interop question: proxy or gen-class?

2010-04-16 Thread Gregg Williams
Many thanks to Meikel Brandmeyer, whose code (after a one-character typo correction) worked the first time. As soon as I saw it, I understood every line of it; the problem was, it wouldn't have occurred to me to put all those elements (which, individually, I understood) together in just that way. M

Re: Erlang like environment

2010-04-16 Thread Jonathan Smith
Actually I've got to disagree here, it is really easy to do. Here is one example of something esessoms did: http://github.com/esessoms/clj-interface And here is an example of the rewrite I did when I decided that his version didn't quite do what I wanted. http://gist.github.com/369114 On Apr 15

Re: noob: call multimethod in a map?

2010-04-16 Thread Brian Wolf
ok, I tested it, it works thanks Brian -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscri

Re: noob: call multimethod in a map?

2010-04-16 Thread David Nolen
On Fri, Apr 16, 2010 at 3:46 PM, Brian Wolf wrote: > Hi, Is it possible to call a multimethod in a map? In this simplified > example, I just want to increment every element of the array when the > multimethod is called (my real application is operating on sets of > hash tables ie database ) > >

noob: call multimethod in a map?

2010-04-16 Thread Brian Wolf
Hi, Is it possible to call a multimethod in a map? In this simplified example, I just want to increment every element of the array when the multimethod is called (my real application is operating on sets of hash tables ie database ) (defmulti cc (fn [c v] [(:category c) ])) (defmethod cc [:toys

Re: sorted-set-by drops elements

2010-04-16 Thread Chris Perkins
On Apr 16, 8:25 am, Razvan wrote: > Hi, > > Is this the intended behavior? > > (sorted-set-by (constantly 0) 1 2 3 4) returns #{1}. > > I would expect the set to contain all the elements, and the comparator > to only affect sort order. I expected the same thing at first, but the behavior appears

Re: sorted-set-by drops elements

2010-04-16 Thread Per Vognsen
On Sat, Apr 17, 2010 at 1:05 AM, Per Vognsen wrote: > You can only do slow > linear-time lookups by traversing the tree's nodes exhaustively. Correction: You do not have to do a linear search on the whole tree but only on the subset of the tree for which the comparator returns 0 with your queried

Re: sorted-set-by drops elements

2010-04-16 Thread Per Vognsen
> Equality and ordinality are not the same thing.  It should be > perfectly reasonable to hand someone a set of unique objects sorted by > some non-unique attribute of the elements of the set. Sure, it's perfectly reasonable but it implies a different data structure. It sounds like you want a data

Re: platform-specific unit test failures in cc.test-complex-numbers

2010-04-16 Thread Konrad Hinsen
On 16.04.2010, at 19:49, B Smith-Mannschott wrote: > A few representative examples of the failures I'm seeing > ... > FAIL in (complex-conjugate) (run-test1347341999632195512.clj:44) > expected: (= (conjugate (complex 1 2)) (complex 1 -2))

Re: "wrong number of args" with nested map

2010-04-16 Thread Per Vognsen
Tangent: On Fri, Apr 16, 2010 at 7:41 PM, Douglas Philips wrote: > (1) http://clojure.org/data_structures says: > ... seq returns a sequence of map entries, which are key/value pairs. ... > > I haven't yet found where in the docs a pair is defined, so I am guessing > that the concrete type (list,

platform-specific unit test failures in cc.test-complex-numbers

2010-04-16 Thread B Smith-Mannschott
I'm building af2a730 "some tests for c.c.io byte-level support" of clojure-contrib. I'm seeing clojure.contrib.test-complex-numbers error out the maven build with 4 failures and 253 errors on two of the five platforms at my disposal. Only my linux-based netbooks fail the build. JDK version does n

Re: sorted-set-by drops elements

2010-04-16 Thread ataggart
The problem is you're unnecessarily conflating the value by which to base a sort (x and y in your example) with the elements of the set. Equality and ordinality are not the same thing. It should be perfectly reasonable to hand someone a set of unique objects sorted by some non-unique attribute of

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Jarkko Oranen
On Apr 16, 5:25 pm, Asim Jalis wrote: > > It does conform to the pattern that the bound variable precedes the > > value to bind in forms like let. A benefit of this ordering is that > > destructuring patterns like {:keys [a b c]} are unambiguous. > > Hi Per, > > Could you explain the rationale f

Re: "wrong number of args" with nested map

2010-04-16 Thread ataggart
The function you give to map needs to accept the same number of args as there are collections. You're passing one map, thus the function will be called with one arg. In the case of maps the "element" is a key/value pair, which can then be destructured in the function. On Apr 15, 8:53 pm, Derek w

Re: sorted-set-by drops elements

2010-04-16 Thread Per Vognsen
On Sat, Apr 17, 2010 at 12:01 AM, Sean Devlin wrote: > I know you might not like it, but there is a convention in JavaLand > that a comparator value of 0 is identical in a sorted collection. It's not a Java convention. It's intrinsic to the business of sorting. For sorting to give well-defined re

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
CORRECTION, DON'T SHOOT!! I should have order & value, not order & identity. On Apr 16, 1:01 pm, Sean Devlin wrote: > I think the fns you're interested in are sort and sort-by, not sorted- > set-by. > > I know you might not like it, but there is a convention in JavaLand > that a comparator v

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
I think the fns you're interested in are sort and sort-by, not sorted- set-by. I know you might not like it, but there is a convention in JavaLand that a comparator value of 0 is identical in a sorted collection. This causes orthogonal concepts of order & identity to be entwined. Sean On Apr 16,

Re: sorted-set-by drops elements

2010-04-16 Thread Per Vognsen
Maybe the example was poorly picked but the point stands: if you're asking for a sorted set based on a comparator, you should expect duplicate elements as dictated by comparator to be eliminated. If you wanted to sort a set of people by age, you wouldn't use a sorted set but a sorted sequence. That

Re: sorted-set-by drops elements

2010-04-16 Thread Razvan
Why should sorting be related to the primary key? You should be able to sort on any attribute. If you wanted to sort a set of people by age would it make sense to only retain one person of each age? Sort order and identity should be orthogonal. Besides, if you need a collection based on primary key

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Asim Jalis
On Fri, Apr 16, 2010 at 2:15 AM, Per Vognsen wrote: > What may confuse is that map destructuring swaps the positions of keys > and values as compared to map literals: > > user> (let [{x :body} {:body 42}] >           x) > 42 > > It does conform to the pattern that the bound variable precedes the >

Re: sorted-set-by drops elements

2010-04-16 Thread Per Vognsen
It doesn't seem confusing to me. You are taking complete control of the set's local notion of ordering and equality. This is what I'd expect. Here's an example. First, a handy little function from Haskell: (defn on [key f] #(apply f (map key %&))) Then: user> (sorted-set-by (on :id compare)

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
Here's the source for sorted-set-by: (defn sorted-set-by "Returns a new sorted set with supplied keys, using the supplied comparator." ([comparator & keys] (clojure.lang.PersistentTreeSet/create comparator keys))) This is because your comparator is saying that everything is equal. Persiste

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Per Vognsen
You will have to ask Rich. The two reasons I mentioned in my post were my own guesses. I don't find either of them very persuasive myself. My preference would be that patterns and literals should reflect each other directly as much as possible. Features like :keys and :or have no counterpart in the

sorted-set-by drops elements

2010-04-16 Thread Razvan
Hi, Is this the intended behavior? (sorted-set-by (constantly 0) 1 2 3 4) returns #{1}. I would expect the set to contain all the elements, and the comparator to only affect sort order. Razvan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: clojure.set index not handling large sets...

2010-04-16 Thread Luc Préfontaine
The problem is more that whole records for already existing keys disappeared along the road. Like if conj failed to do its job. I would be surprised that a smaller subset recreates the problem. I had other instances were the input data was small and the index was correct, all keys and all the reco

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Stefan Rohlfing
Your explanations from different angles of the problem were really helpful. I now have a much better picture of what is going on during destruturing. Thank you very much! Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: Translation from CL - "On Lisp" program

2010-04-16 Thread Per Vognsen
On Fri, Apr 16, 2010 at 12:41 PM, Aravindh Johendran wrote: > Sorry, I shoulda been clearer.  By similar functionality, i meant a 20- > q game with > 1) the network implemented as closures and There are various ways you can do this while separating concerns. If you don't mind specifying the quest

Re: Bug - Clojure -e disables stdin

2010-04-16 Thread Aaron Cohen
This is actually a fairly good bug report, I think. If you look in clojure.main, the "eval-opt" fuction uses "with-in-str", which unnecessarily interferes with using *in* within the expression you are trying to evaluate. I was actually running into this while trying to make a "lein repl" in clojur

Re: "wrong number of args" with nested map

2010-04-16 Thread Douglas Philips
On 2010 Apr 15, at 11:53 PM, Derek wrote: (defn foo [map1 map2] (map (fn [k v] (map2 k)) map1)) (foo {:a 1 :b 2} {:a 5 :b 6 :c 7}) When you turn a map into a sequence, you get a sequence of two-element sequences(1), so if you change your anonymous function to destructure that, it will work

Re: Translation from CL - "On Lisp" program

2010-04-16 Thread Aravindh Johendran
Sorry, I shoulda been clearer. By similar functionality, i meant a 20- q game with 1) the network implemented as closures and 2) code that doesn't have to hold state in a global datastructure The question wasn't about the easiest way to implement the game. State is unavoidable in many circumstanc

"wrong number of args" with nested map

2010-04-16 Thread Derek
I feel like I'm probably doing something dumb, but here's my problem. Below is a function that could take two maps, and return a list of all the values in the second map for each key of the first: (defn foo [map1 map2] (map (fn [k v] (map2 k)) map1)) (foo {:a 1 :b 2} {:a 5 :b 6 :c 7}) I would exp

Re: Erlang like environment

2010-04-16 Thread rberger
At Runa, we've (mostly Amit Rathore) developed a framework somewhat along these lines that we are using called swarmiji. We've open sourced it at http://github.com/amitrathore/swarmiji To quote from the readme: swarmiji is a framework that helps in writing distributed programs using the clojure p

Clojure-based query language for Hadoop

2010-04-16 Thread nathanmarz
I've recently released Cascalog, a Clojure DSL for querying Hadoop, as open-source. Here's the canonical "word count" query in Cascalog: (?<- (stdout) [?word ?count] (sentence ?s) (split ?s :> ?word) (c/ count ?count)) Introductory blog post: http://nathanmarz.com/blog/introducing-cascalog/ Proje

Re: Events vs Threads paper

2010-04-16 Thread Will
I've put up the code those guys eventually worked on (and then abandoned) while at UCBerkley: http://github.com/wlangstroth/capriccio On Apr 15, 4:16 pm, TimDaly wrote: > This might be interesting when the discussion of events vs threads > comes > up:http://www.usenix.org/events/hotos03/tech/fu

Re: Clojure Concurrency Screencast Available

2010-04-16 Thread Craig Andera
One final update: all six parts are now available, including the "mobile" downloads for offline viewing. http://link.pluralsight.com/clojure On Tue, Apr 13, 2010 at 9:40 AM, Craig Andera wrote: > Glad you've enjoyed them! > > 2010/4/13 Pelayo Ramón > > I have seen the first 2, and as a clojure n

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Ramakrishnan Muthukrishnan
On Fri, Apr 16, 2010 at 2:29 PM, Bytesource wrote: > Hi, > > I am currently reading "Programming Clojure" but got stuck at the > destructuring done in the "head-overlaps-body?" function call that is > part of the "snake" game: > > (defn head-overlaps-body? [{[head & body] :body}] >  (includes? bod

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Jarkko Oranen
On Apr 16, 11:59 am, Bytesource wrote: > Hi, > > I am currently reading "Programming Clojure" but got stuck at the > destructuring done in the "head-overlaps-body?" function call that is > part of the "snake" game: > > (defn head-overlaps-body? [{[head & body] :body}] >   (includes? body head))

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Baishampayan Ghose
Bytesource wrote: I am currently reading "Programming Clojure" but got stuck at the destructuring done in the "head-overlaps-body?" function call that is part of the "snake" game: (defn head-overlaps-body? [{[head & body] :body}] (includes? body head)) ;; page 200 of the pdf version I can no

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Per Vognsen
What may confuse is that map destructuring swaps the positions of keys and values as compared to map literals: user> (let [{x :body} {:body 42}] x) 42 It does conform to the pattern that the bound variable precedes the value to bind in forms like let. A benefit of this ordering is that

Problem with Destructuring in A Function Call

2010-04-16 Thread Bytesource
Hi, I am currently reading "Programming Clojure" but got stuck at the destructuring done in the "head-overlaps-body?" function call that is part of the "snake" game: (defn head-overlaps-body? [{[head & body] :body}] (includes? body head)) ;; page 200 of the pdf version I can not figure out wh