I have not read it all (yet), but what I have read is outstanding.
O'Reilly has made the table of contents and first chapter available
online. If you are at all curious, check it out. The first chapter
contains an exceptionally lucid and thorough section on destructuring.
I need to clarify something, since I unintentionally introduced
confusion into this discussion. The initial comment by faenvie
referred to the book Practical Clojure, a very good book (I own a
copy). I spaced out and thought that faenvie's comment concerned the
newly released Clojure
On Thu, Mar 29, 2012 at 12:18 AM, simon.T simon.j@gmail.com wrote:
The obvious way is like the following, which traverse the sequence 2 times.
...
The obvious way does not necessarily traverse the sequence twice. If
a sequence S satisfies the 'counted?' predicate, (count S) takes
constant
Very likely strikes me as a huge overstatement here. Most sequences
that you want to average won't be source-code literals, they'll be
lazy sequences, and those aren't counted
Point taken about lazy sequences. But the above was not intended to
suggest the sequence needs to be source code
Fogus, congratulations on the release. My thanks to you and all the
contributors. Marginalia rules.
--
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
This worked for me, with mysql 5.1 on Ubuntu Natty. The clojure_test
library and fruit table already existed.
(ns foo.core
(use [korma.db])
(use [korma.core]))
(defdb mydb {:subprotocol mysql
:subname //127.0.0.1:3306/clojure_test
:user clojure_test
Please add me to the 'Literate Programming' and 'Heroku Drinking' sessions.
--
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
There are dev dependencies (Marginalia, swank-clojure) that I want
added to every new Leiningen project. Is there a way to configure
lein so that these are automatically inserted into the project.clj
file on project creation?
Thank you,
David
--
You received this message because you are
My standard practice is to split the (Emacs) screen, one side is a
Clojure mode edit session, the other a repl. Best of both worlds.
One can easily build up complex expressions as required, and still
easily evaluate expressions in either side of the screen.
If you are not familiar with Emacs
The fact that currently having vals and keys return seqs in the same
order is not guaranteed by the documentation ?
At the recent Pragmatic Studio class I asked Rich and Stuart about
this very point. As I recall, Rich said vals and keys do behave as one
would hope, so that for a map m we can
Easy to grok is music to my ears.
I imagine most people who read my post would skip the proofs, and that
is just fine. The proofs are gruntwork. I wouldn't want the tedious
details to obscure the idea of the monad, which is quite elegant once
you get your head around it.
On Mon, Sep 6, 2010 at
I had too much time on my hands, and put together a Clojure-based
monad tutorial. If that kind of thing is your cup of tea, I'd love to
get some feedback on it. Here's the link
http://erl.nfshost.com/2010/09/05/bind-unit-and-all-that-2/
David
--
You received this message because you are
Yesterday I paid for my ticket, and scheduled a vacation day for Oct
22. Looking forward to it.
--
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
Here are a couple of implementations of a function I'm calling
'partition-when'. I feel like there should be a simpler way than
either of these. If you have one, I'd love to see it.
(defn partition-when;;version 1
Partition a sequence into subsequences; begin a new
On Sat, Aug 7, 2010 at 9:36 PM, gary ng garyng2...@gmail.com wrote:
if you don't mind about performance, this seems to be natural to me
user= (reverse (map reverse (reduce (fn [a e] (if (even? e) (cons [e] a)
(cons
(cons e (first a)) (rest a (list) [1 2 3 7 5 4 1])))
((1) (2 3 7 5) (4
Using a vector instead of a list as the accumulator makes it possible
to skip the mapping of reverse used in the earlier version of pw:
(defn pw [f? x]
(let [phi (fn [a e]
(if (f? e)
(cons [e] a )
(cons (conj (first a) e)
(rest
conj sounds like 'append' to me which I have no idea about the
performance characteristics in clojure(it is a no-no in F#, Haskell ++
is better but would grow the stack).
conj is not the same as append; it will insert the new element in the
smart (most efficient) way. For instance:
user (conj
Phil,
Just a personal opinion, but I'd urge you not to worry too much about
breaking changes just yet. The future value of doing the right thing
now outweighs the value of backwards compatibility in an application
as young as Lein.
To answer your direct question, I would not be affected by a
Here's an approach that doesn't use macros. I'm not sure I'd actually
do this, but here it is just for grins.
(defn bind [pred]
(fn [[x bool]] [x (and (pred x) bool)]))
(defn comp# [ preds ]
(let [ phi (reduce comp (map bind preds))]
(fn [x] (second (phi [x true])
user (filter
Here's my take:
(defn mmap [f coll]
(- coll
(partition 2)
(map (fn [[x y]] (f x y)
For instance:
user (mmap + (range 8))
(1 5 9 13)
user (mmap * (range 8))
(0 6 20 42)
You probably want to think about whether you'll see input sequences
with an odd number of terms, and how
I tried to run Jame's code, but the compiler (1.2 beta) squawked at me:
Unable to resolve symbol: indexed in this context
[Thrown class java.lang.Exception]
What do I need to pull in to pick up the indexed function?
On Sat, Jul 17, 2010 at 5:08 AM, James Reeves jree...@weavejester.com wrote:
I thought this problem was interesting enough to merit better
treatment than I can give it here, hence a blog post was in order.
Brief version: I think I have a lazy, functional, and idiomatic
implementation with decent performance. Check it out here:
I looked through some of my Project Euler solutions and found this
version. It is essentially the same as Uncle Bob's, but to my eye it
is a bit easier to read.
(defn least-nontrivial-divisor [n];; integer n 1
(loop [k 2]
(cond
(zero? (rem n k)) k ;; k divides n,
+1 DC
--
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, send email to
I have been fooling around with clojure.contrib.zip-filter.xml, and
feel like I'm stuck on something that should be simple.
Below is code showing what I'm talking about. I'm trying to parse some
simple xml, but can't quite get what I'm after.
(ns foo
(:require [clojure.xml :as xml])
(:require
James,
That worked beautifully. I knew it had to be simple, but I was
drawing a total blank.
Thank you,
David.
On Fri, Jan 22, 2010 at 9:53 PM, James Reeves
weavejes...@googlemail.com wrote:
On Jan 23, 2:29 am, David Cabana drcab...@gmail.com wrote:
What I'd like to get from 'tickets
Try this:
(use '[clojure.contrib.seq-utils :only (reductions)])
(defn left-total [lst]
(map vector lst
(reductions + (cons 0 lst
On Sun, Dec 27, 2009 at 8:36 PM, Conrad drc...@gmail.com wrote:
I've been writing Clojure code today and have noticed the same pattern
For years I have complained about the parts of java I don't like, and
lamented the stagnation of lisp. I never imagined anyone could
simultaneously attack both issues so beautifully and so successfully.
Bravo.
I have yet to make a dime using Clojure, but hope to some day. So as a
Christmas
If clean syntax really matters to you, you might want to take a look
at Mathematica. Its syntax is extremely simple and regular, very
lispy. Check out this link:
http://reference.wolfram.com/mathematica/tutorial/EverythingIsAnExpression.html
On Fri, Sep 11, 2009 at 10:43 AM, CuppoJava
is the same, except for an alternative
definition of the triangle numbers:
(defn triangle-numbers []
(lazy-cat [1] (map + (iterate inc 2) (triangle-numbers
This second approach dies with a stack overflow. Can anyone shed some
light on why?
Thank you.
David Cabana
On Jul 3, 11:11 pm, Gert Verhoog g...@feestpaleis.net wrote:
This seems to work:
(def triangle-numbers (lazy-cat [1] (map + (iterate inc 2) triangle-
numbers)))
cheers,
gert
Gert,
Your proposed change works very well.
It's interesting that a (seemingly) small change makes a huge
31 matches
Mail list logo