Re: Confusing interplay between macros and metadata

2011-11-09 Thread Marshall T. Vandegrift
Tassilo Horn tass...@member.fsf.org writes: I'm facing the same issue. I have this macro for java interop: (defmacro with-traversal-context [[g tc] body] `(let [old-tc# (.getTraversalContext ^Graph ~g)] (try (.setTraversalContext ^Graph ~g ^TraversalContext ~tc)

(newbie) - first question - split list of maps into map of maps based on distinct values

2011-11-09 Thread Colin Yates
Hi all, So finally I have managed to get to write some clojure. Gotta say, after two days I am seriously excited - talk about removing ceremony and focusing on the issue. I feel like a blind man performing surgery with welding gloves on whilst holding this tiny but unbelievably powerful and

Re: (newbie) - first question - split list of maps into map of maps based on distinct values

2011-11-09 Thread Colin Yates
Sometimes the answer is just too simple: group-by (see the last post on http://stackoverflow.com/questions/3052162/coverting-a-vector-of-maps-to-map-of-maps-in-clojure) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: Confusing interplay between macros and metadata

2011-11-09 Thread Tassilo Horn
Marshall T. Vandegrift llas...@gmail.com writes: Hi Marshall, I'm facing the same issue. I have this macro for java interop: (defmacro with-traversal-context [[g tc] body] `(let [old-tc# (.getTraversalContext ^Graph ~g)] (try (.setTraversalContext ^Graph ~g

Multiple try via macro

2011-11-09 Thread Michael Jaaka
Hi! I would like to write macro, which tries to evalute one of statements. If exception happens the next statement is taken, if not then rest of expressions execution is stopped. (defmacro try-this[ body ] `(if (seq ~body) (try

ANN: Fughetta 0.0.1

2011-11-09 Thread sebastiansen
Releasing first versioned Fughettahttps://github.com/Sebastiansen/fughetta project with new functions and arrangements. Enjoy! -- 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

Re: `conj` into maps

2011-11-09 Thread Stuart Sierra
It may relate to the implementation of IPersistentCollection.cons(Object). As far as I know, the IPersistentCollection.cons(Object) method powers the polymorphic behavior of the `conj` function, and is the foundation for the persistent collections in general. -S -- You received this message

Re: Multiple try via macro

2011-11-09 Thread Stuart Halloway
Hi! I would like to write macro, which tries to evalute one of statements. If exception happens the next statement is taken, if not then rest of expressions execution is stopped. (defmacro try-this[ body ] `(if (seq ~body) (try

Re: form-zip

2011-11-09 Thread George Jahad
I see your point. Still it seems odd that the default zipper generating function isn't one that understands the big 4 clojure datastructures. On Nov 8, 8:04 pm, Alan Malloy a...@malloys.org wrote: They have a different make-node function, so that when you edit a vector-zip you get vectors

Re: Multiple try via macro

2011-11-09 Thread Michael Jaaka
Thank you. Is loop and not for example let, for recursion optimalization? On Nov 9, 2:51 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Hi! I would like to write macro, which tries to evalute one of statements. If exception happens the next statement is taken, if not then rest of

Re: Dynamic test creation?

2011-11-09 Thread AndyK
Questions about tabular tests... * can they take a lazy-seq as input? * will the tests be parallelized? (i have anywhere from 10k-20k tests to run) On Nov 8, 4:16 pm, Alex Baranosky alexander.barano...@gmail.com wrote: Sounds lile you could use Midje's tabular tests.  Or if you want write a

Re: form-zip

2011-11-09 Thread George Jahad
(fz-node-seq x) is just (tree-seq coll? seq x) Good Point! I had never noticed the parallels between tree-seq and zippers, but it's obvious when you point it out. Thanks for mentioning that. (personally I don't have enough experience to be comfortable with them), yeah, i haven't found a

Re: Multiple try via macro

2011-11-09 Thread Meikel Brandmeyer (kotarak)
Hi, the loop is unnecessary in this case. You can just as well use let. And you may want to use an if with the (throw (Exception. nothing succeeded)) instead of the when. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: `conj` into maps

2011-11-09 Thread Chas Emerick
Right, a collection can implement cons however it likes. While it's convenient, I was just curious about the 'why' of APersistentMap's implementation, esp. since it overlaps w/ `merge`. - Chas On Nov 9, 2011, at 8:28 AM, Stuart Sierra wrote: It may relate to the implementation of

Re: SQL Korma Missing Pred

2011-11-09 Thread Dennis Crenshaw
So it does, thanks! -- 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 unsubscribe from this group,

Re: Multiple try via macro

2011-11-09 Thread Stuart Halloway
Thank you. Is loop and not for example let, for recursion optimalization? The primary purpose of the loop in this example is to indicate the local time where I am and therefore the absence of Mountiain Dew in my bloodstream. :-) Stu -- You received this message because you are subscribed

Re: using sqlite3

2011-11-09 Thread willyh
project.clj: --- (defproject testsqlite 1.0.0-SNAPSHOT :description FIXME: write description :disable-deps-clean false :dependencies [[org.clojure/clojure

Re: using sqlite3

2011-11-09 Thread willyh
Use this project.clj instead (eliminating the reference to clojure-contrib): (defproject testsqlite 1.0.0-SNAPSHOT :description FIXME: write description :disable-deps-clean false :dependencies [[org.clojure/clojure 1.3.0] [org.clojure/java.jdbc 0.1.0]

Re: Dynamic test creation?

2011-11-09 Thread Brian Marick
On Nov 9, 2011, at 8:37 AM, AndyK wrote: Questions about tabular tests... * can they take a lazy-seq as input? Do you mean something like having a computation that generates a stream of test inputs and feeds them into a test evaluator? If so, no: all `tabular's` work happens at

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick
On Nov 8, 2011, at 6:44 PM, Stuart Halloway wrote: Line 4 of midje.util.report is unusual in several ways: it precedes the ns call, adds a second ns call, does an eval, and uses def forms not at the top level: Thanks, Stu. That code was a patch that came in when I was new to Clojure, and

Clojure on the reversim podcast

2011-11-09 Thread ronen
Iv been hosted on reversim (an Israeli software podcast) for a talk about Clojure, The talk is in Hebrew: http://www.reversim.com/ Ronen -- 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

core.logic questions

2011-11-09 Thread Mark
I'm working through the core.logic examples on http://objectcommando.com. I want to develop a query that returns the child and his parents. The gives me what I want: (run* [q] (fresh [m f c] (== c 'Sonny) (parent m c) (parent f c) (!= m f)

REPL magic: get the previous expression?

2011-11-09 Thread nchurch
Does anyone know how to programmatically get the previous expression entered at the REPL? You can get it interactively by pressing the up- arrow key; and of course you can get the previous \result through the variable *1. Is there any similar variable or function (perhaps in Java-land) that

Re: core.logic questions

2011-11-09 Thread David Nolen
Functions that are going to be used in core logic must return goals. (defn parents-of [m f c] (parent m c) (parent f c) (!= m f)) In this case you only return the (!= m f) subgoal instead of the goal that represents the conjunction of all three subgoals. (defn parents-of [m f c]

Open source Clojure projects

2011-11-09 Thread Zack Maril
For many of the older languages I look at, there are big open source projects that people are working on that are making a big impact. C has linux, Javascript has jQuery and Khan Academy's frameworks, Java has their libraries, etc. etc. Are there any Clojure projects I could contribute to? I

Re: Open source Clojure projects

2011-11-09 Thread Ulises
Whenever I see a question like this asked anywhere (and even when I ask the question to myself or others) I usually recommend reading (or read myself): http://prog21.dadgum.com/80.html :) U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

sqlitejdbc jar on clojars

2011-11-09 Thread labwork07
sqlite3 had some problems but a later version (3.7.9) seems to work. Now the sqlitejdbc jar on clojars version 0.5.6 has the same problems as the old sqlite3 command line. Basically, I get this error below when reading certain .sqlite files. Is there a latest version of the sqlitejdcb driver

Re: REPL magic: get the previous expression?

2011-11-09 Thread Michael Beattie
What do you mean? If it's programatically then why not use a loop or something? -- 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

Re: `conj` into maps

2011-11-09 Thread Stuart Sierra
I expect you're right: it's vestigial. -S -- 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

Re: sqlitejdbc jar on clojars

2011-11-09 Thread willyh
I'm using the sqlite-jdbc jar from a maven repository. I use this in my leiningen project to fetch it: [org.xerial/sqlite-jdbc 3.7.2] I haven't had any issues with it, but that doesn't mean you won't. On Nov 9, 12:50 pm, labwor...@gmail.com wrote: sqlite3 had some problems but a later version

Re: REPL magic: get the previous expression?

2011-11-09 Thread nchurch
I mean I want to write a utility that has access to the previous expression entered at the REPL no matter where this utility is called. Since the up-arrow key has this access, it must be possible On Nov 9, 12:57 pm, Michael Beattie mtbee...@gmail.com wrote: What do you mean?  If it's

Re: REPL magic: get the previous expression?

2011-11-09 Thread Chas Emerick
The up-arrow key can recall the expressions you send thanks to either readline or Leiningen. You might be able to hook the appropriate var in leiningen.repl in order to slip your own function into the options passed to the Clojure REPL it starts. You need to be able to intercept the form

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick
On Nov 8, 2011, at 8:47 PM, Alan Malloy wrote: (let [ns-obj (the-ns (doto 'clojure.test require)) the-var (intern ns-obj 'old-report)] (when-not (.hasRoot the-var) (intern ns-obj 'old-report clojure.test/report))) Seems to have the same effect as the defonce in some simple

Re: Open source Clojure projects

2011-11-09 Thread Chris Perkins
There are lots. You could start browsing from here: https://github.com/languages/Clojure - Chris -- 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

Re: Dynamic test creation?

2011-11-09 Thread Nate Young
On 11/08/2011 12:44 PM, AndyK wrote: I finally had a chance to try this out and it fails with error: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj Compilation failed. I think I fat-fingered my deftest-form definition: I originally wrote: (defn

Re: Re: sqlitejdbc jar on clojars

2011-11-09 Thread labwork07
Thanks but I am not getting anything with it. Here's what I have. Does it seem correct? (ns cljstudent.sqlite (:require [clojure.contrib.sql :as sql])) ;; need this to load the sqlite3 driver (as a side effect of evaluating the expression) ;;(Class/forName org.sqlite.JDBC) (def db-path

Re: Re: sqlitejdbc jar on clojars

2011-11-09 Thread labwork07
Sorry, I had my query wrong. This driver does work now. Thanks! On , willyh wheine...@gmail.com wrote: I'm using the sqlite-jdbc jar from a maven repository. I use this in my leiningen project to fetch it: [org.xerial/sqlite-jdbc 3.7.2] I haven't had any issues with it, but that

Re: REPL magic: get the previous expression?

2011-11-09 Thread nchurch
My particular use-case was to be able to write tests for things entered at the REPL. I'm almost done with a basic version of it and will post it to the list when done. It would be much easier if the expressions were there anyway. I guess the issue is that people may not always be using Lein or

Re: Creating a var, functions from a macro

2011-11-09 Thread Sean Bowman
Apparently the missing bit is I need to escape the symbol calls, e.g. (defn ~(symbol index) ... Is this correct? -- 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

All subsets of a vector

2011-11-09 Thread Shoeb Bhinderwala
Is there a more elegant/idomatic way to achieve the following result: user= a1 [a b c d] user= (map-indexed (fn [n x] (vec (take (inc n) x))) (take (count a1) (repeat a1))) ([a] [a b] [a b c] [a b c d]) -- You received this message because you are subscribed to the Google Groups Clojure group.

Re: All subsets of a vector

2011-11-09 Thread Linus Ericsson
(map #(vec (take (inc %) a1)) (range (count a1))) does it the lovely map. /Linus 2011/11/9 Shoeb Bhinderwala shoeb.bhinderw...@gmail.com Is there a more elegant/idomatic way to achieve the following result: user= a1 [a b c d] user= (map-indexed (fn [n x] (vec (take (inc n) x))) (take

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Stuart Halloway
Line 4 of midje.util.report is unusual in several ways: it precedes the ns call, adds a second ns call, does an eval, and uses def forms not at the top level: Thanks, Stu. That code was a patch that came in when I was new to Clojure, and I didn't understand it. I think it was a

Re: problems of a newbie

2011-11-09 Thread Alex Baranosky
Very hard question to answer. It makes sense that static typing would help, but in practice I never seem to get defects that are related to types. Ergo, Clojure's approach to typing works well, and the code stays very minimalist. On Nov 8, 2011 12:52 AM, Sean Corfield seancorfi...@gmail.com

Re: All subsets of a vector

2011-11-09 Thread Alex Baranosky
Does Clojure have the equivalent of Haskell's 'scan' function? (I am on my phone...) Seems like a solution with that would be nice. (scan is like reduce except it keeps all intermediate results) On Nov 9, 2011 5:57 PM, Linus Ericsson oscarlinuserics...@gmail.com wrote: (map #(vec (take (inc %)

Re: All subsets of a vector

2011-11-09 Thread Benny Tsai
Another way to do it, using 'reductions': (rest (reductions conj [] a1)) On Wednesday, November 9, 2011 5:47:08 PM UTC-5, Shoeb Bhinderwala wrote: Is there a more elegant/idomatic way to achieve the following result: user= a1 [a b c d] user= (map-indexed (fn [n x] (vec (take (inc n)

Re: All subsets of a vector

2011-11-09 Thread Benny Tsai
That's exactly what 'reductions' does :) On Wednesday, November 9, 2011 6:09:08 PM UTC-5, Alex Baranosky wrote: Does Clojure have the equivalent of Haskell's 'scan' function? (I am on my phone...) Seems like a solution with that would be nice. (scan is like reduce except it keeps all

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick
On Nov 9, 2011, at 4:58 PM, Stuart Halloway wrote: Line 4 of midje.util.report is unusual in several ways: it precedes the ns call, adds a second ns call, does an eval, and uses def forms not at the top level: Thanks, Stu. That code was a patch that came in when I was new to Clojure,

Re: All subsets of a vector

2011-11-09 Thread Alex Baranosky
Dang, I just logged in in-flight just so I could post my solution with reductions :) (defn doit [coll] (rest (reductions conj [] coll))) -- 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

Re: All subsets of a vector

2011-11-09 Thread Bob Shock
Or my current favorite take-while iterate combo: C:\clojure-1.2.0java -jar clojure.jar Clojure 1.2.0 user= (take-while seq (iterate rest [1 2 3 4])) ([1 2 3 4] (2 3 4) (3 4) (4)) user= (take-while seq (iterate butlast [1 2 3 4])) ([1 2 3 4] (1 2 3) (1 2) (1)) user= On Nov 9, 4:52 pm, Alex

Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro Hozumi
Hi, To avoid peeking same element of a queue, I think PersistentQueue must be stored in ref not atom. Is this correct? ;;Ref: safe (dosync (let [item (peek @r)] (alter r pop) item)) ;Atom: unsafe (let [item (peek @a)] (swap! a pop) item)) Thanks. -- You received this message

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Allen Johnson
In your example yes, but you could make it atomic by placing the functionality in a function of it's own: ;; queue processing actions (defn process-item [queue] (println Processed item: (peek queue)) (pop queue)) ;; usage (let [queue (atom (into PersistentQueue/EMPTY [1 2 3]))] (swap!

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro
I see! Thank you. 2011/11/10 Allen Johnson akjohnso...@gmail.com: In your example yes, but you could make it atomic by placing the functionality in a function of it's own: ;; queue processing actions (defn process-item [queue]  (println Processed item: (peek queue))  (pop queue)) ;;

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Allen Johnson
Although now I see that this usage is breaking the side-effect free rule. So actually this is probably not what you want to do. :) Now I'm with you and thinking that atoms are not a proper fit for PersistentQueue. Maybe someone from the conj can shed some light on this. Allen On Wed, Nov 9,

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro
I see. You are right. A function passed to swap! must return only poped value, so peeked element from a queue is used only for side-effect in the function. 2011/11/10 Allen Johnson akjohnso...@gmail.com: Although now I see that this usage is breaking the side-effect free rule. So actually this

should partial accept a single argument?

2011-11-09 Thread Robert McIntyre
I'm curious why something like (partial *) doesn't work. reading the docstring, user (doc partial) - clojure.core/partial ([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 more]) Takes a function f and fewer than the normal arguments to f, and returns a fn

smallest unit of code requiring a CA

2011-11-09 Thread Chris Gray
Hi, I have a patch to the clojure compiler that I would like to submit. I haven't signed a CA, but the patch is quite small. Would it be possible to submit it without a CA? I have no objection to signing one; it would just be slightly embarassing to do so for such a small patch. :) The patch

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Meikel Brandmeyer (kotarak)
Hi, an atom can be sufficient, but you need to drop to a lower level. (defn !paws Like swap! but returns the old value of the atom. [a f args] (loop [] (let [old-value @a new-value (apply f old-value args)] (if (compare-and-set! a old-value new-value) old-value

Re: smallest unit of code requiring a CA

2011-11-09 Thread Charlie Griefer
Chris Gray wrote: I have a patch to the clojure compiler that I would like to submit. I haven't signed a CA, but the patch is quite small. Would it be possible to submit it without a CA? I have no objection to signing one; it would just be slightly embarassing to do so for such a small patch.