Hi,
On 30 Apr., 08:16, Gregg Williams wrote:
> And what's with the slashes in "[java/lang/Object]"--I've never seen
> that before.
Alex wrote you before: :extends does not take a vector.
Ad your constructor question: see :post-init.
Sincerely
Meikel
--
You received this message because you
Hello Armando, did you try the second half of you experiment in a
clean REPL?
As you describe it, the first evaluation may have created the var.
Regards, alux
On 29 Apr., 21:32, Armando Blancas wrote:
> > The REPL switches to the namespace ns-1 and the var my-namespace is in
> > user !
>
>
> I
On Apr 30, 2010, at 9:15 , ataggart wrote:
>
>
> On Apr 29, 10:43 pm, David Nolen wrote:
>> My rule of thumb is:
>>
>> use + :only
>> require + :as
>
>
> (inc *1)
(inc *1)
(conj *2 "
Also use is handy for your own nameslaces, if you've a project that consists
out of more then one to help y
klang writes:
> laprepl starts up with the following error and localhost:8080 does not
> respond
>
> kl...@feersum:~/projects/labrepl$ script/repl
> Clojure 1.2.0-master-SNAPSHOT
> java.lang.ExceptionInInitializerError (control.clj:9)
Looks like labrepl is not locked to a particular version of Cl
Ok great, thanks guys. Exactly what I needed.
On Apr 30, 12:12 am, Alex Osborne wrote:
> Hi Matt,
>
> Matt Culbreth writes:
> > I'm using slurp to read data from a file and send it to a stream, but
> > sometimes that's failing. I've got a theory that it has to do with
> > slurp not reading bin
On Apr 29, 2010, at 4:21 AM, ataggart wrote:
I know it won't matter, but for posterity if nothing else...
Functions named contains-key? and contains-val? would make a lot more
sense to me than the current contains? and new seq-contains?. Anyone
looking at contains-val? should expect it to be
> simple, you'd be embarrassed to admit that you didn't see WHAT WAS
> STARING YOU IN THE FACE all along?
Don't be too hard on yourself - it takes a while for the clojure
patterns to sink in so you easily spot the simple errors. Best to
throw it out there so someone else can help.
Gen-class is a
2010/4/30 Rich Hickey :
>
> On Apr 29, 2010, at 4:21 AM, ataggart wrote:
>
>> I know it won't matter, but for posterity if nothing else...
>>
>> Functions named contains-key? and contains-val? would make a lot more
>> sense to me than the current contains? and new seq-contains?. Anyone
>> looking
I will check in a fix later this morning.
Stu
klang writes:
laprepl starts up with the following error and localhost:8080 does
not
respond
kl...@feersum:~/projects/labrepl$ script/repl
Clojure 1.2.0-master-SNAPSHOT
java.lang.ExceptionInInitializerError (control.clj:9)
Looks like labrepl
On Apr 29, 2010, at 2:19 PM, MarkSwanson wrote:
> On Apr 29, 4:21 am, ataggart wrote:
>> I know it won't matter, but for posterity if nothing else...
>>
>> Functions named contains-key? and contains-val? would make a lot more
>> sense to me than the current contains? and new seq-contains?. Any
Hi,
On Thu, Apr 29, 2010 at 7:48 AM, Meikel Brandmeyer wrote:
>
> On 29 Apr., 01:38, Mark Engelberg wrote:
>
> > 1. Don't include seq-contains? The behavior you want can usually be
> > achieved by using (some #{item} coll). Disadvantage - if you're
> > testing to see if the collection contains
In a clean repl:
C:\>repl
Clojure 1.2.0-master-SNAPSHOT
user=> (println (do (ns ns-1) (def my-namespace *ns*) my-namespace))
#
nil
ns-1=>
On Apr 30, 1:17 am, alux wrote:
> Hello Armando, did you try the second half of you experiment in a
> clean REPL?
>
> As you describe it, the first evaluation
I'm pounding my head against the wall trying to understand how to do a
simple task. What I want to do is write a function that will take a
even-numbered set of numbers and split them into pairs.
What I have right now is the following
user> (defn pairup ([a b] [a b])([a b & rest] (cons (pairup
Hello,
I'm stuck with "Programming Clojure" on page 37 on a Windows 7
machine. After downloading the "examples" dir into "C:/clojure", I
typed:
user> (require 'examples.introduction)
and I got
; Evaluation aborted.
java.io.FileNotFoundException: Could not locate examples/
introduction__init.cl
Hi everyone,
Reading the documentation I found that except for the docstring there
is no way to tell that InternalReduce is a protocol, it's tagged
simply as a var.
Why don't add a :protocol true to the metadata for protocols
like :macro true for macros?
Andrea.
--
You received this message bec
I fixed my bottleneck-finding problem by applying the right jvisualvm
parameters.
You say:
>It's discouraged to use the mutable reference types in a fine-grained way
>like this. I would recommend changing your code to just be a vector of
>Clojure PersistentMaps that you map over.
What do you mea
Hello,
yesterday, I sent my noob question about the classpath to the group. So far,
my message has not shown up yet. Could you please post my message to the
Clojure group? Thank you in advance.
Kind regards,
Rainer Wolf
-- Forwarded message --
From: Rainer
Date: Fri, Apr 30, 20
Okay, found a fix do my own bug. You can use the with-ns namespace to
solve this issue. I changed the form to be like this:
(send test-result
(fn [& args] (with-ns 'my-ns (eval `(->> ~@(deref test-query))
FYI
On Apr 29, 5:09 pm, Sean Devlin wrote:
> Right...
> Is there a way to force an
I think you want this:
(defn pairup [a b & rest] (cons [a b] (if rest (apply pairup rest) [])))
On Thu, Apr 29, 2010 at 3:32 PM, john.holland wrote:
> I'm pounding my head against the wall trying to understand how to do a
> simple task. What I want to do is write a function that will take a
>
On Apr 30, 1:43 am, David Nolen wrote:
> My rule of thumb is:
>
> use + :only
> require + :as
Yes. clojure.contrib.string deliberately has short function names,
which means there is some overlap with clojure.core.
Note: (use '[clojure.contrib.string :as st :only ()]) also works.
-SS
--
You r
"ns" and "in-ns" have special evaluation rules. In general, they
don't work as you'd expect in block expressions such as "do" or "let".
If you want to create namespaces programatically, use "create-ns" and
"intern".
-SS
On Apr 26, 6:25 pm, David McNeil wrote:
> I am experimenting with clojure
On Fri, Apr 30, 2010 at 4:33 AM, Rich Hickey wrote:
> On Apr 29, 2010, at 4:21 AM, ataggart wrote:
>> Functions named contains-key? and contains-val? would make a lot more
>> sense to me than the current contains? and new seq-contains?. Anyone
>> looking at contains-val? should expect it to be O(
I'd use the built-in, partition
user=> (partition 2 (range 1 9))
((1 2) (3 4) (5 6) (7 8))
And add a mapping operation
user=> (map vec (partition 2 (range 1 9)))
([1 2] [3 4] [5 6] [7 8])
Am I missing a requirement?
On Apr 30, 11:55 am, "Mark J. Reed" wrote:
> I think you want this:
>
>
On Thu, Apr 29, 2010 at 10:43 PM, David Nolen wrote:
> My rule of thumb is:
>
> use + :only
> require + :as
>
> I believe this should be documented as the 'suggested usage'. As contrary
to Python where 'from module import *'(which is 'use' in clojure) is right
in there saying 'you know what you ar
Sorry, let me try answering your questions instead of just proposing an
alternative. :)
As written, your base case and your recursive call are inconsistent. If you
want (pairup 1 2 3 4) to return ([1 2] [3 4]), then you need to wind up
calling (cons [1 2] [[3 4]]). What you're calling instead is
On Fri, Apr 30, 2010 at 12:25 PM, Mark J. Reed wrote:
> I got an error when I tried ([a b]) instead of (list [a b]), by the way:
>
> Clojure 1.1.0
> user=> (cons [1 2] ([3 4]))
> java.lang.IllegalArgumentException: Wrong number of args passed to:
> PersistentVector (NO_SOURCE_FILE:0)
>
To be cle
On Fri, Apr 30, 2010 at 5:18 AM, Laurent PETIT wrote:
> While it sounds soo evident now that you say that explicitly ( the
> contains? / get pair ), it may be good to reflect that in the docs of
> the functions rather than just keep this knowledge here ?
Agreed. This explanation of the relations
On Thu, Apr 29, 2010 at 6:58 PM, Rainer wrote:
> Hello,
>
> I'm stuck with "Programming Clojure" on page 37 on a Windows 7
> machine. After downloading the "examples" dir into "C:/clojure", I
> typed:
>
> user> (require 'examples.introduction)
>
> and I got
>
> ; Evaluation aborted.
>
> java.io.F
On Apr 30, 4:33 am, Rich Hickey wrote:
> People don't consider sets, vectors, arrays or strings to have 'keys'.
> But, like maps, they all support fast lookup of some sort.
But of course we do. I point to the doc for contains? and get:
Usage: (contains? coll key)
Returns true if key is prese
On 2010 Apr 30, at 7:33 AM, Rich Hickey wrote:
> People don't consider sets, vectors, arrays or strings to have
'keys'.
That is not consistent with the documentation:
Sets: http://clojure.org/data_structures:
Sets support 'removal' with disj, as well as contains? and get, the
latter returni
Should this compile?
(defprotocol P (p [this]))
(defrecord R [k] P (p [{:keys [k]}] k))
java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
be cast to clojure.lang.Symbol
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to th
I think you have your destructuring backwards.
You fn should probably be (fn [{k :keys}] k)
For example,
user=> ((fn [{k :keys}] k) {:keys "Awesome"})
"Awesome"
On Apr 30, 2:46 pm, russellc wrote:
> Should this compile?
>
> (defprotocol P (p [this]))
> (defrecord R [k] P (p [{:keys [k]}] k))
Why does this work?
(defrecord R [k])
(extend-protocol P R (p [{:keys [k]}] k))
On Fri, Apr 30, 2010 at 2:52 PM, Sean Devlin wrote:
> I think you have your destructuring backwards.
>
> You fn should probably be (fn [{k :keys}] k)
>
> For example,
>
> user=> ((fn [{k :keys}] k) {:keys "Awesome"})
Oh, wait, my bad... you're getting the keyword args special
destructuring. i.e., you're telling Clojure to expect a map and store
the appropriate keys in the proper symbols
user=> ((fn [{:keys [k]}] (str k)) {:k "Awesome" :l "Beer"})
"Awesome"
user=> ((fn [{:keys [k l]}] (str k l)) {:k "Awesome"
On Apr 30, 2010, at 6:33 AM, Rich Hickey wrote:
> Would contains-val? be fast for sets? As a user of sets, I consider them
> collections of values, and I absolutely would reach for contains-val? in any
> library that had it, for use with sets. If so, and I used contains-val?, and
> I moved cod
I have updated the labrepl [1] to use the latest clojure 1.2 and
contrib 1.2 snapshots. Also, most of the dependencies are now frozen
to specific snapshot timestamps (the project.clj file may be of
interest to people living on the development edge).
After a "lein clean; lein deps" everythi
On Apr 30, 9:46 pm, russellc wrote:
> Should this compile?
>
> (defprotocol P (p [this]))
> (defrecord R [k] P (p [{:keys [k]}] k))
>
> java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
> be cast to clojure.lang.Symbol
defrecord doesn't yet support destructuring as far as I k
On Apr 29, 3:21 am, ataggart wrote:
> Functions named contains-key? and contains-val? would make a lot more
> sense to me than the current contains? and new seq-contains?.
Amen. Even independent of any performance expectations.
--
You received this message because you are subscribed to the Go
On 30 April 2010 18:25, Mark J. Reed wrote:
[...]
> (defn pairup
> ([a b] (list [a b]))
> ([a b & rest] (cons [a b] (apply pairup rest
> I got an error when I tried ([a b]) instead of (list [a b]), by the way:
> Clojure 1.1.0
> user=> (cons [1 2] ([3 4]))
> java.lang.IllegalArgumen
Of course. Which is what I would have done automatically with a
Lispier construct. Just still not used to seeing literal vectors as
functions. :)
On Friday, April 30, 2010, Michael Wood wrote:
> On 30 April 2010 18:25, Mark J. Reed wrote:
> [...]
>> (defn pairup
>> ([a b] (list [a b]))
>>
On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote:
Of course. Which is what I would have done automatically with a
Lispier construct. Just still not used to seeing literal vectors as
functions. :)
On Friday, April 30, 2010, Michael Wood wrote:
Well, you didn't *have* to call list. You could hav
Phil Hagelberg writes:
> Actually I do consider sets to have keys, since internally they are
> implemented using maps, so the exact same semantics apply for their
> lookup. They're just maps where the key and value are the same thing:
But that implementation is one of convenience, of possibly ad
On 30 April 2010 23:49, Douglas Philips wrote:
> On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote:
>>
>> Of course. Which is what I would have done automatically with a
>> Lispier construct. Just still not used to seeing literal vectors as
>> functions. :)
>>
>> On Friday, April 30, 2010, Michael
Clojure embraces this "laziness":
user=> (get #{:foo :bar} :foo)
:foo
'get uses a "key" to return a "value". A vector is not a map is not a
set, but all of them can have their values accessed in constant-time
using a "key".
On Apr 30, 3:14 pm, "Steven E. Harris" wrote:
> Phil Hagelberg write
Ok, so I was right the first time. It think it's past everyone's bedtime.
:)
On Fri, Apr 30, 2010 at 5:49 PM, Douglas Philips wrote:
> On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote:
>
>> Of course. Which is what I would have done automatically with a
>> Lispier construct. Just still not used
On 30 April 2010 18:25, Mark J. Reed wrote:
> (defn pairup
> ([a b] (list [a b]))
> ([a b & rest] (cons [a b] (apply pairup rest
That will overflow the stack when you do, say,
(last (apply pairup (range 2)))
That can be fixed by wrapping (cons ...) in lazy-seq.
Another versio
0On Fri, Apr 30, 2010 at 8:41 PM, Michał Marczyk
wrote:
> That will overflow the stack when you do, say,
>
> (last (apply pairup (range 2)))
>
> That can be fixed by wrapping (cons ...) in lazy-seq.
>
Sure. Laziness good.
Another version:
>
> (defn pairup [& args]
> (map vector args (re
In an earlier thread, in which I learned (from Timothy Pratley) that (. (new
java.util.Random) X) gives an error if X is a bignum, I said that at least
Clojure's rand-int "does the right thing."
Upon further investigation I see that this is only true in the sense that it
doesn't produce an err
I am unable to read-string record instances produced by pr-str.
user> (defrecord Z [x y])
user.Z
user> (read-string (pr-str (Z. 1 2)))
; Evaluation aborted.
The exception is:
java.lang.Exception: No dispatch macro for: :
[Thrown class java.lang.RuntimeException]
However, struct instances are
49 matches
Mail list logo