Hi,
Thanks a lot for your reply. I thought Java interoperability was
one of the key points for Clojure a language for the JVM, having a
pure Clojure version that limits interoperability in the JVM isn't
quite in this spirit.
The first project (clj-ds) seems quite what I need now, but I
Hi Sean,
Not sure I understand the question. If you're designing a library,
you probably want to test on both.
-S
On Nov 7, 3:57 pm, Sean Corfield seancorfi...@gmail.com wrote:
Thanx Stuart!
As a general point of protocol, would the Clojure team prefer folks
test against the Alpha builds
Indeed I was not using the transients correctly. Transients are not
designed to be bashed in-place. (http://clojure.org/transients)
The gist is updated with a version that first worked without the
transients and then had the transient operations added. (https://
gist.github.com/666228)
The times
Hi Miki,
Just to elaborate on what I said before, session# creates a new symbol
using gensym with a prefix session. It avoids accidental variable capture.
Sunil.
On Mon, Nov 8, 2010 at 8:40 PM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
use session# instead of session .. I think
This. Macros, unless you do some gymnastics, always generate fully-
qualified names, which is a Good Thing. You can't bind qnames, in let
or function arguments or anywhere else. But clojure provides you with
a very useful var# syntax: this creates a new symbol which is
guaranteed to be unique, and
As in the below (which doesn't work).
(defmacro def-dispatcher-test [test-name state command body]
`(deftest ~test-name
(let [session (test-session ~state)]
(dispatcher ~command session)
~...@body)))
(def-dispatcher-test user-test :authorization USER bugs
(is (= (:user
Hi all,
I was testing some code under Clojure 1.3 alpha 3 that works correctly
in Clojure 1.2 and got the following error:
CompilerException java.lang.IllegalArgumentException: Only long and
double primitives are supported
For some reason I don't get a full stack trace saying where the error
Also - I'm a bit worried as the message suggests that Clojure won't
support int and float primitives for some purposes - which are pretty
essential for Java interop - surely that can't be true? Or is this
just a temporary thing during the Alpha development?
longs and doubles will be the
Hi,
session will be fully qualified. this is the default behavior.
If you really want it, then you can treat it as the result of the
unquoting of a value which resolves to a symbol.
So you'll use ~ to say you want the value of (quote session)
(quote session returns the symbol session when
Sticking to long and double gets away from Java semantic but it is done
to improve numeric performances. You can actually hint in 1,3 on the return
type of a function to avoid automatic boxing and have your code work
entirely with a native type. Boxing if I recall correctly will
convert
On Mon, Nov 8, 2010 at 2:01 PM, Laurent PETIT laurent.pe...@gmail.com wrote:
Hi,
session will be fully qualified. this is the default behavior.
If you really want it, then you can treat it as the result of the
unquoting of a value which resolves to a symbol.
So you'll use ~ to say you want
Great, that did it. Thanks.
On Nov 8, 11:01 am, Laurent PETIT laurent.pe...@gmail.com wrote:
Hi,
session will be fully qualified. this is the default behavior.
If you really want it, then you can treat it as the result of the
unquoting of a value which resolves to a symbol.
So you'll use ~
that is, use ~'session instead of just session.
What you really want in this case is a binding. Try this:
...
The added parameter just before the body specifies a name to bind the
session object to; this name can then be used in the body.
This is good a well, but I prefer to dark magic
Yes, those are the two choices. Ken's suggestion is the cleanest, and
you definitely should do that in cases where it's not burdensome.
Here, where it's a macro for private testing, and you are certain not
to forget that it's magically binding session for you, then go ahead
and use Laurent's
I played with this some more, and it seems like for accessing an
element in a vector, (v idx) is a bit faster than (nth v idx). If you
replace this line (line 52 in the gist)...
fl (nth freq-layer layer)]
with:
fl (freq-layer layer)]
...the total time needed to compute frequencies for all 92
So... I tried, and failed, to use transients properly.
The function below, new-gen, takes a sequence of nodes and creates a new
generation of nodes out of them using the functions transform-left and
transform-right.
Each node in the sequence has two children, one is created with
2010/11/8 Greg g...@kinostudios.com
So... I tried, and failed, to use transients properly.
It's also, somehow, a fail of using clojure datastructures functionally.
I mean, transients must be used as you would used their persistent
counterparts.
Generally, you would first write the code without
On Mon, Nov 8, 2010 at 5:45 AM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
Not sure I understand the question. If you're designing a library,
you probably want to test on both.
I meant more from the point of view of providing feedback to the
Clojure team. If someone is comfortable
2010/11/8 Alan a...@malloys.org
Yes, those are the two choices. Ken's suggestion is the cleanest, and
you definitely should do that in cases where it's not burdensome.
Here, where it's a macro for private testing, and you are certain not
to forget that it's magically binding session for you,
One thing you could do is to use loop and recur as your looping
construct - every time you enter into the loop, your variable will be
re-bound to the value you used in recur - in this fashion, you can
avoid bashing the transient in place.
On Nov 8, 1:45 pm, Greg g...@kinostudios.com wrote:
So...
On Nov 8, 2010, at 2:45 PM, Paul Mooser wrote:
One thing you could do is to use loop and recur as your looping
construct - every time you enter into the loop, your variable will be
re-bound to the value you used in recur - in this fashion, you can
avoid bashing the transient in place.
Yes, I
On Nov 8, 2010, at 1:59 PM, Laurent PETIT wrote:
I would invite you to try write your code with predicate-based hofs such as
iterate-while, filter, remove, reduce, map, etc.
I did attempt this, but the algorithm doesn't seem to lend itself nicely to
this approach, which is why I was hoping
(defn new-gen [a]
(loop [a a t (transient [])]
(if (empty? a)
(distinct #(= (:val %1) (:val %2)) (persistent! t))
(let [f (first a)]
(recur (rest a)
(loop [c [(transform-left f) (transform-right f)] t t]
(if (empty? c)
t
(defn new-gen [a]
(distinct #(= (:val %1) (:val %2))
(for [f a
n [(transform-left f) (transform-right f)]
:when (not (contains? #(= (:val n) %) (map :val (parents n]
n)))
is more functional but possibly slower.
If you really just want the first one in
Yeah, golfing at late night..
(defn distinct-by
[keyfn coll]
(let [step (fn step [xs seen]
(lazy-seq
((fn [[f :as xs] seen]
(when-let [s (seq xs)]
(if (contains? seen (keyfn f))
Hi again,
Am 09.11.2010 um 00:24 schrieb Meikel Brandmeyer:
(defn new-gen
[a]
(- a
(mapcat (juxt transform-left transform-right))
(remove (fn [n] (some #(= (:val n) (:val %)) (parents n
(distinct-by :val)))
Maybe you also want to exchange the distinct-by and remove.
I also get consistent better times with (freq-layer layer) vs. (nth
freq-layer layer).
Gist updated: https://gist.github.com/666228
-Gijs
--
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
out of curiosity, if 2 siblings have the same value for their :value
attribute, you just keep the first one you encounter, and throw away the
others with the same :value attribute ? Is it because they also have the
same attributes altogether, or because you're relying on an importance
criteria
One problem I've heard with creating Android apps in languages such as
Clojure or Scala is the dependencies (in Clojure's case, probably
clojure.jar and clojure-contrib.jar) that are brought in increase the
size of the app. Those dependencies may be very small when deployed
as a server app or on
There are several forces at play here that work against clojure on
android being a huge force. The size of hello world in clojure is
currently 4.21MB. This is roughly 4 for clojure and .21 for the app.
This is compared to the same app in java at .2MB. Bring in c.c and you
have a whole lot
(Thanks everyone for all the replies! I'll address each response individually).
Awesome, thanks Ken!
This solution is really cool, and it is what I was attempting to go for but my
inexperience with this sort of functional style prevented me from seeing it.
Of the solutions presented though, I
Yeah, I know you wouldn't make such a dreadful recommendation without
prompting. I just want to make sure *he* knows that this is considered
a little smelly: Clojure gives you the power to do stuff like this,
and it's appropriate to use it sometimes, but you should be careful -
it's hard for a
On Nov 8, 2010, at 3:11 PM, Ken Wesson wrote:
(defn new-gen [a]
(distinct #(= (:val %1) (:val %2))
(for [f a
n [(transform-left f) (transform-right f)]
:when (not (contains? #(= (:val n) %) (map :val (parents n]
n)))
is more functional but possibly slower.
Thanks Meikel!
This is a really neat way of writing it, I'm going to need to study this one as
it uses some functions I'm not super familiar with (so thanks very much for
introducing me to them and coming up with this elegant example!).
The only thing is that while your distinct-by function
On Nov 8, 2010, at 3:37 PM, Laurent PETIT wrote:
out of curiosity, if 2 siblings have the same value for their :value
attribute, you just keep the first one you encounter, and throw away the
others with the same :value attribute ?
Yes.
Is it because they also have the same attributes
On Mon, Nov 8, 2010 at 8:34 PM, Greg g...@kinostudios.com wrote:
On Nov 8, 2010, at 3:11 PM, Ken Wesson wrote:
(defn new-gen [a]
(distinct #(= (:val %1) (:val %2))
(for [f a
n [(transform-left f) (transform-right f)]
:when (not (contains? #(= (:val n) %) (map :val
On Mon, Nov 8, 2010 at 8:55 PM, Greg g...@kinostudios.com wrote:
I'm currently in the process of learning Clojure, and as an ex cerise
Did you mean exercise? An ex cerise would be something that used to
be a cherry. :)
The gears are initially set to 3,3,3. Pull the right lever and the top two
On Nov 8, 2010, at 6:04 PM, Ken Wesson wrote:
On Mon, Nov 8, 2010 at 8:55 PM, Greg g...@kinostudios.com wrote:
I'm currently in the process of learning Clojure, and as an ex cerise
Did you mean exercise? An ex cerise would be something that used to
be a cherry. :)
Hehehe... Yes... that was
On Mon, Nov 8, 2010 at 9:08 PM, Greg g...@kinostudios.com wrote:
Ah, I see that this wasn't immediately clear from my explanation: they change
by 1, but 3 wraps to 1. I.e. the chain is:
3 = 1 = 2 = 3 = 1 = etc...
I assume only the first two and last two can be changed together. If
the
On Nov 8, 2010, at 6:29 PM, Ken Wesson wrote:
On Mon, Nov 8, 2010 at 9:08 PM, Greg g...@kinostudios.com wrote:
Ah, I see that this wasn't immediately clear from my explanation: they
change by 1, but 3 wraps to 1. I.e. the chain is:
3 = 1 = 2 = 3 = 1 = etc...
I assume only the
On Nov 8, 2010, at 7:49 PM, Greg wrote:
So I'm unclear on what 3 (mod 3) means...
I may have answered my own question, let me know:
6 = 3 (mod 3)
That means that *both* sides are modulo 3, in which case 0 = 0.
Whereas,
(a + c) = 3 != 2 (mod 3)
Makes sense because:
0
Hey Shantanu,
I mention how to do this here:
http://gregslepak.posterous.com/clojure-development-with-intellijs-la-clojure
- Greg
On Nov 7, 2010, at 12:10 PM, Shantanu Kumar wrote:
For now I just went ahead and replaced existing LaClojure/clojure.jar
(1.1) with clojure-1.2.0.jar
On Mon, Nov 8, 2010 at 10:58 PM, Greg g...@kinostudios.com wrote:
On Nov 8, 2010, at 7:49 PM, Greg wrote:
So I'm unclear on what 3 (mod 3) means...
I may have answered my own question, let me know:
6 = 3 (mod 3)
That means that *both* sides are modulo 3, in which case 0 = 0.
I just want to make sure *he* knows that this is considered
a little smelly: Clojure gives you the power to do stuff like this,
and it's appropriate to use it sometimes, but you should be careful -
it's hard for a reason.
I know it smells, and regularly I won't use such a thing (didn't like
Ah, I got it. Thanks! It's surprising how non-intuitive it is though
to switch to another Clojure version in La Clojure.
Regards,
Shantanu
On Nov 9, 9:01 am, Greg g...@kinostudios.com wrote:
Hey Shantanu,
I mention how to do this here:
Hi,
On 9 Nov., 02:42, Greg g...@kinostudios.com wrote:
The only thing is that while your distinct-by function doesn't seem to work...
Bleh. :( It *was* late in the night...
(defn distinct-by
[keyfn coll]
(let [step (fn step [xs seen]
(lazy-seq
((fn [[f :as xs] seen]
Hi,
On 9 Nov., 00:31, Gijs S. gijsstuur...@gmail.com wrote:
I also get consistent better times with (freq-layer layer) vs. (nth
freq-layer layer).
This is to be expected, because (freq-layer layer) acts directly on
the datastructure, while (nth freq-layer layer) goes through another
function.
2010/11/9 Greg g...@kinostudios.com:
I think to answer both questions I should explain the context of this
problem.
I'm currently in the process of learning Clojure, and as an ex cerise to
assist in this endeavor I set about solving a problem presented in the
classic game called Myst.
One of
Slice is an experimental not-production-ready web library for writing and
composing snippets of html, css, and js that are written in Clojure.
The motivation is that I wanted the html, css, and js for a slice of a
webpage to be next to each other in the source, not in three separate files,
and
For fun, I made my own code for proving your result:
https://gist.github.com/668830
(contains? (reachable-states [3 3 3]) [2 2 1])
= false
//raek
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
50 matches
Mail list logo