Re: function to split a collection into predicate passes and failures?

2011-06-25 Thread Benny Tsai
You could also use group-by: user=> (group-by odd? [1 2 3 4 5]) {true [1 3 5], false [2 4]} The nice thing is that you can also use this with functions that return more than 2 values: user=> (group-by class [0 nil false]) {java.lang.Integer [0], nil [nil], java.lang.Boolean [false]} --

Re: function to split a collection into predicate passes and failures?

2011-06-25 Thread Alan Malloy
It exists in clojure.contrib, and it's called separate. It's easy to rewrite, of course, as you note; but I prefer: (def split-pred (juxt filter remove)) On Jun 25, 8:56 pm, Alex Baranosky wrote: > Something like this is probably good: > > (defn split-pred [pred coll] >   [(filter pred coll) (re

Re: function to split a collection into predicate passes and failures?

2011-06-25 Thread Alex Baranosky
Something like this is probably good: (defn split-pred [pred coll] [(filter pred coll) (remove pred coll)]) But I wanted to make sure I wasn't reinventing the wheel! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

function to split a collection into predicate passes and failures?

2011-06-25 Thread Alex Baranosky
Is there a function built-in to Clojure that given a seq and a predicate will return a list of 2 lists, the items that passed the predicate and the items that failed it? (split-em odd? [1 2 3 4 5]) => ((1 3 5) (2 4)) -- You received this message because you are subscribed to the Google Groups "C

Re: Clojure Atlas

2011-06-25 Thread Sean Corfield
On Sat, Jun 25, 2011 at 9:21 AM, Paul Meehan wrote: > Has anyone tried: > > http://www.clojureatlas.com/ > > Any comments/feedback? Yup. I think it's a great way to explore the Clojure core and libraries and it's always open in a tab in my browser. I signed up for the 1.2.0 and the upcoming 1.3.0

Re: Efficient queue types for Clojure.

2011-06-25 Thread e
interesting. maybe I can change my interface in this thing I abandoned a while back: http://code.google.com/p/jc-pheap/ to match that of the contrib, "priority map". I had gotten stuck figuring out the right interface/usage/idioms for clojure and kinda messed the whole thing up in later checkins

Clojure Atlas

2011-06-25 Thread Paul Meehan
Hi Has anyone tried: http://www.clojureatlas.com/ Any comments/feedback? thanks Paul C. Meehan -- 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 moder

setting a xml value and save the root to a file

2011-06-25 Thread dive_mw
Hi all, can anybody help me, how to fix the following problem? I have a function like this: (defn set-config-value "sets a new value programatically to a config key" [value & tags] ;; set the new value and save the config file? ;;(zip/edit tags (zip/xml-zip(load-config)) value ) ;; Save

Re: Strange Problem With Cake

2011-06-25 Thread Alan Malloy
It sounds like your project.clj is broken, possibly because it reads defproject test_csv ... instead of (defproject test_csv ...) But my psychic powers reach no further than that. Maybe you should paste your project.clj, or even your whole project on github. On Jun 25, 4:41 pm, octopusgrabb

Strange Problem With Cake

2011-06-25 Thread octopusgrabbus
I'm on a home system, same version of Ubuntu as at work. I am able to build clojure-csv with no problems using cake. When sitting in my project directory, test_csv, even cake help results in this error Caused by: java.lang.Exception: Can't take value of a macro: #'cake.core/defproject but when I

Re: ordered map in Clojure?

2011-06-25 Thread Alan Malloy
Note that it's still pretty immature - I started writing it last weekend. It's tested fairly thoroughly, and I spent four or five days hunting down the best performance I could, so it should be perfectly usable. However, if you have any problems please let me know. Especially, if you plan to disso

Re: ordered map in Clojure?

2011-06-25 Thread Alan Malloy
array-map turns into a hashmap after ten insertions, currently, but that's far from guaranteed: user> (->> {} (iterate #(assoc % (rand-int 1e6) 1)) (drop-while (comp #{(class {})} class)) (first) (count)) 10 My ordered-set/map are now available on cloja

Re: ordered map in Clojure?

2011-06-25 Thread Alex Baranosky
I wonder at what point array-map becomes a hash-map? Maybe I could use it? On second thought, I don't really want to depend on something so flimsy. Alan, is your ordered map code available on clojars? Alex -- You received this message because you are subscribed to the Google Groups "Cloj

Re: ordered map in Clojure?

2011-06-25 Thread Ivan Koblik
Hi Ken, Having a mutable stm-map would be awesome. I actually had to implement one for my project at work. Sorry can't publish it due to licensing issues, but anyway my implementation is dead simple and won't perform well on big data sets. I was trying to understand how to implement detection of n

Re: defrecord and namespace

2011-06-25 Thread Gregg Reynolds
On Sat, Jun 25, 2011 at 4:17 PM, Phil Hagelberg wrote: > I suspect part of your problem comes from using records where you should be > using maps. Records are a relatively advanced feature; I have been using > Clojure for two years without ever finding a use for them. Learn to walk > before you r

Re: defrecord and namespace

2011-06-25 Thread Gregg Reynolds
On Sat, Jun 25, 2011 at 2:11 PM, David Nolen wrote: > On Sat, Jun 25, 2011 at 2:06 PM, Gregg Reynolds wrote: > >> (ns gae-lex.test.dataServiceTests >> (:use [gae-lex.core]) >> (:import (gae-lex.core.Author)) >> ...) >> > > (ns gae-lex.test.dataServiceTests > (:use [gae-lex.core]) > (:imp

Re: defrecord and namespace

2011-06-25 Thread Phil Hagelberg
I suspect part of your problem comes from using records where you should be using maps. Records are a relatively advanced feature; I have been using Clojure for two years without ever finding a use for them. Learn to walk before you run. -Phil On Jun 25, 2011 11:06 AM, "Gregg Reynolds" wrote: --

Re: ordered map in Clojure?

2011-06-25 Thread Ken Wesson
On Sat, Jun 25, 2011 at 4:18 PM, Laurent PETIT wrote: > Beware the devil hidden in the details: > " > Note that an array map will only maintain sort order when > un-'modified'. Subsequent assoc-ing will eventually cause it to > 'become' a hash-map. > " Besides a LinkedHashMap-alike, Clojure could

Re: ordered map in Clojure?

2011-06-25 Thread Laurent PETIT
Beware the devil hidden in the details: " Note that an array map will only maintain sort order when un-'modified'. Subsequent assoc-ing will eventually cause it to 'become' a hash-map. " 2011/6/25 Alex Baranosky : > Ha!  Perfect.  Thanks. > > On Sat, Jun 25, 2011 at 4:00 PM, James Estes wrote: >>

Re: ordered map in Clojure?

2011-06-25 Thread Alan Malloy
ArrayMap isn't very performant for large collections. You might like https://github.com/flatland/ordered On Jun 25, 1:11 pm, Alex Baranosky wrote: > Ha!  Perfect.  Thanks. > > > > > > > > On Sat, Jun 25, 2011 at 4:00 PM, James Estes wrote: > > ArrayMap? > >http://clojure.org/data_structures#toc2

Re: ordered map in Clojure?

2011-06-25 Thread Alex Baranosky
Ha! Perfect. Thanks. On Sat, Jun 25, 2011 at 4:00 PM, James Estes wrote: > ArrayMap? > http://clojure.org/data_structures#toc21 > > James > > > On Sat, Jun 25, 2011 at 1:55 PM, Alex Baranosky > wrote: > > What are some options for having a map that guarantees ordering of its > keys > > in Clo

Re: ordered map in Clojure?

2011-06-25 Thread James Estes
ArrayMap? http://clojure.org/data_structures#toc21 James On Sat, Jun 25, 2011 at 1:55 PM, Alex Baranosky wrote: > What are some options for having a map that guarantees ordering of its keys > in Clojure? (note: sorted-map won't do!)  My first try was to use > LinkedHashMap, but am running into

ordered map in Clojure?

2011-06-25 Thread Alex Baranosky
What are some options for having a map that guarantees ordering of its keys in Clojure? (note: sorted-map won't do!) My first try was to use LinkedHashMap, but am running into exceptions of the " java.util.LinkedHashMap cannot be cast to clojure.lang.Associative" variety. So then I tried to use e

Re: defrecord and namespace

2011-06-25 Thread David Nolen
On Sat, Jun 25, 2011 at 2:06 PM, Gregg Reynolds wrote: > (ns gae-lex.test.dataServiceTests > (:use [gae-lex.core]) > (:import (gae-lex.core.Author)) > ...) > (ns gae-lex.test.dataServiceTests (:use [gae-lex.core]) (:import [gae_lex.core Author]) ...) Should work. David -- You receive

Re: defrecord and namespace

2011-06-25 Thread Gregg Reynolds
On Sat, Jun 25, 2011 at 12:07 PM, Meikel Brandmeyer wrote: > Hi, > > Am 25.06.2011 um 18:35 schrieb Gregg Reynolds: > > > This is using the standard clojure-test stuff. I've tried every way I > can think of to get Author into the namespace with no luck. Since the > defentity statement occurs in

deftype issue in 1.3-beta1

2011-06-25 Thread Praki
This looks like an issue with hyphenated attribute names in deftype. defrecord seems to be fine. user> *clojure-version* {:major 1, :minor 3, :incremental 0, :qualifier "beta1"} user> (deftype Foo [foo]) user.Foo user> (Foo. 1) #user.Foo[1] user> (deftype Bar [bar-id]) user.Bar user> (Bar. 1) ; Ev

Re: defrecord and namespace

2011-06-25 Thread Meikel Brandmeyer
Hi, Am 25.06.2011 um 18:35 schrieb Gregg Reynolds: > This is using the standard clojure-test stuff. I've tried every way I can > think of to get Author into the namespace with no luck. Since the defentity > statement occurs in the myapp.core namespace I don't see why :use ing that > isn't go

defrecord and namespace

2011-06-25 Thread Gregg Reynolds
Hi, I'm trying to use appengine-magic's datastore api, but I can't get defentity to work across files. I can do (ds/defentity Author [^:key name, birthday]) in core.clj, but if I try to use Author in my test core.clj I get "Unable to resolve classname: Author". This is using the standard cloj

Re: Conversion of one java example to clojure?

2011-06-25 Thread Ken Wesson
On Fri, Jun 24, 2011 at 11:57 AM, .Bill Smith wrote: > Sure could.  And you don't want to do this if brownFox is a function: > > (Label. brownFox) > > If you really want it to be a function, you could do the following, but I >  think it would complicate things unnecessarily: > > (Label. (brownFox)

Re: table vaadin?

2011-06-25 Thread Benny Tsai
That usually means somewhere in the code, an object of class com.vaadin.ui.Table is being used where a function is expected. For example, evaluating this code: ("abc" 1) ...will result in "java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn", because a String can

Re: table vaadin?

2011-06-25 Thread Antonio Recio
It seems there is some error importing com.vaadin.ui.Table. What does it mean "cannot be cast to clojure.lang.IFn"? How I can solve it? * * *exception* javax.servlet.ServletException: java.lang.ClassCastException: com.vaadin.ui.Table cannot be cast to clojure.lang.IFn *root cause* java.lang.Cl

Re: Clojure 1.3 Beta 1

2011-06-25 Thread Aaron Bedra
Also see the original design page on the wiki for where things ended up. http://dev.clojure.org/display/design/Contrib+Library+Names -- Cheers, Aaron Bedra -- Clojure/core http://clojure.com On 06/24/2011 04:53 PM, Stuart Sierra wrote: The monolithic "clojure-contrib" project is not being ac

Re: Clojure 1.3 Beta 1

2011-06-25 Thread Aaron Bedra
It's already on the list in the ticket http://dev.clojure.org/jira/browse/CLJ-815 On 06/24/2011 11:31 PM, Alan Malloy wrote: What about juxt? Can we get rid of the "Alpha - name subject to change" in the docstring there? -- Cheers, Aaron Bedra -- Clojure/core http://clojure.com -- You receiv

Re: table vaadin?

2011-06-25 Thread Meikel Brandmeyer
Hi, you don't need the .class suffix; just use the class name. null is named nil. Also [] is a vector, not an array. You need to-array resp. into-array. In the addItem calls you got the “array” sizes wrong. And finally new Object[] {a, b, c} creates a new array. Not a new Object. (Which is what

table vaadin?

2011-06-25 Thread Antonio Recio
I am having problems to translate this table vaadin in java to clojure: ;; Java Table table = new Table("This is my Table"); table.addContainerProperty("First Name", String.class, null); table.addContainerProperty("Last Name", String.class, null); table.addContainerProperty("Year", Intege