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)
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
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
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
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
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
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
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
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
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
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
(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
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
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
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,
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
project.clj:
---
(defproject testsqlite 1.0.0-SNAPSHOT
:description FIXME: write description
:disable-deps-clean false
:dependencies [[org.clojure/clojure
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]
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
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
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
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)
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
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]
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
(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
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
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
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 %)
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)
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
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,
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
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
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
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!
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))
;;
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,
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
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
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
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
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.
58 matches
Mail list logo