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 clojure@googlegro
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 tha
2010/11/9 Greg :
> 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 my favorite gam
Hi,
On 9 Nov., 00:31, "Gijs S." 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.
Sincerely
Meikel
Hi,
On 9 Nov., 02:42, Greg 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]
(when-let [s (seq xs)]
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 wrote:
> Hey Shantanu,
>
> I mention how to do this here:
>
>
> http://gregslepak.posterous.com/clojure-development-with-inte
> 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
On Mon, Nov 8, 2010 at 10:58 PM, Greg 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.
>
> Whereas,
>
>
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 a
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
On Nov 8, 2010, at 6:29 PM, Ken Wesson wrote:
> On Mon, Nov 8, 2010 at 9:08 PM, Greg 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 tw
On Mon, Nov 8, 2010 at 9:08 PM, Greg 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 first and l
On Nov 8, 2010, at 6:04 PM, Ken Wesson wrote:
> On Mon, Nov 8, 2010 at 8:55 PM, Greg 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 a typo. :-p
On Mon, Nov 8, 2010 at 8:55 PM, Greg 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
> gears will turn
On Mon, Nov 8, 2010 at 8:34 PM, Greg 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 (parents n)))
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 a
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 doe
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 s
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 reas
(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 t
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
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 a
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 ba
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
N
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.
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))
(rec
(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 traversal
(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
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 f
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
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 wrote:
> So... I tried, and failed
2010/11/8 Alan
> 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
On Mon, Nov 8, 2010 at 5:45 AM, Stuart Sierra
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 developing against a fairly
blee
2010/11/8 Greg
> 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 transients, and wh
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 transform
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 t
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 sugges
>> 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 s
Great, that did it. Thanks.
On Nov 8, 11:01 am, Laurent PETIT 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
On Mon, Nov 8, 2010 at 2:01 PM, Laurent PETIT 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 the value of
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 systemati
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 ev
> 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 de
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
o
>From the README.txt on github:
===
Run the following command in this directory:
mvn package
This will produce the file target/clojure-contrib-${VERSION}.jar that
you can add to your Java classpath.
===
I understand the project
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 (= (:us
Hello Sunil,
> Just to elaborate on what I said before, session# creates a new symbol
> using gensym with a prefix session. It avoids accidental variable capture.
Thanks for the quick reply. However I *do* want the symbol name to be
"session" since the
code in "body" uses it.
All the best,
--
Mi
Miki:
This is what Sunil is talking about:
http://en.wikipedia.org/wiki/Common_Lisp#Variable_capture_and_shadowing
The "symbol#" string is a part of how syntax-quote works. Read
http://clojure.org/reader#The Reader--Macro characters
On Mon, Nov 8, 2010 at 10:12 AM, Sunil S Nandihalli
wrote:
>
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
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 t
use session# instead of session .. I think that should work.. try it..
On Mon, Nov 8, 2010 at 8:32 PM, Miki wrote:
> Greetings,
>
> I need some help with the 1'st macro I'm writing.
> I have many tests in the format
>
> (deftest user-test
> (let [session (test-session :authorization)]
>(dis
Greetings,
I need some help with the 1'st macro I'm writing.
I have many tests in the format
(deftest user-test
(let [session (test-session :authorization)]
(dispatcher "USER bugs" session)
(is (= (:user @session) "bugs"))
(is (= (get-one session) "+OK Hello bugs\n"
I've tried
On Fri, Nov 5, 2010 at 9:41 PM, Scott Jaderholm wrote:
> This sounds like a problem with emacs server/client that might be unrelated
> to Clojure or Slime. Some configurations of emacs will start a server mode
> so that you can run emacsclient and have a new frame pop up instantaneously.
> If you
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 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 wrote:
> Thanx Stuart!
>
> As a general point of protocol, would the Clojure team prefer folks
> test against the Alpha builds or the (master) SNA
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
Gijs,
I would put the return value of the assoc! call as one of the values
of the loop.
Otherwise, as far as I understand, you may lose values associated with
the fl transient map.
(Transient maps should not be used any differently than regular maps.
It's just their internals that are different.)
57 matches
Mail list logo