Hi,
I read a few messages on the new version.
Could someone summarize the changes and the motivation
behind?
Thanks,
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send
thanks!
sun
On Feb 14, 4:34 pm, Brian Doyle brianpdo...@gmail.com wrote:
On Sat, Feb 14, 2009 at 2:24 PM, wubbie sunj...@gmail.com wrote:
Hi,
a quick question:
user= (keys {:a 1 :b 2})
(:a :b)
But
user= (key {:a 1})
java.lang.ClassCastException
Hi,
Why vector is not a seq?
user= (seq? [1 2 3])
false
user= (seq? '(1 2 3))
true
thanks,
-sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
Hi, do we have labels equiv. in clojure?
The code below is from OnLisp. Trying to convert to clj file,
but have minor difficulties.
(defun count-instances (obj lsts)
(labels ((instances-in (lst)
(if (consp lst)
(+ (if (eq (car lst) obj) 1 0) (instances-in (cdr lst)))
0)))
Hello,
How can I do this? Do we have a function that checks if
it's a char or digit?
(digits a2c3)
- 23
Thanks,
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email
%
if you prefer a more haskellish form :-)
2009/2/12 wubbie sunj...@gmail.com
Hello,
How can I do this? Do we have a function that checks if
it's a char or digit?
(digits a2c3)
- 23
Thanks,
sun
--
Cordialement,
Laurent PETIT
for simplicity, first tried to create two dimentional array(vector) of
numbers.
On Feb 5, 1:58 am, Emeka emekami...@gmail.com wrote:
Where did 'ref' go in your own implementation?
Emeka
--~--~-~--~~~---~--~~
You received this message because you are subscribed
Hi,
Have some difficulties in reasoning about it.
From ants.clj,
(def board
(apply vector
(map (fn [_]
(apply vector
(map (fn [_] (ref (struct cell white)))
(range dim
(range dim
Is there any
, 12:19 am, wwmorgan wmorga...@gmail.com wrote:
Here's what I came up with: is it any clearer?
(def board
(vec (for [i (range dim)]
(vec (for [j (range dim)]
(ref (struct cell white)))
On Feb 4, 11:30 pm, wubbie sunj...@gmail.com wrote:
Hi,
Have
any concrete example?
thanks,
-sun
On Feb 2, 5:13 am, Christian Vest Hansen karmazi...@gmail.com wrote:
On Sun, Feb 1, 2009 at 9:35 PM, e evier...@gmail.com wrote:
This may be obvious to others, but what's the motivation behind it? Is it
that we are very concerned about combatting the
Hello,
I'd like to separate dosync and other funcs as follows.
Any comment? Essentially I want to allow more concurrency.
(if true
(do
(dosync (ref-set r1 1))
(non-ref setting fun))
(else-fun))
Instead of
(if true
(dosync
(ref-set r1 1)
(non-ref setting
Hi,
I saw in ants.clj a notation (-).
what is it?
For example,
(defn place [[x y]]
(- world (nth x) (nth y)))
thanks in advance.
-sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to
will be the value of *file* in both cases.
I assume that your CLASSPATH contains path to clojure.jar, otherwise
you will have to provide it:
java -cp /path/to/clojure.jar clojure.main test.clj
Cheers,
Telman
On Jan 29, 9:23 pm, wubbie sunj...@gmail.com wrote:
Hi Telman,
I know *file
])
(:use [clojure.contrib server-socket duck-streams]))
thanks,
sun
On Jan 28, 8:05 pm, wubbie sunj...@gmail.com wrote:
Hi,
I see
(add-classpath (str file:// (.getParent (java.io.File. *file*))
/))
in mire.clj.
What value of *file* is it? I failed to see *file* is assigned at all
The path of the file being evaluated, as a String.
Evaluates to nil when there is no file, eg. in the REPL.
On Jan 29, 7:03 am, wubbie sunj...@gmail.com wrote:
Hello,
As you see, java.io.File. construct takes path argument but it is the
first line of code and I don't know how *file
, wubbie sunj...@gmail.com wrote:
again I don't know how *file* gets current dir value. Maybe some
magic?
-sun
On Jan 29, 12:30 pm, Telman Yusupov use...@yusupov.com wrote:
I had the same question, that was answered by typing this into REPL:
user= (doc *file*)
Output
The notation mire.rooms/ is new, especially dod(.) and slash(/).
mire.rooms is rooms in ns mire, etc?
-sun
On Jan 28, 12:50 pm, Phil Hagelberg p...@hagelb.org wrote:
wubbie sunj...@gmail.com writes:
@mire.rooms/*rooms* is new to me.
could anybody explain to me?
Sure thing. *rooms
Oh,
I see (ns mire.rooms ... in rooms.clj
Also see (def *rooms* ...)
So we can refer in other name spaces
the vars and functions in this ns?
Like mire.rooms/*rooms*, mire.rooms/*items*,
mire.rooms/make-room etc?
Thanks
-sun
On Jan 28, 1:18 pm, wubbie sunj...@gmail.com wrote:
The notation
Hi,
I see
(add-classpath (str file:// (.getParent (java.io.File. *file*))
/))
in mire.clj.
What value of *file* is it? I failed to see *file* is assigned at all.
-thanks
sun
On Jan 27, 1:16 pm, Phil Hagelberg p...@hagelb.org wrote:
Keith Bennett keithrbenn...@gmail.com writes:
I'm trying
Hi,
I saw (.getParent (java.io.File. *file*)) is resolved to parent
directory of current running directory.
java.io.File. is a constructor that takes *file* as an argument, but
I don't see *file* is assgned any value at all.
Is it related to the starup script?
The start-up script has
Hi Phil,
Why defn ends with -(dash)?
(defn- mire-handle-client [in out]
On Jan 27, 1:16 pm, Phil Hagelberg p...@hagelb.org wrote:
Keith Bennett keithrbenn...@gmail.com writes:
I'm trying to wrap my head around Clojure's concurrency. I'm new to
Lisp-like languages, and the examples that
What's the typical usage of fn constantly ?
thanks
-sun
--~--~-~--~~~---~--~~
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,
Hi,
I saw dorun and doall in core.clj as follows:
That is, doall just calls dorun.
My question is, how come doall does force eval and dorun does not.
thanks in advance,
-sun
(defn dorun
([coll]
(when (and (seq coll) (or (first coll) true))
(recur (rest coll
([n coll]
(when
(and (seq coll) (or (first coll) true))
(recur (rest coll
On Jan 25, 6:21 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Jan 25, 2009, at 5:51 PM, wubbie wrote:
I saw dorun and doall in core.clj as follows:
That is, doall just calls dorun.
My question is, how come doall does
then, back to my original question.
They (dorun do all) differe ONLY in return value.
Then how come one forces eval and the other not?
-sun
On Jan 25, 7:18 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Jan 25, 2009, at 6:45 PM, Laurent PETIT wrote:
2009/1/26 Stephen C. Gilardi
the-value)' and get the
same result.
user= (= (#(identity ab)) ((constantly ab)))
true
Sorry if I beat this to death; some of it was for my own learning and
benefit.
On Jan 25, 2:08 pm, wubbie sunj...@gmail.com wrote:
thanks James,
I'll have a look.
-sun
On Jan 25, 2:00 pm, James Reeves
:35 PM, wubbie wrote:
then, back to my original question.
They (dorun do all) differe ONLY in return value.
Then how come one forces eval and the other not?
Both force evaluation. Is there something that makes you think
otherwise?
In the case of dorun, the members of the sequence
until now, when I see when, my eyes have glazed over. Thus the
only reason I need when is to read other people's code. Good question. Is
there a reason to have when?
On Sat, Jan 24, 2009 at 9:33 AM, wubbie sunj...@gmail.com wrote:
Here is code from core.clj.
The question is when to use
Hi,
I wonder why self-call(filter) is used in one place and
recur is used in the other.
(defn filter
Returns a lazy seq of the items in coll for which
(pred item) returns true. pred must be free of side-effects.
[pred coll]
(when (seq coll)
(if (pred (first coll))
In core.clj, merge is essentially defined using conj.
user= (merge '(1) 2)
(2 1)
user= (merge [1] 2)
[1 2]
user= (merge #{1} 2)
#{1 2}
user= (conj '(1) 2)
(2 1)
user= (conj [1] 2)
[1 2]
user= (conj #{1} 2)
#{1 2}
user= (conj {:name ryan} {:age 25})
{:age 25, :name ryan}
-sun
On Jan 24, 10:51
I understand vaguely.
My understanding is that recur is related to tail-call-optimization.
Where can I get more detailed info on recur?
thanks
-sun
On Jan 24, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 24.01.2009 um 16:50 schrieb wubbie:
I wonder why self-call(filter
How do you define side-effects?
-sun
On Jan 24, 5:26 am, Christophe Grand christo...@cgrand.net wrote:
Tzach a écrit :
The text on the panel do update.
When I try to do the same for all the elements:
(for [t (components r)]
(.setText t (str 6)))
Nothing happened.
What am I
Hi,
I got the following and don't know what's wrong with it.
thanks in advance.
user= (defn sum [ more ]
((fn [total other]
(if other
(recur (+ total (first other)) (rest(other)))
total))
0 more))
#'user/sum
user= (sum [1 2 3 4])
java.lang.ClassCastException:
Thanks Jason.
Anyway I'd like to have (sum) returns 0 so I used [ more].
Is there any way to specify 0 or more args?
-sun
On Jan 23, 12:49 pm, Jason Wolfe jawo...@berkeley.edu wrote:
Two mistakes:
First, if you want sum to take a vector, you should remove the from
the arglist.
Second,
Is every function supposed to return something?
Of course, except for pure side-effects.
-sun
On Jan 23, 3:02 pm, Vincent Foley vfo...@gmail.com wrote:
The only two false values in Clojure are false and nil. Everything
else is logically true. If your function returns nil/false or a
(some (set aeiou) e)
is equiv to
(some #{\a \e \i \o \u} e)
- \e
Finally, I can answer, instead of keep asking...
-sun
On Jan 23, 4:04 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote:
On Fri, Jan 23, 2009 at 2:51 PM, Chouser chou...@gmail.com wrote:
On Fri, Jan 23, 2009 at 3:47 PM,
Hi,
Here is def of merge:
(defn merge
[ maps]
(when (some identity maps)
(reduce #(conj (or %1 {}) %2) maps)))
How can I interpret when (some identity maps)?
Thanks
-sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
Hi
I would just print the files, excluding #File and .
what's the best way?
user= (filter recently-modified? (file-seq (File. .)))
(#File . #File ./.my-hints.clj.swn #File ./my-hints.clj)
Thanks
-Sun
--~--~-~--~~~---~--~~
You received this message because you
Hi,
Just tried a piece of code from here...
(defn my-deref [x]
(if (or (isa? clojure.lang.Ref (class x))
(isa? clojure.lang.Agent (class x))
(isa? clojure.lang.Atom (class x)))
@x
x))
java.lang.ClassNotFoundException: clojure.lang.Atom (NO_SOURCE_FILE:
22)
But I
Hi,
Why into does not work for second argument of list?
user= (into [] (1 2 3))
java.lang.ClassCastException: java.lang.Integer cannot be cast to
clojure.lang.IFn (NO_SOURCE_FILE:0)
user= (into [] [1 2 3])
[1 2 3]
thanks
-Sun
--~--~-~--~~~---~--~~
You received
thanks, I forgot about that.
sun
On Jan 18, 4:00 pm, Nick Vogel voge...@gmail.com wrote:
You need to do (into [] '(1 2 3)) otherwise it will be read as calling the
function 1 with arguments 2 and 3.
On Sun, Jan 18, 2009 at 3:56 PM, wubbie sunj...@gmail.com wrote:
Hi,
Why into does
Hi,
is #^ type hint below? I don't see any type at all.
It's from clojure core.
(def
#^{:arglists '([ items])
:doc Creates a new list containing the items.}
list (. clojure.lang.PersistentList creator))
--~--~-~--~~~---~--~~
You received this message
came across over the net the following examples.
I can understand full destructuring because [ and ]
mirrors the structure of tree.
But in partial desctructuring, [[a [b]] has extra pair of outer-most
[] which leads to confusion. Any explanation on that?
Also not sure about the last (on strings).
Extra pair of []? What do you mean?
Sorry, my bad.
-sun
On Jan 15, 1:25 pm, James Reeves weavejes...@googlemail.com wrote:
On Jan 15, 2:54 pm, wubbie sunj...@gmail.com wrote:
But in partial desctructuring, [[a [b]] has extra pair of outer-most
[] which leads to confusion. Any
Hi
Came across Chouser's posting below:
I know *agent* is for global designation.
My question is how the first agent (agent nil) and *agent* used
later in another nested send-off related?
Also m after (fn is a function name so that it can be referred to
later inside the same function?
Thanks
Hi,
Earlier Stuart Sierra replied as follows:
Hi Patrick,
Here's one way to do it:
(defn new-person [name]
(ref {:name name, :friends #{}}))
(defn are-friends [a b]
(dosync
(commute a assoc :friends (conj (:friends @a) b))
(commute b assoc :friends (conj (:friends @b) a
(def
Thanks David.
-sun
On Jan 14, 11:55 am, David Nolen dnolen.li...@gmail.com wrote:
(:name @(first (:friends @bill)))
You need to dereference before trying to access name.
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
(map #(println %) [1 2 3 4]) prints 1 2 3 and 4
But what if the vector element is a hash with
[ {:a 1 :b 11} {:a 2 :b 22} {:a 3 :b 33}]?
can we dereference :a using %1, like (:a %1)?
If not, any alternative? maybe destructuring or something?
thanks
-sun
Hi,
After (are-friends bill bob) they should be friends,
so I tried @bob
and don't see bill as a friend. why?
@bob
{:friends #{#Ref clojure.lang@165ab39}, :name Bob}
-sun
On Jan 10, 9:44 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote:
Hi Patrick,
Here's one way to do it:
Hi,
How can you add line numbers for each line printed from the file.
Without line number, I have this:
(with-open [rdr (reader executors.clj)]
(filter #(println %) (line-seq rdr)))
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are
Hi all,
I can use file-seq
(file-seq (File. .))
But how can I filter out all files ending with .clj?
Do we use re-find, re-seq etc?
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post
I tried
(filter #(re-find #\.clj$ %) (seq (file-seq(java.io.File. .
- java.lang.ClassCastException: java.io.File cannot be cast to
java.lang.CharSequence (NO_SOURCE_FILE:0)
On Jan 8, 9:06 pm, Achim Passen achim.pas...@gmail.com wrote:
On 9 Jan., 03:03, Achim Passen achim.pas...@gmail.com
thank, it was str as usual.
On Jan 8, 9:22 pm, Brian Doyle brianpdo...@gmail.com wrote:
This works:
(filter #(re-find #\.clj$ (str %)) (file-seq(java.io.File. .)))
On Thu, Jan 8, 2009 at 7:16 PM, wubbie sunj...@gmail.com wrote:
I tried
(filter #(re-find #\.clj$ %) (seq (file-seq
Hi all,
I'm attempting to provide 2 type hints here and not working...
(defn my-fn [#^String s #^Integer i] (println format(%s %d s i)))
(my-fn hello (new Integer 123))
Thanks
Sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
typo...
and looks working...
should be (println (format %s %d s i)))
On Jan 7, 10:44 am, wubbie sunj...@gmail.com wrote:
Hi all,
I'm attempting to provide 2 type hints here and not working...
(defn my-fn [#^String s #^Integer i] (println format(%s %d s i)))
(my-fn hello (new Integer 123
So nested transactions only keep track of nesting level similar to
that in Sybase?
Sun
On Jan 7, 12:18 pm, Rich Hickey richhic...@gmail.com wrote:
On Jan 7, 12:07 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote:
Are there any particular issues with using nested transactions ...
dosync
Hi,
I tried your example and some weird sequence generates
java.util.concurrent.RejectedExecutionException (NO_SOURCE_FILE:0)
Here is the scenario:
Clojure
user= (def counter (agent 0))
#'user/counter
user= (send counter inc)
#Agent clojure.lang.ag...@9e4585
user= @counter
1
user= (def
:
On Tue, Jan 6, 2009 at 10:00 AM, wubbie sunj...@gmail.com wrote:
user= (shutdown-agents)
nil
[snip]
user= (send-off my-agent sleep-and-multiply 7 1500)
java.util.concurrent.RejectedExecutionException (NO_SOURCE_FILE:0)
I don't know why you're getting that error.
The error is because
Hi,
Here is the question on differences between with-meta and #^
Specifically 1) and 2) are different in that 1) has meta info carried
over
to jumping-wubbie, while 2) has not.
What's the rationale behind this?
user= (def wubbie {:name Wubbie :email wub...@gmail.com})
#'user/wubbie
user
Hi,
This example is from clojure site.
My question is on line 5 and line 6:
The confusion is str is a function and here looks like used as a
regular variable.
Thanks in advance.
Sun
(defn loves [x y]
(str x loves y))
(defn test-rebind []
(println (loves ricky lucy))
(let [str-orig str]
Hi,
Why are there multiple Logging str output.
Also in (apply str-orig args), I don't see any args passed at all!
Thanks
sun
On Jan 5, 2:14 pm, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 05.01.2009 um 18:35 schrieb wubbie:
This example is from clojure site.
My question is on line
Hi,
I got core dump while running
It's on linux(ubuntu):
user= (if true (str true!) (str false!)
)
true!
user= (if false (str true!) (str false!))
false!
user= #
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x064f7e68, pid=6500, tid=2893822864
#
Ok, I'll do it.
Thanks
Sun
On Jan 5, 6:36 pm, Randall R Schulz rsch...@sonic.net wrote:
On Monday 05 January 2009 15:30, wubbie wrote:
Hi,
I got core dump while running
...
user= #
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc
Hi,
What's the correct syntax for this code -- from clojure manual.
(import '(java.util.concurrent Executors))
(defn test‐stm [nitems nthreads niters]
(let [refs (map ref (replicate nitems 0))
pool (. Executors (newFixedThreadPool nthreads))
tasks (map (fn [t]
(fn []
(dotimes n niters
(dosync
Hi all,
Here is the code from Stu's CL translation.
(defmacro check [ forms]
`(do
~@(map (fn [f] `(report-result ~f '~f)) forms)))
And report-result is:
(defn report-result [result form]
(println (format %s: %s (if result pass FAIL) (pr-str form
An example run is:
(check (=
Thanks Chouser,
Happy new year!
sun
On Jan 1, 12:37 am, Chouser chou...@gmail.com wrote:
On Wed, Dec 31, 2008 at 11:41 PM, wubbie sunj...@gmail.com wrote:
Hi all,
what's the new syntax for this?
It is part of the code below which was translation by Stu.
That's a nifty little
Hi all,
what's the new syntax for this?
It is part of the code below which was translation by Stu.
; using dotimes instead of repeat from cl
(defn plot [f min max step]
(doseq i (range min max step)
(dotimes _ (apply f [i]) (print *))
(println)))
Thanks,
Sun
Hi,
Why do we need to specify the second argument(#'func) is a function,
not a variable?
the syntax of send-off required a function as the second arg?
thanks,
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Hi all,
Looking into ants.clj, I came across
(defn place [[x y]]
(- world (nth x) (nth y)))
What - mean here?
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group,
, etc.
nil
On Dec 29, 8:27 pm, wubbie sunj...@gmail.com wrote:
Hi all,
Looking into ants.clj, I came across
(defn place [[x y]]
(- world (nth x) (nth y)))
What - mean here?
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you
Hi all,
I've been using command line Repl for a while and want to move to
slime/emacs
so I followed instructions in wiki
and got errors in emacs:
I was able to load ants.clj in upper panel.
On the bottom panel, alt -x slime give me the following errors:
(require 'swank.swank)
in Slime
(interactive)
(slime 'clojure))
;; To use other Lisps...
;; Incidentally, you can then choose different Lisps with
;; M-- M-x slime tab
;; (add-to-list 'slime-lisp-implementations
;; '(sbcl (/path/to/bin/sbcl)))
On Dec 28, 7:03 pm, wubbie sunj...@gmail.com wrote:
Hi all
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
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
Hi,
I ran it with the changes and got the message:
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Symbol (NO_SOURCE_FILE:22)
What can be the problem?
thanks
sun
On Dec 23, 6:08 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Dec 23, 2008, at 5:19 PM, MattyDub
still have error:
s...@wubbie:~/clj-ex$ java -cp clojure.jar clojure.lang.Repl snake.clj
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Symbol (snake.clj:26)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
at clojure.lang.Compiler.analyze
, wubbie wrote:
Hello,
My question is that conj takes two argument and how conj finds
the first argument? Is it somehow provided by commute?
Consider the documentation for (commute ...) (at
http://clojure.org/api):
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
commute ref
Hello,
doall and dorun returns different results from seond run on...
e.g.
user= (def x (for [i (range 1 3)] (do (println i) i)))
#'user/x
user= (doall x)
1
2
(1 2)
user= (doall x)
(1 2)
user= (doall x)
(1 2)
user=
user= (def x (for [i (range 1 3)] (do (println i) i)))
#'user/x
user= (dorun x)
Hello,
While reading the book, I came across the phrase
true? tests whether a value is actually true, not
whether the value evaluates to true in a boolean context. The only
thing
that is true? is true:
(true? true)
- true
(true? foo)
- false
Be careful with predicates ...
My question is what's
Hi,
The same hello world did not work for me.
The error msgs are:
(defn hello-world []
(qt4
(let [app (QCoreApplication/instance)
button (new QPushButton Go Clojure Go)]
(.. button clicked (connect app quit()))
(doto button
(resize 250 100)
(setFont (new
80 matches
Mail list logo