This series of posts can be useful to
you http://stevelosh.com/blog/2012/07/caves-of-clojure-01/
Juan Manuel
--
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
My solution:
(defn lis [s]
(- s
(partition 2 1)
(partition-by (partial apply =))
(filter (fn [[[a b]]] ( a b)))
(reduce (fn [m s] (if ( (count s) (count m)) s m)) [])
(#(cons (ffirst %) (map second %)
The strategy is (given the vector [3 2 1 2 4 2]
- I
On Wednesday, June 13, 2012 5:47:55 PM UTC+2, Andy C wrote:
On Wed, Jun 13, 2012 at 4:05 AM, JuanManuel Gimeno Illa wrote:
My solution:
(defn lis [s]
(- s
(partition 2 1)
(partition-by (partial apply =))
(filter (fn [[[a b]]] ( a b
Can you elaborate some suggestions?
Juan Manuel
On Friday, June 8, 2012 3:44:16 PM UTC+2, Stuart Sierra wrote:
The ants demo is definitely dated. It's not terrible, but the code could
use some polishing/simplifying using newer additions to the language.
-S
--
You received this message
I'm preparing an informal presentation about clojure concurrency and my
plan is use the ant colony demo. Given the amount of changes in clojure
since the time that code was written I wonder if the code is still
idiomatic or parts of it should be adapted to modern clojure.
Any ideas would be
On Friday, April 13, 2012 9:11:07 PM UTC+2, faenvie wrote:
in addition there could be a separate book 'professional clojure' that
focuses on extensions and advanced topics of the clojure cosmos:
clojurescript, monads, continuations, building dsl, core.logic, ring,
korma, noir ... this
Playing with some problems of 4clojure, I wanted to make a map which, for
each empty collection, returns a keyword. But it seems that it is
impossible to have both an empty list and an empty vector in the same map.
user= {() :list}
{() :list}
user= {() :list [] :vector}
IllegalArgumentException
user= {'(1) :list [1] :vector}
{(1) :vector}
...but I don't know what's going on.
On Tuesday, April 3, 2012 9:11:50 AM UTC+2, JuanManuel Gimeno Illa wrote:
Playing with some problems of 4clojure, I wanted to make a map which, for
each empty collection, returns a keyword. But it seems
Thanks, I'll give it a try.
Juan Manuel
On Thursday, March 22, 2012 4:21:19 PM UTC+1, Moritz Ulrich wrote:
Do you really need Aquamacs? My experience is that it causes more
trouble than it's worth.
I'd recommend using vanilla Emacs from [1] or building from source
with the --cocoa switch.
I'm having problems typing character literals in aquamacs when clojure-mode
and paredit are active. When I type the character \, emacs complains with:
after 0 kwd macro iterations: Wrong type argument: characterp, -1
Any idea of what is going on?
Thanks,
Juan Manuel
--
You received this
Problem 21 is: Write a function which returns the Nth element from a
sequence.
My solution is:
(fn [[f r] n]
(if (zero? n)
f
(recur r (dec n)
but it is marked as incorrect. Opening a REPL, and defining it with defn:
(defn mynth
[[f r] n]
(if
Thanks !!!
It's wonderful how much time can be wasted because a bad copypaste :-)
Juan Manuel
On Friday, March 16, 2012 9:39:09 AM UTC+1, Meikel Brandmeyer (kotarak)
wrote:
Hi,
there is no 6th element in your example. That's why you get nil.
Clojure 1.3.0
user= ((fn [[f r] n] (if
Variables - but am getting the same error!
When I press cmd+R a pop-up window says Cake started - it's the ctrl
+X command that's not working.
Thanks,
James
On Feb 29, 7:28 pm, JuanManuel Gimeno Illa jmgim...@gmail.com wrote:
Maybe it is that you haven't included the directory where
-goodness/
Juan Manuel
/ James
On Mar 1, 3:17 pm, JuanManuel Gimeno Illa jmgim...@gmail.com wrote:
The version of cake I'm using is the master branch from:
https://github.com/ninjudd/cake
and the version of clojure-textmate is the master branch from
https://github.com
, JuanManuel Gimeno Illa jmgim...@gmail.com wrote:
El jueves 1 de marzo de 2012 15:44:26 UTC+1, James escribió:
I was using the same branches.
Another piece of the puzzle. My global .cake/project.clj is:
(defproject global 0.0.0
:description Don't rename this project
Maybe it is that you haven't included the directory where the cake
executable is in the text mate PATH.
For instance, my PATH is defined
as: /Users/jmgimeno/Local/cake/bin:/usr/bin
because my cake executable is in /Users/jmgimeno/Local/cake and textmate
needs /usr/bin for other things.
To
A similar version:
(defn combinations [[x xs]]
(if xs
(for [e x c (combinations xs)]
(cons e c))
(map list x)))
Juan Manuel
El lunes 27 de febrero de 2012 15:23:30 UTC+1, Bill Caputo escribió:
Here's a version that uses destructuring (but is otherwise the
I'm trying to understand the difference between next and rest, so I've
taken clojure's implementation of some of the collection functions to view
how those functions use them. The source code of reduce is (I've marked in
red the calls than I do not understand).
(def
reduce
(fn r
One implementation using only one recursive function and the sequence
library:
(defn split-at-subsequence [mark input]
(when-let [sequence (seq input)]
(let [len (count mark)
pieces (partition-all len 1 sequence)
[fst rst] (split-with #(not= mark %)
Maybe this version is clearer:
(defn split-at-subsequence [mark input]
(when-let [sequence (seq input)]
(let [len (count mark)
pieces (partition-all len 1 sequence)
[fst rst] (split-with #(not= mark %) pieces)
head (map first
One variation making the lazy-sequence only over the pieces:
(defn split-at-subsequence [mark input]
(let [len (count mark)
split-at-subseq (fn split-at-subseq [pieces]
(when (seq pieces)
(let [[fst rst]
El viernes 24 de febrero de 2012 18:46:03 UTC+1, Cedric Greevey escribió:
On Fri, Feb 24, 2012 at 11:30 AM, JuanManuel Gimeno Illa wrote:
I think it would be better to create the lazy-seq over a function that
uses
the pieces in order to not to explode input with partition-all and
de
This solution, I think, does not do more map first than needed, avoids
computing len and pieces more than once, uses nthnext to avoid extra cost
of drop and computes the example
(first (second (split-at-subsequence [1 2] (range
(defn split-at-subsequence [mark input]
(when-let
I'm trying to use :or patterns with records but I'm getting an error and
I'm not sure if I have found a bug (or a not-implemented-yet) or if its
the intended behavior (and there are good reasons for it).
Without :or patterns I can do:
(let [x {:a 1 :b 2}]
(clojure.core.match/match [x]
I'm using 0.2.0-alpha8
Juan Manuel
--
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
El martes 3 de enero de 2012 15:30:24 UTC+1, David Nolen escribió:
Please try using master. If that works for you, I can cut another alpha
release.
Now the example works and I've found no problems using it with my code.
Thanks,
Juan Manuel
--
You received this message because you are
I'm not 100% sure but this is a side effect of the property that symbols
can be used as functions that find themselves on maps.
For instance:
(def m {'a 1 'b 2 'c 3})
('a m)
;= 1
('b m)
;= 2
and, when the symbols is not found, we have:
('d m)
;= nilurn
('d m :nono)
;= :nono
So a symbol is a
I've been writing some code which adds some keywords in metadata associated
to vars. Initially I used namespaces keywords to not collide with other
keywords. The problem is that having to namespace these keywords makes the
code, at least, ugly. Is it any consensus in the use of keywords in
El sábado 24 de diciembre de 2011 05:21:33 UTC+1, David Nolen escribió:
I'd like to fully support types/records as they provide significant
performance benefits.
Now I'm not very much interested in performance. I have added the
possibility to define datatypes that use lazy constructors
Gimeno Illa jmgi...@gmail.com
wrote:
I've been writing some code which adds some keywords in metadata
associated to vars. Initially I used namespaces keywords to not collide
with other keywords. The problem is that having to namespace these keywords
makes the code, at least, ugly. Is it any
Finally I have considered your advice and namespaced the keywords.
Thanks,
Juan Manuel
El miércoles 28 de diciembre de 2011 12:33:22 UTC+1, Meikel Brandmeyer
(kotarak) escribió:
Hi,
Am 28.12.2011 um 11:09 schrieb JuanManuel Gimeno Illa:
My main concern is that when using reader macros
Hi all,
I've been working a proof of concept implementation of some data
structures from Okasaki's book Purely functional data structures. The
implementations tries to follow the ML implementation describes in the book
so I have defined some macros than use clojure.match to allow patter
Very, very cool. Is this just sugar for map pattern matching?
I use only vector matching. When I define a datatype, for instance:
(defdatatype ::Type Constant (Expr x y))
I create symbols Constant, with value ::Constant and Expr with value (fn [x
y] [::Expr x y]). That way I can use the
I'm looking for a clojure library to perfomr matrix manipulation a la numpy.
The best candidate I've found is infer.matrix but I wonder if there is a
hidden jewel to discover.
Anyone has other suggestions?
Thanks,
Juan Manuel
--
You received this message because you are subscribed to the
I'm sure this can be simplyfied:
(defn mlg [attrs data]
(if (empty? attrs)
[ (reduce + (map :mv data)) {:children data}]
(let [parts (group-by (first attrs) data)
subtrees (map (fn [[value data]]
[value (mlg (rest attrs) (map #(dissoc % (first
I'm sure this can be simplyfied:
(defn mlg [attrs data]
(if (empty? attrs)
[ (reduce + (map :mv data)) {:children data}]
(let [parts (group-by (first attrs) data)
subtrees (map (fn [[value data]]
[value (mlg (rest attrs) (map #(dissoc % (first
36 matches
Mail list logo