what is the new version of clj about?

2009-02-17 Thread wubbie
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

Re: count-leaves from onLisp question

2009-02-15 Thread wubbie
So destructuring is essentially doing (first coll) for each parameter and the rest is assigned (rest coll)? On Feb 15, 11:48 am, wubbie wrote: > Also how left and right gets mapped magically to (first tree) and > (rest tree)? > Is it destructuring? I have some ideas on destructuring

Re: count-leaves from onLisp question

2009-02-15 Thread wubbie
Also how left and right gets mapped magically to (first tree) and (rest tree)? Is it destructuring? I have some ideas on destructuring but this left and right things confuses me... thanks sun On Feb 15, 11:31 am, wubbie wrote: > thanks, > it works, although it does not count ni

Re: count-leaves from onLisp question

2009-02-15 Thread wubbie
t-leaves [[left & right :as tree]] >   (if (seq tree) >     (+ (if (sequential? left) >          (count-leaves left) >          1) >        (count-leaves right)) >     0)) > > user> (count-leaves []) > 0 > user> (count-leaves [1 [2 [3]]]) > 3 > user>

Re: count-leaves from onLisp question

2009-02-15 Thread wubbie
ree))) >     (or tree 0))) > > user> (count-leaves [1 2 3]) > 6 > user> (count-leaves [1 [2] 3]) > 6 > user> (count-leaves []) > 0 > > On Feb 15, 10:55 am, wubbie wrote: > > > Hi, > > > Trying to convert to clojure but stumbled on i

count-leaves from onLisp question

