On Apr 20, 8:51 pm, Remco van 't Veer wrote:
> I am doing the following after an insert for a Derby database:
>
> (sql/with-query-results res
> ["VALUES IDENTITY_VAL_LOCAL()"]
> (first (vals (first res
>
> For MySQL it would be something like:
>
> (sql/with-query-results res
>
Nice! That's a lot better than depending on some quirky sql construct.
Thanks,
Remco
Saul Hazledine writes:
> On Apr 20, 8:51 pm, Remco van 't Veer wrote:
>> I am doing the following after an insert for a Derby database:
>>
>> (sql/with-query-results res
>> ["VALUES IDENTITY_VAL_LOCAL(
On Apr 21, 11:48 am, Remco van 't Veer wrote:
> Nice! That's a lot better than depending on some quirky sql construct.
Agreed. There's just one potential issue (which is the same issue I
have with
clojure.contrib.sql): it doesn't quote the column or table names,
meaning you
can't use such nice c
Hi,
I'm using an API to connect to a server which does not provide
constructors, just static methods to get & close connections.
How can I do something like ...
(try
(let [conn (API/getConnection ..)]
())
(catch ..)
(finally (if conn (API/closeConnection conn
Problem is that c
Hi,
I'm new to Clojure. I've been trying to go through the Programming
Clojure book and have run into a problem that I hope someone can fix.
I'm trying to use duck-streams, but it is missing from the clojure-
contrib JAR file (at least in build #81). I have listed the contents
of the JAR file a
I've been writing a program that requires the use of java.util.Calendar and
its descendent java.util.GregorianCalendar. One thing I'd hoped to do was
compare two Calendar objects with <, but the compiler complained that the
arguments to < didn't inherit from Number which was a surprise to me becaus
H! :D -- Clojure uses MVCC, which may help with this.
http://en.wikipedia.org/wiki/Multiversion_concurrency_control
But as Hickey points out, no one really knows yet because there aren't
enough high-core machines doing real work in the field.
http://groups.google.com/group/clojure/msg/cd3e77afb754
ka writes:
> How can I do something like ...
>
> (try
> (let [conn (API/getConnection ..)]
> ())
> (catch ..)
> (finally (if conn (API/closeConnection conn
>
> Problem is that conn is unavailable in the finally context.
Why not just have two try blocks?
(try
(let [conn (API/g
Hi,
On 21 Apr., 01:37, Neal wrote:
> All the documentation that I read seems to indicate that duck-streams
> is not deprecated.
c.c.ducks-streams is now named c.c.io.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to thi
Hi Neal,
Neal writes:
> I'm trying to use duck-streams, but it is missing from the clojure-
> contrib JAR file (at least in build #81). I have listed the contents
> of the JAR file and confirmed that it is not in there.
It sounds like you're using a 1.2 pre-release snapshot build of
clojure-co
Hello,
I've consulted a lot of already made presentations of clojure.
They are great, but I guess they may not suit my needs because it
seems to me that either:
* they are more 1 1/2 to 2 hours talks than 45 minutes
* they assume the "public" will not be relunctant to some terms like
"Lisp", "
The built-in Java comparison operators don't honor Comparable either.
In Clojure, it's about keeping (pure number) math fast.
If you are doing any nontrivial date work, I recommend you look at clj-
time (http://github.com/clj-sys/clj-time), a Clojure wrapper for Joda
Time. Then, if you real
Thanks for the reply Alex,
I thought of 2 try blocks, but seems over engineering doesn't it ? I
actually need to open 2 connections simultaneously, which would amount
to 3 nested try blocks. The whole code gets cluttered with all these
try finally (and one catch) statements.
(try
(let [con
On 2010 Apr 21, at 8:11 AM, Alex Osborne wrote:
I suggest you use the stable 1.1 releases of both Clojure and contrib
for your initial learning as it will better match the book. When
1.2 is
released stable I'm sure there will be a document written that
explains
the differences.
That isn't
On Wed, Apr 21, 2010 at 9:06 AM, ka wrote:
> Connection1 conn1 = null;
> Connection2 conn2 = null;
> try {
> conn1 = API1.getConnection ..;
> conn2 = API2.getConnection ..;
> ...
> }
You can't do that without using atoms or something, because you're assigning
to conn1 and conn2 twice. That'
The second level header tells you the branch (e.g. master). On the
left hand side is a list of branches (so you can click on e.g. 1.1.x).
Some ways I see this might be better:
(1) make clear what master currently equals (right now it is 1.2 alpha)
(2) highlight the branch info more with css
(3
Hi,
Something I don't understand: if the call to (API/getConnection ...)
fails, there is nothing to close, right ?
So for the problem of ensuring that any open connection is always
closed, the following pattern seems enough:
(try
(let [conn (API/getConnection ..)]
XXX)
(finally (API/clo
Oh, also see the source code for with-open :
http://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L2542
and also note that it allows you to declare bindings for opening
connections in sequence, and will take care of closing them in the
reverse order.
And to answer your questi
On Wed, Apr 21, 2010 at 9:37 AM, Laurent PETIT wrote:
> Hi,
>
> Something I don't understand: if the call to (API/getConnection ...)
> fails, there is nothing to close, right ?
>
> So for the problem of ensuring that any open connection is always
> closed, the following pattern seems enough:
>
> (
2010/4/21 Mark J. Reed :
> On Wed, Apr 21, 2010 at 9:37 AM, Laurent PETIT
> wrote:
>>
>> Hi,
>>
>> Something I don't understand: if the call to (API/getConnection ...)
>> fails, there is nothing to close, right ?
>>
>> So for the problem of ensuring that any open connection is always
>> closed, th
ka writes:
> The whole code gets cluttered with all these try finally (and one
> catch) statements.
>
> (try
> (let [conn1 (API1/getConnection ..)]
> (try
> (let [conn2 (API2/getConnection ..)]
> (try
> ( ... Do something with conn1 conn2
On Wednesday 21 April 2010 15:06:40 ka wrote:
Hi!
> The macro solution looks good. But with 2 different APIs for 2
> connections, I would need to write 2 macros right?
No, not really. You could also make the symbols for the API class an
additional arg to the macro, like:
(defmacro with-api-c
Stuart Halloway writes:
> The second level header tells you the branch (e.g. master). On the
> left hand side is a list of branches (so you can click on e.g. 1.1.x).
>
> Some ways I see this might be better:
>
> (1) make clear what master currently equals (right now it is 1.2 alpha)
> (2) highlig
2010/4/21 Alex Osborne :
> Stuart Halloway writes:
>
>> The second level header tells you the branch (e.g. master). On the
>> left hand side is a list of branches (so you can click on e.g. 1.1.x).
>>
>> Some ways I see this might be better:
>>
>> (1) make clear what master currently equals (right
Thanks all for replies.
Laurent, Alex you guys are right, the problem is only with aesthetics
of nesting / boilerplate. The nesting implementation semantically
expresses exactly what is required.
The with-cleanup macro seems really neat. Guess I'll learn macros
first and try to implement one.
Hi,
I don't know for sure, but it seems to me that perl 6 way of "writing"
exception handling is just a syntactic difference.
For an interesting shift in the possibilities of exception
handling/recovery, have a look at how Common Lisp does this with
conditions/restart :
http://www.gigamonkeys.com
The main thing about Perl6 in this case is that the catch/finally blocks are
inside the same scope as the try. But that's true in Clojure as well!
The difference is that Clojure's try is not itself a lexical binding scope;
you have to wrap one around it or within it via let. That's why I thought
Hey everyone,
I've had to code these guys up a few times:
(defn rotate
"Take a collection and left rotates it n steps. If n is negative,
the
collection is rotated right. Executes in O(n) time."
[n coll]
(let [c (count coll)]
(take c (drop (mod n c) (cycle coll)
(defn rotate-while
Hi All,
This e-mail is the product of some musing about refs, agents, and atoms. I
would like to offer some thoughts on a possible fourth reference type that
allows coordinated, asynchronous modification of state.
I would greatly appreciate comments from the community. Maybe some of these
ideas h
On 21 April 2010 17:23, Sean Devlin wrote:
> I've had to code these guys up a few times:
Nice functions!
I'd replace "collection" with "sequence" in the docstrings, though.
(And rename the args accordingly.)
You can also rewrite rotate as
(defn rotate [n s]
(lazy-cat (drop n s)
(
On 2010 Apr 21, at 9:31 AM, Stuart Halloway wrote:
The second level header tells you the branch (e.g. master). On the
left hand side is a list of branches (so you can click on e.g. 1.1.x).
Wow, that is quite subtle. As you click into contrib from clojure.org
it isn't very noticeable.
It als
You're right about changing the docstring to read ""sequence"
I think the lazy-cat version looses the ability to rotate in reverse,
which I've come to love from Ruby. Also, I have found use cases where
I want to rotate a period longer than the sequence length.
Thanks for the feedback, though.
Se
Hi All,
The moment one sends a post one starts thinking about it from a critical
perspective.
I think I may have grown so used to the idea that nothing in Clojure can
deadlock that I completely overlooked the possibility of deadlock in the
idea I proposed. If two serfs are the targets of two diff
On 21 April 2010 17:46, Sean Devlin wrote:
> I think the lazy-cat version looses the ability to rotate in reverse,
> which I've come to love from Ruby. Also, I have found use cases where
> I want to rotate a period longer than the sequence length.
Right. I don't mind rotate being strict, actuall
On Apr 20, 4:46 pm, Josh Stratton wrote:
> But I can't seem to call createGLPbuffer w/o getting an exception.
> Caused by: java.lang.IllegalArgumentException: No matching method:
> createGLPbuffer
This one is because the createGLPbuffer method is not static; you need
to have created a GLDrawable
On Wed, Apr 21, 2010 at 8:46 AM, Sean Devlin wrote:
> You're right about changing the docstring to read ""sequence"
>
> I think the lazy-cat version looses the ability to rotate in reverse,
> which I've come to love from Ruby. Also, I have found use cases where
> I want to rotate a period longer
Hi All -
I am having a hard time destructuring a nested data structure.
I am starting out with:
{:tag :column,
:attrs nil,
:content
[{:tag :name, :attrs nil, :content ["agecat"]}
{:tag :value, :attrs nil, :content ["nil"]}
{:tag :threshold, :attrs nil, :content ["0.05"]}]}
and am looking
Hmmm... good point. Now that I think about it, cycle is an artifact
of an early implementation.
On Apr 21, 1:01 pm, Mark Engelberg wrote:
> On Wed, Apr 21, 2010 at 8:46 AM, Sean Devlin wrote:
> > You're right about changing the docstring to read ""sequence"
>
> > I think the lazy-cat version l
Hmmm... I'm not sure destructuring is possible here. Would it be
easier to put an extractor fn in place?
(defn extract
[arg]
(apply hash-map (map (juxt :tag :content) (:content arg
Just a thought. I'm sure someone will have a better idea, though.
On Apr 21, 1:02 pm, Base wrote:
> Hi All
One could also do
(defn rotate [n s]
(let [[front back] (split-at (mod n (count s)) s)]
(concat back front)))
I was hoping for a moment to avoid calculating (count s) up front, but
that definitely does interfere with negative / large shifts, so never
mind that.
Sincerely,
Michał
--
You r
On Apr 19, 2010, at 5:55 , Daniel Glauser wrote:
> I would like to start a thread about Clojure use in production. Who
> is using it? And for what? What kind of load do you have on the
> system in terms of approximate transactions per day? Would you mind
> if your example was featured in a pr
Damn! This looks pretty good to me.
BTW - Love your blog and tutorial videos. they are incredibly helpful
and instructive. I have watched many of them more than once.
I really appreciate them.
Thanks Sean!!!
Bassel
On Apr 21, 12:07 pm, Sean Devlin wrote:
> Hmmm... I'm not sure destructuring
I like that version :)
On Apr 21, 1:11 pm, Michał Marczyk wrote:
> One could also do
>
> (defn rotate [n s]
> (let [[front back] (split-at (mod n (count s)) s)]
> (concat back front)))
>
> I was hoping for a moment to avoid calculating (count s) up front, but
> that definitely does interfer
On 21 April 2010 19:02, Base wrote:
> I am having a hard time destructuring a nested data structure.
>
> I am starting out with:
>
> {:tag :column,
> :attrs nil,
> :content
> [{:tag :name, :attrs nil, :content ["agecat"]}
> {:tag :value, :attrs nil, :content ["nil"]}
> {:tag :threshold, :attr
On 21 April 2010 19:35, Sean Devlin wrote:
> I like that version :)
:-)
In this case, rotate-while could be rewritten like so:
(defn rotate-with [pred s]
(let [[front back] (split-with pred s)]
(concat back front)))
And to round it off with ridiculous overengineering ;-) --
(defn rotate
Hey all,
I wrote a clojure version of the simplest functionality of wget. I
basically translated the java version into clojure code, but I'm not
quite happy with the wget-binary function because I use a loop, and I
feel like someone else has a more idiomatic solution to iterating
through a java-ar
If you're gonna over engineer use a protocol :-p
On Apr 21, 1:43 pm, Michał Marczyk wrote:
> On 21 April 2010 19:35, Sean Devlin wrote:
>
> > I like that version :)
>
> :-)
>
> In this case, rotate-while could be rewritten like so:
>
> (defn rotate-with [pred s]
> (let [[front back] (split-wit
At first glance, you should be requiring c.c.string, and don't write
your own blank? fn. That's the only low hanging fruit I see.
On Apr 21, 1:47 pm, Brent Millare wrote:
> Hey all,
>
> I wrote a clojure version of the simplest functionality of wget. I
> basically translated the java version int
Technically I didn't write my own cause I just copied pasted it ;)
For the purposes of this review, just consider that library code or a
reference so everyone knows what it does. :)
Sean Devlin wrote:
> At first glance, you should be requiring c.c.string, and don't write
> your own blank? fn. Th
In some languages, split-at is more performant than doing take and
drop separately. But in Clojure, split-at is simply defined as:
(defn split-at
"Returns a vector of [(take n coll) (drop n coll)]"
[n coll]
[(take n coll) (drop n coll)])
So by using split-at, you gain nothing other than t
What you are talking about is commonly referred to as a "barrier" in
parallel processing. All processes coordinated on a given barrier
must each reach the barrier before any one may cross it.
Simply putting a barrier check into the message queue of an Clojure
agent would not be sufficient as I un
Thanks Michal -
I have done a little digging into juxt (reading the great write up
that Sean previously posted here - great post by the way) and it is a
very slick way to deal with this issue. I am always amazed at the
createive and concise solutions that Clojure enables.
Thanks much for all of
Hmmm... we could talk about what's faster or measure it. Time to eat
my own damn dog food, I guess :)
Traveling now, I'll run the experiments in a few days when I get back
to my normal setup.
Sean
On Apr 21, 2:09 pm, Mark Engelberg wrote:
> In some languages, split-at is more performant than
On 21 April 2010 19:57, Sean Devlin wrote:
> If you're gonna over engineer use a protocol :-p
You're absolutely right, of course; I stand corrected! Here's my new
attempt at overengineering then:
(defprotocol Rotator
(rotate [self s]))
(extend-protocol Rotator
Number
(rotate
[self s]
== < <= > >= are all numeric equality/comparison functions.
= and 'compare are object equality/comparison functions.
On Apr 20, 6:47 pm, Bill Allen wrote:
> I've been writing a program that requires the use of java.util.Calendar and
> its descendent java.util.GregorianCalendar. One thing I'd h
On 21 April 2010 20:09, Mark Engelberg wrote:
> In some languages, split-at is more performant than doing take and
> drop separately. But in Clojure, split-at is simply defined as:
> (defn split-at
> "Returns a vector of [(take n coll) (drop n coll)]"
> [n coll]
> [(take n coll) (drop n coll
Thank you for taking the time to provide feedback.
> I can't think of a direct equivalent now, but it's straightforward
> enough to supply your own equivalent, like my compound? function
> (basically #(and (seq? %) (seq %))). This won't work on arrays and
> other things which seq can operate upon,
Hi all,
(For those who don't know, I'm the one who maintains the autodoc API
documentation.)
There are some great suggestions here and I'll try to pick up as many
as I can. More useful branch names and having the branch in the title
are no brainers and I'll try to get them in soon.
One resource
Kevin Livingston writes:
>> Not at all. next is basically #(seq (rest %)); you might want to use
>> it when the extra bit of strictness is beneficial to your code and you
>> shouldn't use it when it isn't.
>
> oh, ok. I saw some posts on using the new super-lazy lists / code and
> it implied tha
Thank you the LineNumberingPushbackReader is exactly what is needed.
The other metadata I can add fairly straightforwardly so good, this is
*far* more sane than that monstrosity I conjured up.
Kevin
On Apr 20, 3:15 am, Ilia Ablamonov wrote:
> I've encountered the same problem (as far as I unde
On Thursday, April 22, 2010, Tom Faulhaber wrote:
>
> A couple things I've also been thinking about are building in a search
> capability and building a "super-index" of not only core and contrib
> but various other external libraries that would link back to their
> doc.
I think building a super
I see downloads named
- Java SE (45MB)
- Java FX (76MB)
- Java (146MB) - apparently includes Sun Glassfish Server & what-not
I'm using OSX 10.5.8, and just want to install the easiest Netbeans
(with Enclojure) to for development with Compojure.
Would I use Compojure with Jetty? Apache (buil
If you've got the HD space, grab the most inclusive options. I
*think* the SE one will work, but I haven't tested it. Space is cheap
and all that.
On Apr 21, 7:55 pm, Sophie wrote:
> I see downloads named
> - Java SE (45MB)
> - Java FX (76MB)
> - Java (146MB) - apparently includes Sun Gla
On 22/04/2010, at 10:48 AM, Sean Devlin wrote:
> I think* the SE one will work, but I haven't tested it.
Yes it does.
Antony Blakey
--
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
If at first you don’t succeed, try, try again. Then quit. No use being a damn
fool about it
Yet another variation:
(defn conjugate [f g & [g-inv]]
(comp (or g-inv g) f g))
(defn composite [f f-inv n x]
(nth (iterate (if (pos? n) f f-inv) x) (abs n)))
(defn rotate-left [xs]
(when (seq xs) (concat (rest xs) [(first xs)])))
(def rotate-right (conjugate rotate-left reverse))
(defn
On 21 April 2010 22:58, Kevin Livingston
wrote:
> Thank you for taking the time to provide feedback.
Thank you for the insightful response!
I've posted the current state of my code -- which uses clojure.zip and
clojure.walk, among other things -- here:
http://gist.github.com/374764
> intention
On 22 April 2010 03:51, Per Vognsen wrote:
> Yet another variation:
>
> [...]
>
> Food for thought. :)
This is absolutely beautiful. I feel a tremendous joy now. :-)
Sincerely,
Michał
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this
Get the SE version. You can add other parts that are included in the other
versions (JavaFX, JEE, etc) using the NetBean's plugin mechanism if you find
that you need them. (In the menu bar select Tools -> Plugins)
On Wed, Apr 21, 2010 at 18:18, Sean Devlin wrote:
> If you've got the HD space, gr
On 2010 Apr 21, at 5:04 PM, Tom Faulhaber wrote:
(For those who don't know, I'm the one who maintains the autodoc API
documentation.)
Cool, thank you!
One resource to use is the index included with each API. (See the
index link in the left sidebar.)
I saw that, but you know, after finding
By the way, once you start looking for conjugation in common code
patterns, you see it everywhere. A less trivial example is the
Schwartzian transform for caching sorting keys:
(defn schwartz [key-fn] #(map (fn [x] [(key-fn x) x]) %))
(def unschwartz #(map second %))
(defn schwartz-sort [key-fn]
70 matches
Mail list logo