On Fri, Apr 16, 2010 at 7:00 AM, Aaron Cohen wrote:
> This is actually a fairly good bug report, I think.
>
> If you look in clojure.main, the "eval-opt" fuction uses
> "with-in-str", which unnecessarily interferes with using *in* within
> the expression you are trying to evaluate. I was actually
Many thanks to Meikel Brandmeyer, whose code (after a one-character
typo correction) worked the first time. As soon as I saw it, I
understood every line of it; the problem was, it wouldn't have
occurred to me to put all those elements (which, individually, I
understood) together in just that way. M
Actually I've got to disagree here, it is really easy to do.
Here is one example of something esessoms did:
http://github.com/esessoms/clj-interface
And here is an example of the rewrite I did when I decided that his
version didn't quite do what I wanted.
http://gist.github.com/369114
On Apr 15
ok, I tested it, it works
thanks Brian
--
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 unsubscri
On Fri, Apr 16, 2010 at 3:46 PM, Brian Wolf wrote:
> Hi, Is it possible to call a multimethod in a map? In this simplified
> example, I just want to increment every element of the array when the
> multimethod is called (my real application is operating on sets of
> hash tables ie database )
>
>
Hi, Is it possible to call a multimethod in a map? In this simplified
example, I just want to increment every element of the array when the
multimethod is called (my real application is operating on sets of
hash tables ie database )
(defmulti cc (fn [c v] [(:category c) ]))
(defmethod cc [:toys
On Apr 16, 8:25 am, Razvan wrote:
> Hi,
>
> Is this the intended behavior?
>
> (sorted-set-by (constantly 0) 1 2 3 4) returns #{1}.
>
> I would expect the set to contain all the elements, and the comparator
> to only affect sort order.
I expected the same thing at first, but the behavior appears
On Sat, Apr 17, 2010 at 1:05 AM, Per Vognsen wrote:
> You can only do slow
> linear-time lookups by traversing the tree's nodes exhaustively.
Correction: You do not have to do a linear search on the whole tree
but only on the subset of the tree for which the comparator returns 0
with your queried
> Equality and ordinality are not the same thing. It should be
> perfectly reasonable to hand someone a set of unique objects sorted by
> some non-unique attribute of the elements of the set.
Sure, it's perfectly reasonable but it implies a different data
structure. It sounds like you want a data
On 16.04.2010, at 19:49, B Smith-Mannschott wrote:
> A few representative examples of the failures I'm seeing
>
...
> FAIL in (complex-conjugate) (run-test1347341999632195512.clj:44)
> expected: (= (conjugate (complex 1 2)) (complex 1 -2))
Tangent:
On Fri, Apr 16, 2010 at 7:41 PM, Douglas Philips wrote:
> (1) http://clojure.org/data_structures says:
> ... seq returns a sequence of map entries, which are key/value pairs. ...
>
> I haven't yet found where in the docs a pair is defined, so I am guessing
> that the concrete type (list,
I'm building af2a730 "some tests for c.c.io byte-level support" of
clojure-contrib.
I'm seeing clojure.contrib.test-complex-numbers error out the maven
build with 4 failures and 253 errors on two of the five platforms at
my disposal.
Only my linux-based netbooks fail the build. JDK version does n
The problem is you're unnecessarily conflating the value by which to
base a sort (x and y in your example) with the elements of the set.
Equality and ordinality are not the same thing. It should be
perfectly reasonable to hand someone a set of unique objects sorted by
some non-unique attribute of
On Apr 16, 5:25 pm, Asim Jalis wrote:
> > It does conform to the pattern that the bound variable precedes the
> > value to bind in forms like let. A benefit of this ordering is that
> > destructuring patterns like {:keys [a b c]} are unambiguous.
>
> Hi Per,
>
> Could you explain the rationale f
The function you give to map needs to accept the same number of args
as there are collections. You're passing one map, thus the function
will be called with one arg. In the case of maps the "element" is a
key/value pair, which can then be destructured in the function.
On Apr 15, 8:53 pm, Derek w
On Sat, Apr 17, 2010 at 12:01 AM, Sean Devlin wrote:
> I know you might not like it, but there is a convention in JavaLand
> that a comparator value of 0 is identical in a sorted collection.
It's not a Java convention. It's intrinsic to the business of sorting.
For sorting to give well-defined re
CORRECTION, DON'T SHOOT!!
I should have order & value, not order & identity.
On Apr 16, 1:01 pm, Sean Devlin wrote:
> I think the fns you're interested in are sort and sort-by, not sorted-
> set-by.
>
> I know you might not like it, but there is a convention in JavaLand
> that a comparator v
I think the fns you're interested in are sort and sort-by, not sorted-
set-by.
I know you might not like it, but there is a convention in JavaLand
that a comparator value of 0 is identical in a sorted collection.
This causes orthogonal concepts of order & identity to be entwined.
Sean
On Apr 16,
Maybe the example was poorly picked but the point stands: if you're
asking for a sorted set based on a comparator, you should expect
duplicate elements as dictated by comparator to be eliminated. If you
wanted to sort a set of people by age, you wouldn't use a sorted set
but a sorted sequence. That
Why should sorting be related to the primary key? You should be able
to sort on any attribute. If you wanted to sort a set of people by age
would it make sense to only retain one person of each age? Sort order
and identity should be orthogonal. Besides, if you need a collection
based on primary key
On Fri, Apr 16, 2010 at 2:15 AM, Per Vognsen wrote:
> What may confuse is that map destructuring swaps the positions of keys
> and values as compared to map literals:
>
> user> (let [{x :body} {:body 42}]
> x)
> 42
>
> It does conform to the pattern that the bound variable precedes the
>
It doesn't seem confusing to me. You are taking complete control of
the set's local notion of ordering and equality. This is what I'd
expect.
Here's an example. First, a handy little function from Haskell:
(defn on [key f]
#(apply f (map key %&)))
Then:
user> (sorted-set-by (on :id compare)
Here's the source for sorted-set-by:
(defn sorted-set-by
"Returns a new sorted set with supplied keys, using the supplied
comparator."
([comparator & keys]
(clojure.lang.PersistentTreeSet/create comparator keys)))
This is because your comparator is saying that everything is equal.
Persiste
You will have to ask Rich. The two reasons I mentioned in my post were
my own guesses. I don't find either of them very persuasive myself. My
preference would be that patterns and literals should reflect each
other directly as much as possible. Features like :keys and :or have
no counterpart in the
Hi,
Is this the intended behavior?
(sorted-set-by (constantly 0) 1 2 3 4) returns #{1}.
I would expect the set to contain all the elements, and the comparator
to only affect sort order.
Razvan
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To pos
The problem is more that whole records for already existing keys
disappeared along the road.
Like if conj failed to do its job.
I would be surprised that a smaller subset recreates the problem.
I had other instances were the input data was small and the index was
correct, all keys and all the reco
Your explanations from different angles of the problem were really
helpful. I now have a much better picture of what is going on during
destruturing. Thank you very much!
Stefan
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, s
On Fri, Apr 16, 2010 at 12:41 PM, Aravindh Johendran
wrote:
> Sorry, I shoulda been clearer. By similar functionality, i meant a 20-
> q game with
> 1) the network implemented as closures and
There are various ways you can do this while separating concerns. If
you don't mind specifying the quest
This is actually a fairly good bug report, I think.
If you look in clojure.main, the "eval-opt" fuction uses
"with-in-str", which unnecessarily interferes with using *in* within
the expression you are trying to evaluate. I was actually running into
this while trying to make a "lein repl" in clojur
On 2010 Apr 15, at 11:53 PM, Derek wrote:
(defn foo [map1 map2] (map (fn [k v] (map2 k)) map1))
(foo {:a 1 :b 2} {:a 5 :b 6 :c 7})
When you turn a map into a sequence, you get a sequence of two-element
sequences(1),
so if you change your anonymous function to destructure that, it will
work
Sorry, I shoulda been clearer. By similar functionality, i meant a 20-
q game with
1) the network implemented as closures and
2) code that doesn't have to hold state in a global datastructure
The question wasn't about the easiest way to implement the game.
State is unavoidable in many circumstanc
I feel like I'm probably doing something dumb, but here's my problem.
Below is a function that could take two maps, and return a list of all
the values in the second map for each key of the first:
(defn foo [map1 map2] (map (fn [k v] (map2 k)) map1))
(foo {:a 1 :b 2} {:a 5 :b 6 :c 7})
I would exp
At Runa, we've (mostly Amit Rathore) developed a framework somewhat
along these lines that we are using called swarmiji. We've open
sourced it at http://github.com/amitrathore/swarmiji
To quote from the readme:
swarmiji is a framework that helps in writing distributed programs
using the clojure p
I've recently released Cascalog, a Clojure DSL for querying Hadoop, as
open-source.
Here's the canonical "word count" query in Cascalog:
(?<- (stdout) [?word ?count] (sentence ?s) (split ?s :> ?word) (c/
count ?count))
Introductory blog post: http://nathanmarz.com/blog/introducing-cascalog/
Proje
I've put up the code those guys eventually worked on (and then
abandoned) while at UCBerkley:
http://github.com/wlangstroth/capriccio
On Apr 15, 4:16 pm, TimDaly wrote:
> This might be interesting when the discussion of events vs threads
> comes
> up:http://www.usenix.org/events/hotos03/tech/fu
One final update: all six parts are now available, including the "mobile"
downloads for offline viewing. http://link.pluralsight.com/clojure
On Tue, Apr 13, 2010 at 9:40 AM, Craig Andera wrote:
> Glad you've enjoyed them!
>
> 2010/4/13 Pelayo Ramón
>
> I have seen the first 2, and as a clojure n
On Fri, Apr 16, 2010 at 2:29 PM, Bytesource wrote:
> Hi,
>
> I am currently reading "Programming Clojure" but got stuck at the
> destructuring done in the "head-overlaps-body?" function call that is
> part of the "snake" game:
>
> (defn head-overlaps-body? [{[head & body] :body}]
> (includes? bod
On Apr 16, 11:59 am, Bytesource wrote:
> Hi,
>
> I am currently reading "Programming Clojure" but got stuck at the
> destructuring done in the "head-overlaps-body?" function call that is
> part of the "snake" game:
>
> (defn head-overlaps-body? [{[head & body] :body}]
> (includes? body head))
Bytesource wrote:
I am currently reading "Programming Clojure" but got stuck at the
destructuring done in the "head-overlaps-body?" function call that is
part of the "snake" game:
(defn head-overlaps-body? [{[head & body] :body}]
(includes? body head))
;; page 200 of the pdf version
I can no
What may confuse is that map destructuring swaps the positions of keys
and values as compared to map literals:
user> (let [{x :body} {:body 42}]
x)
42
It does conform to the pattern that the bound variable precedes the
value to bind in forms like let. A benefit of this ordering is that
Hi,
I am currently reading "Programming Clojure" but got stuck at the
destructuring done in the "head-overlaps-body?" function call that is
part of the "snake" game:
(defn head-overlaps-body? [{[head & body] :body}]
(includes? body head))
;; page 200 of the pdf version
I can not figure out wh
41 matches
Mail list logo