Thanks for the explanation Christophe.
I really need to try use (for) more often. I seem to forget about it
all the time.
On Dec 27, 10:42 pm, Christophe Grand wrote:
> tristan a écrit :
>
> > Hi All,
>
> > I've been trying to learn clojure lately by solving the project euler
> > problems with i
> ... in any case
> explicitly setting *ns* works, and really who uses eval/load-file like
> this??
Agreed.
Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to
Just a simpler example to demonstrate that new threads have *ns* set
to clojure.core:
(def *value* 'ok)
(def *a* (agent nil))
(send *a* (fn f [x] (println "AGENT:" *ns*)))
(send *a* (fn f [x] (eval '(println "AGENT:" *value*
(try (await *a*) (catch Exception e (println e) (println (agent-erro
Meikel's example works fine for strings:
user=> (doseq [s ["hi" "mum" "love u"]] (println s))
hi
mum
love u
nil
As does your map:
user=> (dorun (map println ["hi" "mum" "love u"]))
hi
mum
love u
nil
--~--~-~--~~~---~--~~
You received this message because yo
I believe the first parameter must be "this", only in the case of
methods .
The init function doesn't take a "this" parameter.
Here's an example of my problem, MyDerivedClass is a subclass of
Thread.
This doesn't work, because "this" actually refers to the first
argument passed to the constructo
Here's a related problem. I have a sequence of strings and I'd like to
print each on a separate line. I know that this isn't the answer:
(force (map println results))
I'm not sure what else to try.
On Sat, Dec 27, 2008 at 10:12 AM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 26.12.2008 um 21:43 schrie
Ah thanks Bill well that would explain it!
I added (println "DYN:" *ns*) to dyn.clj and (println "DEF:" *ns*) to
def.clj
and this is what I get:
>From the command line:
C:\java>clj def.clj
DEF: #
DYN: #
ok
>> both are in the same namespace
>From the REPL:
C:\java>clj
Clojure
user=> (load-file "d
> What's happening in the ActionListener code?
Actually this is more a question of how does load-file work I believe.
If I run your example with (read) added to the end to prevent the main
thread ending from the command line:
clj test.clj
it works as expected... ie: ok gets printed when clicking
I suggest you start by comparing the current namespace in your
actionPerformed method with that of *value*. Perhaps they are
different.
Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post t
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
The first parameter to these functions should be the reference the object.
so try:
(defn -init [this]
(.setDescription this "this is a derived class")
On 12/27/2008 08:05 PM, CuppoJava wrote:
> Here's my stab at it.
> I'm having problems with t
Here's my stab at it.
I'm having problems with the setDescription() line.
Thanks for your help
-Patrick
(ns test)
(gen-class
:name test.MyDerivedClass
:extends [SuperClass]
:init init
:constructors {[] [String]})
(defn -init []
;The following line doesn't work.
;I need to call setDescr
Thanks!
On Sat, Dec 27, 2008 at 2:01 PM, Kevin O'Neill wrote:
> Hi all,
> I've updated the github svn clones to pull from google code. I've also
> pushed the 20081217 branch so it's now accessible from git.
>
> Any problems please let me know.
>
> -k.
>
> >
>
--~--~-~--~~---
Here's some code that works as I expected:
dyn.clj
(println *value*)
test.clj
(def *value* 'ok)
(defn test-eval []
(load-file "dyn.clj"))
(test-eval)
=> 'ok
But when run in an event handler it fails:
test.clj
(import '(javax.swing JButton JFrame)
'(java.aw
On Sat, Dec 27, 2008 at 2:18 PM, bOR_ wrote:
> but
> didn't see an obvious/elegant way to do it in there, and the only way
> I'd write it now in clojure is going to be ugly.
>
> Anyone has a suggestion?
This kind of problem is straightforward if you understand recursion,
and the Clojure code is
Hi all,
Next problem. If I've a collection of sets of letters, and I want all
possible words you can make with this collection if you keep the order
of the sets intact, I would use 'for'. However, for wants me to know
beforehand how many sets there are in my collection. Is there a more
flexible w
Am 27.12.2008 um 22:40 schrieb wubbie:
I didn't get the syntax error at all:
The first yields: ([0 0] [0 1] ... [0 99])
The second y ields ([0 1] [0 2] .. [0 100])
I don't know why.
Just as Michael said: in the first the (< x y)
is ignored. You can see it in the first item:
[0 0]. This is h
I didn't get the syntax error at all:
The first yields: ([0 0] [0 1] ... [0 99])
The second y ields ([0 1] [0 2] .. [0 100])
I don't know why.
On Dec 27, 4:29 pm, "Michael Wood" wrote:
> On Sat, Dec 27, 2008 at 11:01 PM, wubbie wrote:
>
> > Hi,
> > Why are they different?
>
> > (take 100 (
On Sat, Dec 27, 2008 at 11:01 PM, wubbie wrote:
>
> Hi,
> Why are they different?
>
> (take 100 (for [x (range 1000) y (range 1000) (< x y)][x y]))
> (take 100 (for [x (range 1000) y (range 1000) :when (< x y)][x y]))
Based on the doc string I think the first one should be a syntax
error. Th
Hi,
Why are they different?
(take 100 (for [x (range 1000) y (range 1000) (< x y)][x y]))
(take 100 (for [x (range 1000) y (range 1000) :when (< x y)][x y]))
Thanks,
Sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google G
Hi all,
As a learning exercise, I've started working on a sort of clojure
clone of ActiveRecord (from Rails). You can see it here:
http://github.com/duelinmarkers/clj-record/tree/master
The model used in the tests is defined in files here:
http://github.com/duelinmarkers/clj-record/tree/master/cl
On Saturday 27 December 2008 12:32, wubbie wrote:
> Hi,
>
> I'm trying union/intersection/difference operations, but
> got undefined symbols error:
> java.lang.Exception: Unable to resolve symbol: intersection in this
> context (NO_SOURCE_FILE:22)
user=> (use 'clojure.set)
nil
user=> (doc inters
Hi,
I'm trying union/intersection/difference operations, but
got undefined symbols error:
java.lang.Exception: Unable to resolve symbol: intersection in this
context (NO_SOURCE_FILE:22)
Thanks
Sun
--~--~-~--~~~---~--~~
You received this message because you are su
Hi all,
I've updated the github svn clones to pull from google code. I've also
pushed the 20081217 branch so it's now accessible from git.
Any problems please let me know.
-k.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
So one thing I don't get is why would tristan's pow code sometimes
generate a BigInteger, and sometimes a Long for the same resulting
number?
But if this is really the problem, it seems like before hashing a
number, Clojure should apply some sort of consistent type conversion
rule to make sure th
I am done with first, rest, ffirst, frest, rfirst, rrest, second. They
are ready for check-in as sequences:
http://intricatevisions.com/source/clojure/sequences.clj
[I don't have rights for clojure-contrib and if somebody is willing to
check it in, please do :-) Please, also adjust test_clojure.cl
Oh, nevermind. I hadn't switched my svn over to the Google Code
repository, so I was on 1162... up to 1185 and we're ok.
So yeah.
user=> (sort-by frest {:a 2 :b 3 :c 1})
([:c 1] [:a 2] [:b 3])
On Dec 27, 12:50 pm, kwatford wrote:
> Sorted maps sort only on keys, sorry. I was going to suggest u
Sorted maps sort only on keys, sorry. I was going to suggest using
(sort-by frest foo) to at least get a sequence in the right order, but
it seems like sorting might be broken at the moment? Looks like this
response has turned into a bug report...
user=> (sort [3 1 2])
java.lang.ClassCastExceptio
Hi,
Am 26.12.2008 um 21:43 schrieb Mark Volkmann:
(for [x (range 3)] (println x))
for is not a looping construct. for is a list comprehension.
For side effects as above use doseq.
(doseq [x (range 3)] (println x))
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
>(defn sum-up-to [n]
>"returns the sum of the positive integers from 1 to n"
>(apply + 0
> (map #(+ 1 %) (range n
Is there any reason for that zero ('0')? I guess your function could work
with it.
Emeka
--~--~-~--~~~---~--~~
You received this message
Hi Justin,
This is the right place. Thanks for trying the plugin.
It would absolutely be helpful to document use of the plugin. However, I am
sure you can tell that it is nowhere near ready.
I would like to get a basic set of features going and then recruit you and
Randall to test and document
Merci!
Janus
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegro
janus a écrit :
> (take 100 (for [x (range 1000) y (range 1000) (< x y)][x y]))
>
> The above works, but when I changed [ x y] to (x y) it fails. Could
> anyone come to my help.
>
(take 100 (for [x (range 1000) y (range 1000) (< x y)] (list x y)))
(x y) means "call the function x passing y a
(take 100 (for [x (range 1000) y (range 1000) (< x y)][x y]))
The above works, but when I changed [ x y] to (x y) it fails. Could
anyone come to my help.
Emeka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clo
> Some robustness notes:
>
> On 5.2MB file, it takes 9s compared to 7s of improved Mibu version, or
> 7s of mine initial one.
>
> On 38MB file, it takes 53s and about 270MB of memory. Similarly, the
> initial one and the mibu versions take 39s and also about 270MB of
> memory. I also like Ipetit c
tristan a écrit :
> Hi All,
>
> I've been trying to learn clojure lately by solving the project euler
> problems with it, and I think the distinct function is broken (or it
> doesn't quite work as I assume it would).
>
> here is the code i'm running
>
>
> (defn pow [nbr pwr]
> (if (< pwr 2)
>
And the nice pastie version: http://pastie.org/347369
regards,
Piotrek
--~--~-~--~~~---~--~~
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
To unsubscribe fr
Thank you for all improvements and suggestions. Based on your
feedback, here is my final version:
(defn read-words
"Given a file, return a seq of every word in the file, normalizing
words by
coverting them to lower case and splitting on whitespace"
[in-filepath]
(re-seq #"\w+"
what-a-guy a écrit :
> (defmacro dlg [dlgid# & fields#]
> `(fn [parent# layout#]
> ~@(map
> (fn [[f# id# text# type#]]
> `(fld parent# layout# '~id# ~text# ~type#))
> fields#)))
>
> (def inp '(dlg "test"
> (field fld-1 "Field number one" (JTextField.))
>
Can I see you code?
Emeka
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to
clojure+unsubscr
I attached the source code since indentation disappear when I paste code
in mails.
Christophe Grand a écrit :
> aria42 a écrit :
>
>> I decided to code Tarjan's Algorithm for finding all the
>> strongly connected components of a graph (http://en.wikipedia.org/wiki/
>> Tarjan's_strongly_connect
aria42 a écrit :
> I decided to code Tarjan's Algorithm for finding all the
> strongly connected components of a graph (http://en.wikipedia.org/wiki/
> Tarjan's_strongly_connected_components_algorithm). I've written this
> code in Java and it's about a 100 lines. Sadly, my clojure version is
> abo
41 matches
Mail list logo