2009-02-15 Thread wubbie
Hi, Trying to convert to clojure but stumbled on it... (defun count-leaves (tree) (if (atom tree) 1 (+ (count-leaves (car tree)) (or (if (cdr tree) (count-leaves (cdr tree))) 1 > (count-leaves ’((a b (c d)) (e) f)) 10 My clojure version is: user=> (defn count-leaves [t

why (seq? [1 2 3]) yields false?

2009-02-14 Thread wubbie
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 clojure@googl

Re: why fn key doesn't do what I want?

2009-02-14 Thread wubbie
thanks! sun On Feb 14, 4:34 pm, Brian Doyle wrote: > On Sat, Feb 14, 2009 at 2:24 PM, wubbie wrote: > > > Hi, > > > a quick question: > > > user=> (keys {:a 1 :b 2}) > > (:a :b) > > > But > > user=> (key {:a 1}) > > java.lang.Cl

why fn key doesn't do what I want?

2009-02-14 Thread wubbie
Hi, a quick question: user=> (keys {:a 1 :b 2}) (:a :b) But user=> (key {:a 1}) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:0) I see defn key in core.clj, though. What can be the correct usage of fn key, then? thanks in a

how to emulate lisp's labels functionality?

2009-02-13 Thread wubbie
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))) (map

Re: how can I do this?

2009-02-12 Thread wubbie
/isDigit > % > > if you prefer a more haskellish form :-) > > 2009/2/12 wubbie > > > > > Hello, > > > How can I do this? Do we have a function that checks if > > it's a char or digit? > > > (dig

how can I do this?

2009-02-12 Thread wubbie
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

Re: how not to deref @ again?

2009-02-11 Thread wubbie
thanks Meikel, I'll have a look. Cheers, sun On Feb 11, 6:09 pm, Meikel Brandmeyer wrote: > Hi, > > Am 11.02.2009 um 23:59 schrieb wubbie: > > > In some post Rich recommended: > >   (let [z (ref 0)] > >   (defn add2 [] (dosync (alter z #(inc %) > &

how not to deref @ again?

2009-02-11 Thread wubbie
Hi, In some post Rich recommended: (let [z (ref 0)] (defn add2 [] (dosync (alter z #(inc %) instead of (let [z (ref 0)] (defn add2 [] (dosync (refset z (inc @z) ; !!! deref @z again Then Is there any way not to deref again for this? It's from ants.clj (alter oldp assoc :phe

Re: how to reason about two dimentional array(vector) like...

2009-02-05 Thread wubbie
for simplicity, first tried to create two dimentional array(vector) of numbers. On Feb 5, 1:58 am, Emeka wrote: > Where did 'ref' go in your own implementation? > > Emeka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gro

Re: how to reason about two dimentional array(vector) like...

2009-02-04 Thread wubbie
.. On Feb 5, 12:19 am, wwmorgan 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 wrote

how to reason about two dimentional array(vector) like...

2009-02-04 Thread wubbie
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 sim

Re: what does -> mean?

2009-02-02 Thread wubbie
any concrete example? thanks, -sun On Feb 2, 5:13 am, Christian Vest Hansen wrote: > On Sun, Feb 1, 2009 at 9:35 PM, e wrote: > > This may be obvious to others, but what's the motivation behind it?  Is it > > that we are very concerned about combatting the criticism that lisp has too > > many

what does -> mean?

2009-01-31 Thread wubbie
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

newbie Q: can I optimize away like this?

2009-01-31 Thread wubbie
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 fun))

Re: Simple Examples of Concurrency?

2009-01-30 Thread wubbie
or run this > > java clojure.lang.Script test.clj > > - the output 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 >

Re: Simple Examples of Concurrency?

2009-01-29 Thread wubbie
the built-in global vars (there is more - > vars like *command-line-args*, *compile-path* and others in core.clj > file). > > If you really need to see the source of it, look for SOURCE_PATH in > Compiler.java in Clojure's source code in jvm/clojure/lang directory. > > Chee

Re: Simple Examples of Concurrency?

2009-01-29 Thread wubbie
lojure.core/*file* > nil >   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 wrote: > > > Hello, > > > As you see, java.io.File. construct takes path argument but it is the

Re: Simple Examples of Concurrency?

2009-01-29 Thread wubbie
ire commands player rooms]) (:use [clojure.contrib server-socket duck-streams])) thanks, sun On Jan 28, 8:05 pm, wubbie wrote: > Hi, > > I see > (add-classpath (str "file://" (.getParent (java.io.File. *file*)) > "/")) > in mire.clj. > Wha

How come *file* is assigned to current (running) dir?

2009-01-28 Thread wubbie
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 clojure.ma

Re: Simple Examples of Concurrency?

2009-01-28 Thread wubbie
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 wrote: > Keith Bennett writes: > > I'm trying to wrap my head around Clojure's

Re: Simple Examples of Concurrency?

2009-01-28 Thread wubbie
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 wrote: > The notation mire.rooms/ is

Re: Simple Examples of Concurrency?

2009-01-28 Thread wubbie
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 wrote: > wubbie writes: > > @mire.rooms/*rooms* is new to me. > > could anybody explain to me? > > Sure thing. *rooms* is a

Re: Simple Examples of Concurrency?

2009-01-28 Thread wubbie
ue of *in*/ *out* (binding [*name* (read-name) *inventory* (ref []) *current-room* (ref (@mire.rooms/*rooms* :start))] On Jan 27, 8:45 pm, "Stephen C. Gilardi" wrote: > On Jan 27, 2009, at 3:57 PM, wubbie wrote: > > > Why defn ends with -(dash

Re: Simple Examples of Concurrency?

2009-01-27 Thread wubbie
Hi Phil, Why defn ends with -(dash)? (defn- mire-handle-client [in out] On Jan 27, 1:16 pm, Phil Hagelberg wrote: > Keith Bennett writes: > > I'm trying to wrap my head around Clojure's concurrency.  I'm new to > > Lisp-like languages, and the examples that I've found are a bit > > complex.

Re: NewBie Q: doall forces eval and dorun not; but why?

2009-01-25 Thread wubbie
ilardi" wrote: > On Jan 25, 2009, at 7: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 make

Re: what's the typical usage of fn constantly

2009-01-25 Thread wubbie
ew constantly to be the same as identity except it > returns a function which can be passed around, rather than the value > itself. > > Finally, you could just as well do '#(identity the-value)' and get the > same result. > > user=> (= (#(identity "ab&q

Re: NewBie Q: doall forces eval and dorun not; but why?

2009-01-25 Thread wubbie
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" wrote: > > On Jan 25, 2009, at 6:45 PM, Laurent PETIT wrote: > > >> 2009/1/26 Stephen C. Gilardi > > >> Both for

Re: NewBie Q: doall forces eval and dorun not; but why?

2009-01-25 Thread wubbie
(when (and (seq coll) (or (first coll) true)) (recur (rest coll On Jan 25, 6:21 pm, "Stephen C. Gilardi" 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

NewBie Q: doall forces eval and dorun not; but why?

2009-01-25 Thread wubbie
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 (a

Re: what's the typical usage of fn constantly

2009-01-25 Thread wubbie
thanks James, I'll have a look. -sun On Jan 25, 2:00 pm, James Reeves wrote: > On Jan 25, 5:34 pm, wubbie wrote: > > > What's the typical usage of fn constantly ? > > When you need a function that constantly returns the same result :) > > That probably doesn

what's the typical usage of fn constantly

2009-01-25 Thread wubbie
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,

Re: are (swing) elements in a data structures read only?

2009-01-24 Thread wubbie
How do you define side-effects? -sun On Jan 24, 5:26 am, Christophe Grand 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 missing

Re: newbie Q: recur vs self call

2009-01-24 Thread wubbie
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 wrote: > Hi, > > Am 24.01.2009 um 16:50 schrieb wubbie: > > > I wonder why self-call(

Re: merge, not just for maps?

2009-01-24 Thread wubbie
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

newbie Q: recur vs self call

2009-01-24 Thread wubbie
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)) (la

Re: what's the difference between when and if?

2009-01-24 Thread wubbie
n > does.  Up 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 wrote: > > > Here is c

what's the difference between when and if?

2009-01-24 Thread wubbie
Here is code from core.clj. The question is when to use when or if. (defn take "Returns a lazy seq of the first n items in coll, or all items if there are fewer than n." [n coll] (when (and (pos? n) (seq coll)) (lazy-cons (first coll) (when (> n 1) (take (dec n) (rest coll)

Re: contains

2009-01-23 Thread wubbie
(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 wrote: > On Fri, Jan 23, 2009 at 2:51 PM, Chouser wrote: > > > On Fri, Jan 23, 2009 at 3:47 PM, Mark Volkmann > > wrote: > > >> (c

Re: Not nil and 'true' with conditional functions

2009-01-23 Thread wubbie
Is every function supposed to return something? Of course, except for pure side-effects. -sun On Jan 23, 3:02 pm, Vincent Foley 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 > result, you don't ne

Re: newbie Q: what's wrong with this?

2009-01-23 Thread wubbie
thanks -sun On Jan 23, 1:43 pm, vthakr wrote: > Hi Wubble, > > Looking at the code you have above I thought I might point out that > rather than create an anonymous function inside of sum and then call > it immediately after finishing its description, you could just use the > loop/recur constru

Re: newbie Q: what's wrong with this?

2009-01-23 Thread wubbie
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 wrote: > Two mistakes: > > First, if you want sum to take a vector, you should remove the & from > the arglist. > Second, (rest(other)) sh

newbie Q: what's wrong with this?

2009-01-23 Thread wubbie
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: clojure.lang.Laz

what "when (some identity maps)" mean?

2009-01-22 Thread wubbie
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 th

What's best way to get rid of #

2009-01-20 Thread wubbie
Hi I would just print the files, excluding "#". what's the best way? user=> (filter recently-modified? (file-seq (File. "."))) (# # #) Thanks -Sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: why (into [] [1 2 3]) works, but not (into [] (1 2 3))?

2009-01-18 Thread wubbie
thanks, I forgot about that. sun On Jan 18, 4:00 pm, "Nick Vogel" 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 wrote: > > > Hi, >

why (into [] [1 2 3]) works, but not (into [] (1 2 3))?

2009-01-18 Thread wubbie
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

how to know which version of clojure?

2009-01-18 Thread wubbie
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 thin

is it type hint?

2009-01-16 Thread wubbie
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 b

Newbie question on *agent* here

2009-01-15 Thread wubbie
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 sun

Re: newbie destructuring question

2009-01-15 Thread wubbie
> Extra pair of []? What do you mean? Sorry, my bad. -sun On Jan 15, 1:25 pm, James Reeves wrote: > On Jan 15, 2:54 pm, wubbie wrote: > > > But in partial desctructuring, [[a [b]] has extra pair of outer-most > > [] which leads to confusion. Any explanation on th

newbie destructuring question

2009-01-15 Thread wubbie
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 string

Is there any way to dereference %1 %2 etc?

2009-01-14 Thread wubbie
(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 --~--~-~--~~~-

Re: newbie question!!

2009-01-14 Thread wubbie
Thanks David. -sun On Jan 14, 11:55 am, David Nolen 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 Google Groups "C

newbie question!!

2009-01-14 Thread wubbie
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 bi

Re: Simple Data Structure Question

2009-01-13 Thread wubbie
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 #{#}, :name "Bob"} -sun On Jan 10, 9:44 pm, Stuart Sierra wrote: > Hi Patrick, > > Here's one way to do it: > > (defn new-person [name] >   (ref {:name name, :frien

adding line number while reading a file

2009-01-09 Thread wubbie
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 s

Re: How can I find all files ending with .clj, for example

2009-01-08 Thread wubbie
thank, it was str as usual. On Jan 8, 9:22 pm, "Brian Doyle" wrote: > This works: > > (filter #(re-find #"\.clj$" (str %)) (file-seq(java.io.File. "."))) > > On Thu, Jan 8, 2009 at 7:16 PM, wubbie wrote: > > > I tried > > &

Re: How can I find all files ending with .clj, for example

2009-01-08 Thread wubbie
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 wrote: > On 9 Jan., 03:03, Achim Passen wrote: > > > (filter #(re-find #".clj$

Re: How can I find all files ending with .clj, for example

2009-01-08 Thread wubbie
thanks, Is there anyway to specify regular expression, instead of startsWith/ endsWith? -sun On Jan 8, 8:00 pm, James Reeves wrote: > On Jan 9, 12:48 am, wubbie wrote: > > > I can use file-seq > > (file-seq (File. ".")) > > But how can I filter out all files

How can I find all files ending with .clj, for example

2009-01-08 Thread wubbie
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 p

Re: nested transactions

2009-01-07 Thread wubbie
So nested transactions only keep track of nesting level similar to that in Sybase? Sun On Jan 7, 12:18 pm, Rich Hickey wrote: > On Jan 7, 12:07 pm, "Mark Volkmann" wrote: > > > Are there any particular issues with using nested transactions ... > > dosync inside a dosync ... in Clojure? > > Nop

Re: what's wrong with this?

2009-01-07 Thread wubbie
typo... and looks working... should be (println (format "%s %d" s i))) On Jan 7, 10:44 am, wubbie 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"

what's wrong with this?

2009-01-07 Thread wubbie
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

metadata question

2009-01-06 Thread wubbie
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.co

Re: terminating an app that uses agents

2009-01-06 Thread wubbie
, 2009 at 10:00 AM, wubbie 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 wh

Re: automatic deref

2009-01-06 Thread wubbie
both (my-ref :a) and (@my-ref :a) returns 1. hmmm... On Jan 6, 11:01 am, "Mark Volkmann" wrote: > Why does this output 1? > > (def my-ref (ref {:a 1})) > (my-ref :a) > > I thought I could only access data in a ref by dereferencing it, but > this shows otherwise. > > -- > R. Mark Volkmann > Obje

Re: terminating an app that uses agents

2009-01-06 Thread wubbie
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) # user=> @counter 1 user=> (def my-agent (agent 1)) #'user/my-agent

Re: process inferior-lisp core dumped!

2009-01-05 Thread wubbie
Ok, I'll do it. Thanks Sun On Jan 5, 6:36 pm, Randall R Schulz wrote: > On Monday 05 January 2009 15:30, wubbie wrote: > > > > > Hi, > > > I got core dump while running > > > ... > > > user=> # > > # An unexpected error has been dete

process inferior-lisp core dumped!

2009-01-05 Thread wubbie
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, ti

Re: newbie question on binding

2009-01-05 Thread wubbie
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 wrote: > Hi, > > Am 05.01.2009 um 18:35 schrieb wubbie: > > > This example is from clojure s

newbie question on binding

2009-01-05 Thread wubbie
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

what's the correct syntax for new clojure?

2009-01-03 Thread wubbie
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 (

How to interpret nested back quote in Macro?

2009-01-02 Thread wubbie
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: (chec

Re: what's the new syntax for (dotimes _ (apply f [i]) (print "*")) ?

2009-01-01 Thread wubbie
Thanks Chouser, Happy new year! sun On Jan 1, 12:37 am, Chouser wrote: > On Wed, Dec 31, 2008 at 11:41 PM, wubbie wrote: > > > Hi all, > > > what's the new syntax for this? > > It is part of the code below which was translation by Stu. > > That'

what's the new syntax for (dotimes _ (apply f [i]) (print "*")) ?

2008-12-31 Thread wubbie
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 --~--~-~--~

send-off *agent* #' func

2008-12-30 Thread wubbie
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

Re: what does -> mean?

2008-12-29 Thread wubbie
he first form as the > second item in second form, etc. > nil > > On Dec 29, 8:27 pm, wubbie wrote: > > > Hi all, > > > Looking into ants.clj, I came across > > (defn place [[x y]] > > (-> world (nth x) (nth y))) > > > What -> mean here?

what does -> mean?

2008-12-29 Thread wubbie
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,

Re: clojure slime/swank mode problem -- still NewBie

2008-12-28 Thread wubbie
emacs configuration; I just execute M-x slime to start slime -- Chousuke (defun run-clojure () "Starts clojure in Slime" (interactive) (slime 'clojure)) ;; To use other Lisps... ;; Incidentally, you can then choose different Lisps with ;; M-- M-x slime ;; (add-to-list &#

clojure slime/swank mode problem -- still NewBie

2008-12-28 Thread wubbie
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) (swank.swank/ignor

Re: why two list comprehensions are different?

2008-12-27 Thread 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. On Dec 27, 4:29 pm, "Michael Wood" wrote: > On Sat, Dec 27, 2008 at 11:01 PM, wubbie wrote: > > > Hi, > > W

why two list comprehensions are different?

2008-12-27 Thread wubbie
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

where is set operations (union, intersection, etc) defined?

2008-12-27 Thread wubbie
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

Re: Proxying in clojure

2008-12-23 Thread wubbie
Hi Steve, It works now. thanks Sun On Dec 23, 9:42 pm, "Stephen C. Gilardi" wrote: > On Dec 23, 2008, at 9:28 PM, wubbie wrote: > > > Hi, > > I ran it with the changes and got the message: > > java.lang.IllegalArgumentException: Don't know how to creat

Re: Proxying in clojure

2008-12-23 Thread wubbie
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.an

Re: Proxying in clojure

2008-12-23 Thread wubbie
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" wrote: > On Dec 23, 2008, at 5:19 PM, MattyDub wrote: > > > On the

Re: question about (commute messages conj msg)

2008-12-16 Thread wubbie
Thanks Randall. My background is mostly in imperative languages, including perl and perl has closure, so it looks commute uses closure concept to implement this. Is it right? Thanks again, sun On Dec 16, 9:28 pm, Randall R Schulz wrote: > On Tuesday 16 December 2008 18:10, wubbie wr

question about (commute messages conj msg)

2008-12-16 Thread wubbie
Hello, My question is that conj takes two argument and how conj finds the first argument? Is it somehow provided by commute? Thanks, sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

doall and dorun

2008-12-15 Thread wubbie
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=> (dor

newbie question on true?

2008-12-13 Thread wubbie
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 wh

Re: Swing GUI Builder and Clojure

2008-12-12 Thread wubbie
Hi Geoffrey, Thanks for the tip. I put . for every command within the doto. Also looking forward to having a look at the Qt work you are currently doing. Cheers, Sun On Dec 12, 4:32 am, "Geoffrey Teale" wrote: > 2008/12/12 Geoffrey Teale > > > > > Hi, > > > Depending on which version of Cloj

Re: Swing GUI Builder and Clojure

2008-12-11 Thread wubbie
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 Q