Re: Dynamic scoping issue

2011-03-21 Thread Ken Wesson
On Mon, Mar 21, 2011 at 4:03 AM, Tassilo Horn tass...@member.fsf.org wrote: Why do I use a dynamic var in the first place?  I want to use the simple names in the lexical scope of the `with-schema-imports' block, and I used a dynamic var only because the resolution takes place somewhere in the

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 4:16 PM, Tassilo Horn tass...@member.fsf.org wrote: the println prints {Locality localities.Locality}, which is correct. However, my resolving function errors because there is no class Locality.  In the error message, I also print the value of *schema-imports*, and in

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 5:17 PM, Tassilo Horn tass...@member.fsf.org wrote: Ken Wesson kwess...@gmail.com writes: the println prints {Locality localities.Locality}, which is correct. However, my resolving function errors because there is no class Locality.  In the error message, I also print

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 5:41 PM, Tassilo Horn tass...@member.fsf.org wrote: Ken Wesson kwess...@gmail.com writes: Hi Ken, Does the resolving function run on, or use, another thread? No, it runs in the same thread.  But some functions like `vseq' in the example produce LazySeqs.  So

Re: concise description of SLIME indentation rules?

2011-03-18 Thread Ken Wesson
On Fri, Mar 18, 2011 at 4:05 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Sure, this is the target solution. More complex than what I've done, though. And the gathering of the metadata is not easy, also. Any Clojure IDE that can open a REPL should be able to get at the metadata. Just

Re: concise description of SLIME indentation rules?

2011-03-18 Thread Ken Wesson
On Fri, Mar 18, 2011 at 7:24 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Ah, you're worried about resolve? Not at all. ns-resolve will not discover vars if the namespace hasn't been required, used or loaded first. It's the user's own damn fault if some things won't indent the way they

Re: Can't recur from within a catch expression.

2011-03-18 Thread Ken Wesson
On Fri, Mar 18, 2011 at 1:13 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: The `try-times` macro above is buggy (doesn't work when body of code returns logical false). Fixed version is below: (defmacro try-times  [n body] {:pre [(posnum? n)]}  `(let [c# (repeat-exec (dec ~n) #(maybe

Re: Operations inside associative structures

2011-03-18 Thread Ken Wesson
On Fri, Mar 18, 2011 at 9:04 PM, Nick npatric...@gmail.com wrote: I'm looking to do some operations upon the data in an associative structure.  What do you think about this method of hijacking the definition of assoc-in?  Is there some better way to do what I'm doing here? user (defn op-in

Re: Can't recur from within a catch expression.

2011-03-18 Thread Ken Wesson
It occurs to me you probably only want the delay between successive retries, so really you want to put the delay in the retrying code, or maybe use interpose in some manner (and make the interposed delay function look like a failure to the surrounding loop). -- You received this message because

Re: concise description of SLIME indentation rules?

2011-03-17 Thread Ken Wesson
On Thu, Mar 17, 2011 at 6:22 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Lee, while we're at it. I decided to finally give it a try, and so I implemented an alternate behaviour for smart indent for ccw : the version of the gist does the following : it uses the following function to test

Re: Software Engineering Practices for Marking Algorithms?

2011-03-16 Thread Ken Wesson
On Wed, Mar 16, 2011 at 7:35 PM, CuppoJava patrickli_2...@hotmail.com wrote: Thank you for the reply again Mark. Actually, now that I've had some time to think about your solution, I think it, is in fact, suitable for myself after all. There's just some trickiness involving handing out the

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Ken Wesson
On Tue, Mar 15, 2011 at 11:17 AM, Armando Blancas armando_blan...@yahoo.com wrote: If so, it's only the subforms not in operator position that get macroexpanded first. Otherwise user= (defmacro qqq [] 'if) #'user/qqq user= ((qqq) (even? 42) boo!) #CompilerException java.lang.Exception:

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Ken Wesson
On Mon, Mar 14, 2011 at 11:15 PM, Daniel Solano Gomez cloj...@sattvik.com wrote: This method works fairly well, and you can even use it to define protocols for types you don't control, such as classes from a Java API. If you need some more complicated form of dispatch for polymorphism, there

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Ken Wesson
On Tue, Mar 15, 2011 at 12:58 PM, Armando Blancas armando_blan...@yahoo.com wrote: Another choice is to construct shapes as closures with auto-dispatch. So a circle could be made thus, with no data structure per se: (defn make-circle [x y r]  (fn [method]    (case method      :draw (fn

Re: How to read this sample code?

2011-03-15 Thread Ken Wesson
(when pred (foo) (bar)) just calls foo and then bar if pred evaluates to logical true, and falls through otherwise. There's no parentheses around the pred, so it just looks up pred without trying to call it as a function. So, it's not pred's return value it's conditioning on, but pred's own

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Ken Wesson
On Wed, Mar 16, 2011 at 12:01 AM, CuppoJava patrickli_2...@hotmail.com wrote: If someone knows of a better way of implementing these marking algorithms, or a nice way of organizing these marker fields, I would love to hear your workarounds. HashSets of visited Nodes. Test with contains?. --

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
Well, except that count and empty are broken for some reason: user= (.count (Bag. {} 0)) 0 user= (count (Bag. {} 0)) 1 I don't understand what's causing this, but empty bags are always returning a count of 1 (and false from empty?) although the .count method correctly returns zero. I've

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 3:49 AM, Ken Wesson kwess...@gmail.com wrote: Well, except that count and empty are broken for some reason: user= (.count (Bag. {} 0)) 0 user= (count (Bag. {} 0)) 1 I don't understand what's causing this, but empty bags are always returning a count of 1 (and false

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
Here is a bag implementation: (defprotocol SetOps (disjoin* [this obj]) (has* [this obj]) (total [this obj]) (counts [this])) (defn disjoin ([s] s) ([s obj] (disjoin* s obj)) ([s obj more] (apply disjoin (disjoin s obj) more))) (defn difference ([s] s) ([s other]

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 4:12 AM, Alan a...@malloys.org wrote: By the way, thanks for the very thorough Bag implementation. Your implementations of the very detailed things that people wish Clojure had are always interesting reading. You're welcome. I solved the count problem independently,

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
(defn bag-of [coll] (apply bag coll)) just so we have analogues of both vec and vector here. -- 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

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 5:11 AM, Dominikus dominikus.herzb...@gmail.com wrote: But I can call the redefined 'if' only with a qualified symbol name user= (user/if 3) 9 Or using apply: user= (apply if [3]) 9 You can even just rename it: user= (let [a if] (a 3)) 9 Cute, but you probably

Re: Multiple replacements in string using a map

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 2:17 PM, Daniel Solano Gomez cloj...@sattvik.com wrote: On Mon Mar 14 13:02 2011, shuaybi2 shuaybi2 wrote: I have a string such as: select * from account where acctId = _ACCT-ID_ and acctTyp = _ACCT-TYP_ I have a map such as: {:_ACCT-ID_ 9876 :_ACCT-TYP B} I want

Re: (.contains (transient #{}) 17) == true!?!

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 4:13 PM, Tassilo Horn tass...@member.fsf.org wrote: Hi all, I've implemented IEditableCollection support for ninjudd's PersistentOrderedSet.  But when using that, my application delivered wrong results.  See 87hbb6c4qf@member.fsf.org and follow-ups. I was able to

Re: (.contains (transient #{}) 17) == true!?!

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 4:41 PM, Alan a...@malloys.org wrote: Thanks Ken, I found this too when I saw Tassilo's problem on irc (didn't notice it was on ML as well). I was going submit a patch for this, but if you've already done so let me know and I won't. I don't have a CA so no, I haven't.

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 6:32 PM, Dominikus dominikus.herzb...@gmail.com wrote: I did some investigations on the code in Compiler.java. There is an IPersistentMap called 'specials' (line 95, Clojure 1.2) that maps symbols like 'if' to parsers like IfExpr.Parser(); obviously, these are the

Re: intersection and union on sequences/lists

2011-03-13 Thread Ken Wesson
On Sun, Mar 13, 2011 at 3:50 PM, Alan a...@malloys.org wrote: Why shouldn't it give '(3 3 3)? It looks like you've introduced a fairly arbitrary distinction between the first and second arguments to a normally-symmetric function, intersect. And you would get the same behavior by using one of

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-12 Thread Ken Wesson
On Sat, Mar 12, 2011 at 10:44 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: Yes, but create a static final member in the class I'm generating bytecode for, stuff the object in that static member, and embed a reference to the static member here seems like a sensible thing for it to do.

Re: Question about the Clojure load-file command

2011-03-12 Thread Ken Wesson
On Sat, Mar 12, 2011 at 7:49 PM, Larry Travis tra...@cs.wisc.edu wrote: I'm having trouble getting the load-file command to work in a Clojure repl. On some files it works and on some it doesn't. Here is an example of its not working: I do: (load-file

Re: Monad Lessons

2011-03-12 Thread Ken Wesson
On Sat, Mar 12, 2011 at 7:20 PM, Brian Marick mar...@exampler.com wrote: http://www.vimeo.com/20963938 Your sequence-decider can be simplified a bit: (mapcat rest-fn step-val). :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: Question about the Clojure load-file command

2011-03-12 Thread Ken Wesson
On Sat, Mar 12, 2011 at 9:46 PM, Larry Travis tra...@cs.wisc.edu wrote: Ken: The cause of my difficulty indeed was a corrupted file. I was looking for it in a completely different direction, and I clearly don't know how to correctly parse Java error messages! Thank you very much for sharing

Re: Why does this break memoization?

2011-03-11 Thread Ken Wesson
On Fri, Mar 11, 2011 at 3:54 AM, Tassilo Horn tass...@member.fsf.org wrote: Ken Wesson kwess...@gmail.com writes: Hi Ken Alan, Adding metadata to an object produces a new object, rather than altering the existing object.  Every time you increment the counter for a function in p it becomes

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Ken Wesson
On Fri, Mar 11, 2011 at 11:52 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: `eval` invokes the Clojure compiler, which transforms data structures into Java bytecode.  The Clojure compiler understands Clojure data structures like lists, vectors, and symbols, plus a few Java types like

Re: setup and propagation of config-params

2011-03-10 Thread Ken Wesson
On Thu, Mar 10, 2011 at 9:51 AM, faenvie faen...@googlemail.com wrote: references to *opts* are scattered all over my clojure-code so that many of the functions are impure. this seems like a smell to me and there are probably cleaner ways to propagate config-params (keep functions pure) ...

Re: Why does this break memoization?

2011-03-10 Thread Ken Wesson
Adding metadata to an object produces a new object, rather than altering the existing object. Every time you increment the counter for a function in p it becomes different, and the memoize treats it as new. That is, p-apply-memoized takes parameters p and v. Your post-walk over p replacing

Re: [ANN] borneo - Clojure wrapper for Neo4j, a graph database.

2011-03-09 Thread Ken Wesson
On Wed, Mar 9, 2011 at 1:22 PM, Jozef Wagner jozef.wag...@gmail.com wrote: On Wednesday, March 9, 2011 3:09:05 PM UTC+1, Baishampayan Ghose wrote: I've released a Clojure wrapper for Neo4j called borneo. Purpose of this library is to provide intiutive access to commonly used Neo4j

Making the JVM's stack effectively deeper

2011-03-09 Thread Ken Wesson
It seems to me there is a way to make the JVM's stack effectively deeper -- even limited only by available memory. Threads have separate stacks, and there's no limit on threads, *especially* if they're nearly all sleeping. So ... (defn apply-with-stack-extension [f args] (let [x (future

Re: Making the JVM's stack effectively deeper

2011-03-09 Thread Ken Wesson
On Wed, Mar 9, 2011 at 6:59 PM, Alan a...@malloys.org wrote: Clever, but do we really want to encourage writing code that blows infinite stack, by burying the problem until all of the JVM's memory has been used up for stack? I agree there's a place for this sort of thing, but I don't think we

Re: [ANN] borneo - Clojure wrapper for Neo4j, a graph database.

2011-03-09 Thread Ken Wesson
On Wed, Mar 9, 2011 at 8:15 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Minor observation, it seems you are using `proxy` to implement interfaces. Why not use `reify` instead? Thank you for this remark. reify would be more idiomatic, I'll change it. proxy is a clojure-neo4j leftover, from

Re: arithmetic progression

2011-03-08 Thread Ken Wesson
On Tue, Mar 8, 2011 at 10:42 AM, Chris Perkins chrisperkin...@gmail.com wrote: You'll probably want to add checks for special cases, like an empty or one-element sequence, too. Better yet, clojure.core should amend = so that (=) and (= x) return true instead of throwing an arity exception. That

Re: arithmetic progression

2011-03-08 Thread Ken Wesson
On Tue, Mar 8, 2011 at 2:28 PM, Alan a...@malloys.org wrote: On Mar 8, 10:27 am, Ken Wesson kwess...@gmail.com wrote: On Tue, Mar 8, 2011 at 10:42 AM, Chris Perkins chrisperkin...@gmail.com wrote: You'll probably want to add checks for special cases, like an empty or one-element sequence

Re: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 8:40 AM, Chas Emerick cemer...@snowtide.com wrote: On Mar 6, 2011, at 11:53 AM, Ken Wesson wrote: On Sun, Mar 6, 2011 at 11:00 AM, Chas Emerick cemer...@snowtide.com wrote: Rather than enumerate the places where sexprs are sub-optimal, it would save a *lot* of time

Re: Are there sets that keep the insertion order?

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:14 PM, Tassilo Horn tass...@member.fsf.org wrote: Hello all, does clojure have sets that keep the insertion order, like Java's LinkedHashSet? Currently, I use lazy vectors in conjunction with `distinct', but that seems to perform not too well. Bye, Tassilo Try

Re: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:48 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 07.03.2011 um 17:08 schrieb Ken Wesson: Bzzzt, sorry. Their choice seems as arbitrary as any other, much of the time. Ask yourself this: if aliens from another planet are at about the same level of development

Re: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:56 PM, Timothy Baldridge tbaldri...@gmail.com wrote: ...because they are easier to parse by the human brain. You keep saying that, and I don't think I agree. They may be easier to parse for western culture due to the hundreds of years of our brains being presented with

Re: overriding keyword behavior?

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 9:34 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: Yes, something like tonyl's code will work. OH RLY? #CompilerException java.lang.IllegalArgumentException: interface clojure.lang.ILookup is not a protocol (NO_SOURCE_FILE:10) -- You received this message because

Re: Summer of Code 2011

2011-03-06 Thread Ken Wesson
On Sun, Mar 6, 2011 at 8:39 AM, Chas Emerick cemer...@snowtide.com wrote: No, you're exactly right.  Leaving aside the obvious utility of being able to consume non-sexpr-structured content/data, there are plenty of domains for which s-expressions are not optimal, or even well-suited. An

Re: Summer of Code 2011

2011-03-06 Thread Ken Wesson
On Sun, Mar 6, 2011 at 11:00 AM, Chas Emerick cemer...@snowtide.com wrote: Rather than enumerate the places where sexprs are sub-optimal, it would save a *lot* of time to simply point out that: (a) Every general-purpose programming language notation is a poor substitute for the native

Re: Summer of Code 2011

2011-03-06 Thread Ken Wesson
On Sun, Mar 6, 2011 at 12:13 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 06.03.2011 um 17:53 schrieb Ken Wesson: Ah, but what, pray tell, *is* the native notation of a domain? And why are you so sure it's almost never sexps? Sexps are a natural fit to at least one other domain I can

Re: Summer of Code 2011

2011-03-06 Thread Ken Wesson
On Sun, Mar 6, 2011 at 12:27 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 06.03.2011 um 18:19 schrieb Ken Wesson: It's a matter of what you're used to. Fact is, a lot of mathematicians use LaTeX code, even in newsgroup posts and the like where it won't be typeset, and it reads a lot

Re: Writing a generic function for getting any value for a key

2011-03-05 Thread Ken Wesson
On Sat, Mar 5, 2011 at 3:37 AM, Alan a...@malloys.org wrote: Yeah, thanks for the reminder Ken. It's easy to assume people can just go look at SO to see the relevant question, but we're curating a sort of archive here as well so it's good to have a permanent link. Also, after a while the SO

Re: Serialising functions...

2011-03-05 Thread Ken Wesson
Christopher Brown asked me: Is there a reason a moderately strong random GUID generator is not enough? But I'm not the OP who wanted unique node-IDs, and the above doesn't seem to need to remain private, and it's also an interesting problem, so I'm going to post my reply to the list: Not if

Re: Summer of Code 2011

2011-03-05 Thread Ken Wesson
On Sat, Mar 5, 2011 at 2:35 PM, Timothy Washington twash...@gmail.com wrote: Indeed :) I've actually been thinking about that. And from what I can tell, LISP DSLs are simply extensions to the LISP language. But maybe I still haven't gotten my head wrapped around 'defmacros' and how they

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 7:50 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: This is hardly unfortunate! The API is carefully designed: object args come first, seq args come last. Eh, not always: conj, nth, and several others put seq args first, though cons can be used on seqs in place of

Re: unchecked-divide etc being replaced in 1.3 - no more support for longs?

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 6:43 AM, Joost jo...@zeekat.nl wrote: On Mar 2, 2:05 am, Jason Wolfe ja...@w01fe.com wrote: But I don't know what the plan is if you really do want truncating arithmetic on longs. On 1.3 alpha 4: user= (+ Long/MAX_VALUE Long/MAX_VALUE) ArithmeticException integer

Re: Serialising functions...

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 4:48 AM, Jules jules.gosn...@gmail.com wrote: So, I introduced the concept of a per-jvm id and hacked it into RT, Compiler and LispReader. There were not too many places that needed to be changed. Why not just use the machine's MAC address? user= (defn mac []

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 12:34 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: This is hardly unfortunate! The API is carefully designed: object args come first, seq args come last. Eh, not always: conj, nth, and several others put seq args first, though cons can be used on seqs in place

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 12:53 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: In the context of chaining operators such as -, it is logical to consider both the input and output of the function. The functions listed under the Seq In, Seq Out section at http://clojure.org/sequences should

Re: [Code Bounty] Implementing ClojureScript - command-line/sys-admin scripting with Clojure

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 1:41 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: There are difficulties with using Clojure -- or any JVM language -- for system administration.  The first and biggest is the JVM startup time, making it impractical for command-line use without a separate server

Re: [Code Bounty] Implementing ClojureScript - command-line/sys-admin scripting with Clojure

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 2:32 PM, Chas Emerick cemer...@snowtide.com wrote: I've actually come to think that perl may be a great Clojure host language Talk about Beauty and the Beast ... ;) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: Serialising functions...

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 1:09 PM, Christopher Brown cjbrown...@gmail.com wrote: It's always tempting to use the MAC address, and while in physical hardware it's unique, in networking it's only required to be unique within a single L2 domain. Some virtualized environments, including EC2, play

Re: Writing a generic function for getting any value for a key

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 8:25 PM, HB hubaghd...@gmail.com wrote: On Mar 5, 3:05 am, Alan a...@malloys.org wrote: Does my answer to your StackOverflow question also resolve this issue? Yes, it did and I was about resolving this post. Thanks. The issue is solved guys, thank you all for passing.

Re: Writing a generic function for getting any value for a key

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 10:07 PM, HB hubaghd...@gmail.com wrote: Sorry, my mistake. I will do this in the future, sorry for any inconvenience that may happened. Oh I wasn't accusing anyone of a mistake, just asking for the link (or the actual solution) to be posted for the benefit of readers of

Re: Summer of Code 2011

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 10:50 PM, Timothy Washington twash...@gmail.com wrote: I can tell you the tools that I'm investigating: A) From what I can tell, there's no standard (E)BNF parser generator for clojure. Who needs an (E)BNF parser generator when you've got defmacro? ;) -- You received

Re: Serialising functions...

2011-03-04 Thread Ken Wesson
On Fri, Mar 4, 2011 at 8:07 PM, Christopher Brown cjbrown...@gmail.com wrote: It will always return a MAC address, but in a virtualized environment those are a fiction and under the control of the VM creator (and hence, not real physical hardware). Since those MAC addrs are only required to

Re: Writing a generic function for getting any value for a key

2011-03-03 Thread Ken Wesson
On Thu, Mar 3, 2011 at 8:33 PM, HB hubaghd...@gmail.com wrote: Hi, I'm trying to write a function that gets the value for a key of a map. (def *places* {:room Nice room                    :basement what ever}) (defn describe-place [place places]   (places place)) (describe-place :room

Re: better error messages smaller stack traces

2011-03-02 Thread Ken Wesson
On Wed, Mar 2, 2011 at 3:32 AM, Alan a...@malloys.org wrote: '(apply + 1 1) would be how you create a list of those symbols. Or (list 'apply '+ 1 1) or `(apply + 1 1), both of which allow you to put something variable in there, like (list 'apply '+ 1 x) or `(apply + 1 ~x). -- You received this

Re: Printing to *out* from macro

2011-03-02 Thread Ken Wesson
On Wed, Mar 2, 2011 at 8:54 AM, Vitaly Peressada vit...@ufairsoft.com wrote: I want to have a way to print progress message before and after invoking a function/expression. Came up with this macro (defmacro run-with-msg [msg body]  (doto *out*  (. write (format %s... msg))  (. flush))  

Re: A blocking function

2011-03-02 Thread Ken Wesson
On Wed, Mar 2, 2011 at 6:49 PM, Daniel Solano Gomez cloj...@sattvik.com wrote: On Wed Mar  2 15:44 2011, clj123123 wrote: In a multi thread app, is there a way to mark a function to be blocking so it can run not simultaneously but would be blocking for each thread? You could try the locking

Re: Serialising functions...

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 5:59 AM, Jules jules.gosn...@gmail.com wrote: Unfortunately, I'd like it to be a open set, just as I would like the system's types to be - this was one of the choices driving Clojure over Java as the implementation language. The simplest thing I can think of in that

Re: Unpredictable behavior of Protocol Extension

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 8:32 AM, Chas Emerick cemer...@snowtide.com wrote: I agree with your sentiment.  This has been discussed before here: http://groups.google.com/group/clojure-dev/browse_frm/thread/fb3a0b03bf3ef8ca That discussion pretty quickly wandered into the weeds of whether this

Re: Master worker pattern

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 9:34 AM, Zlaja zlatko.jo...@gmail.com wrote: Hi, How I can achieve master worker pattern in clojure with agents. For example I have components that write messages to a queue. I would like to process messages parallel by agents. Is it posible? Thanks It may be

Re: Serialising functions...

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 9:25 AM, Jules jules.gosn...@gmail.com wrote: This is actualy my preferred route - however I've just revisited some test code I wrote a while back, that I thought I had working... - I only had it half working :-( - and in having another go at it, I've realised that

Re: Unpredictable behavior of Protocol Extension

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 11:30 AM, Chris Perkins chrisperkin...@gmail.com wrote: On Feb 28, 10:49 am, Rich Hickey richhic...@gmail.com wrote: On Feb 28, 2011, at 8:32 AM, Chas Emerick wrote: I agree with your sentiment.  This has been discussed before here:

Re: Master worker pattern

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 12:31 PM, Zlatko Josic zlatko.jo...@gmail.com wrote: First thanks for reply. if I use only one agent does it mean that the agent process one message by one? Yes. And messages sent from the same thread will be processed in the order that that thread sent them, also. --

Re: Serialising functions...

2011-02-28 Thread Ken Wesson
On Mon, Feb 28, 2011 at 2:51 PM, Seth wbu...@gmail.com wrote: Notice that saving the code wouldn't work if you had locals (i.e. clojures). On the other hand, clojures are serialized when you serialize the function. All the way back in my first post to this thread, I noted that for closures

Re: better error messages smaller stack traces

2011-02-27 Thread Ken Wesson
On Sat, Feb 26, 2011 at 8:14 PM, Mark markaddle...@gmail.com wrote: I get this: #CompilerException java.lang.IllegalArgumentException: Wrong number of args (3) passed to: Symbol (C:\Users\addma03\workspace\test\src\main \clojure:1) A few suggestions: 1)  An improved line number 2) I'd like

Re: better error messages smaller stack traces

2011-02-27 Thread Ken Wesson
On Sun, Feb 27, 2011 at 2:10 PM, Ken Wesson kwess...@gmail.com wrote: On Sat, Feb 26, 2011 at 8:14 PM, Mark markaddle...@gmail.com wrote: I get this: #CompilerException java.lang.IllegalArgumentException: Wrong number of args (3) passed to: Symbol (C:\Users\addma03\workspace\test\src\main

Re: Problem establishing jdbc connection in la clojure REPL

2011-02-27 Thread Ken Wesson
According to MSDN: WSAEPROVIDERFAILEDINIT 10106 Service provider failed to initialize. The requested service provider could not be loaded or initialized. This error is returned if either a service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or NSPStartup

Re: Serialising functions...

2011-02-25 Thread Ken Wesson
Embedding literal functions in macros sorta works. It behaves glitchy sometimes, especially if the functions are closures. If your set of functions is not open-ended, I'd suggest simply defn'ing all of them at both client and server sides, sticking them in a map, and putting a keyword instead of

Re: easier exit

2011-02-25 Thread Ken Wesson
On Fri, Feb 25, 2011 at 11:21 AM, Michael Wood esiot...@gmail.com wrote: Would this help? user= (def exit Use Ctrl-C to exit) #'user/exit user= exit Use Ctrl-C to exit user= Why stop there? (defn exit [] (System/exit 0)) -- You received this message because you are subscribed to the

Re: type hinting record types?

2011-02-25 Thread Ken Wesson
On Fri, Feb 25, 2011 at 8:26 PM, Seth wbu...@gmail.com wrote: Notice that this occurs even if i dont redefine record A - if i do (require :reload-all 'my-namespace), any old record object will now fail with type hinted functions. Reloading replaces A with a new instance of the A class. These

Re: easier exit

2011-02-25 Thread Ken Wesson
On Fri, Feb 25, 2011 at 9:39 PM, Alan a...@malloys.org wrote: On Feb 25, 6:21 pm, Ken Wesson kwess...@gmail.com wrote: On Fri, Feb 25, 2011 at 11:21 AM, Michael Wood esiot...@gmail.com wrote: Would this help? user= (def exit Use Ctrl-C to exit) #'user/exit user= exit Use Ctrl-C

Re: easier exit

2011-02-25 Thread Ken Wesson
On Fri, Feb 25, 2011 at 10:04 PM, .Bill Smith william.m.sm...@gmail.com wrote: If you are running any non-daemon threads, even System.exit won't cause the JVM to shut down. I'm pretty sure it will. Falling off the end of main won't and closing all GUI windows won't, but System/exit is supposed

Re: Ordering of defn's?

2011-02-23 Thread Ken Wesson
Java has a lack of this top-down processing, and it sometimes causes problems because the order in which static initializers will execute is not generally predictable. I don't have any problems with Clojure files being processed from the top down. I prefer to define my terms (simpler functions)

Re: Ordering of defn's?

2011-02-23 Thread Ken Wesson
On Wed, Feb 23, 2011 at 3:12 PM, Jonathan Mitchem jmitc...@gmail.com wrote: Java has a lack of this top-down processing, and it sometimes causes problems because the order in which static initializers will execute is not generally predictable. If you're programming with a side-effect free

Re: Ordering of defn's?

2011-02-23 Thread Ken Wesson
On Wed, Feb 23, 2011 at 4:54 PM, Alessio Stalla alessiosta...@gmail.com wrote: On 23 Feb, 19:51, Ken Wesson kwess...@gmail.com wrote: Java has a lack of this top-down processing, That's not true, what do you mean? class Foo {  void bar() { baz(); }  void baz() {} } compiles fine

Re: Release.Next Version Number

2011-02-23 Thread Ken Wesson
On Wed, Feb 23, 2011 at 9:23 PM, Brian Marick mar...@exampler.com wrote: On Feb 23, 2011, at 3:06 PM, David Jacobs wrote: Thanks for the suggestions. I should say that I was only giving you my impression of using Clojure re: it's version number. I'm not saying any of the things I listed

Re: Transforming map entries

2011-02-22 Thread Ken Wesson
On Tue, Feb 22, 2011 at 7:36 PM, Daniel Bell dchristianb...@gmail.com wrote: I don't know if it's specified in the documentation anywhere It doesn't seem to be. but (= map-I-made-up  (zipmap    (keys map-I-made-up)    (vals map-I-made-up))) returns true. However, it is clearly

Re: Implementing search algorithm for binary tree

2011-02-22 Thread Ken Wesson
On Tue, Feb 22, 2011 at 8:37 PM, HB hubaghd...@gmail.com wrote: Hi, I'm trying to implement searching algorithm for binary tree. Here is my Java implementation:    public Node findNode(Integer data) {        Node current = root;        while (!data.equals(current.getData())) {            

Re: Distributed atom :)

2011-02-22 Thread Ken Wesson
On Tue, Feb 22, 2011 at 10:37 PM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hello all, How could one simulate a distributed atom, e.g. a ref that get updated atomically and thus synchronised in two different processes. Has anyone thought about this in Clojure before? Well, the

Re: Importing and using Enum types

2011-02-22 Thread Ken Wesson
On Tue, Feb 22, 2011 at 11:38 PM, Kasim ktu...@gmail.com wrote: Hi Hackers, I am trying to import and use following Enum class from Clojure: http://build.xuggle.com/view/Stable/job/xuggler_jdk5_stable/javadoc/java/api/com/xuggle/xuggler/IContainer.Type.html Basically, I need it so that I can

Re: Passing vars

2011-02-21 Thread Ken Wesson
On Tue, Feb 22, 2011 at 1:35 AM, David Jagoe davidja...@gmail.com wrote: Hi Meikel, On 21 February 2011 15:18, Meikel Brandmeyer m...@kotka.de wrote: Hi, Is there a reason, not to use the function object directly? Just that I wanted to prevent adding the same function multiple times. You

Re: Docstring on def

2011-02-20 Thread Ken Wesson
On Sun, Feb 20, 2011 at 12:45 PM, Daniel Solano Gomez cloj...@sattvik.com wrote: On Sun Feb 20 17:30 2011, Paul Richards wrote: I've been trying to add docstrings to my constants that are defined using 'def'.  According to the webpage[1] I should be able to write: (def pi hello 3.14) But

Re: defrecord/deftype ...

2011-02-18 Thread Ken Wesson
On Fri, Feb 18, 2011 at 5:31 PM, Base basselh...@gmail.com wrote: Are there some things that you can do with maps that you cannot do with defrecord? Round-trip them through prn/read without them turning into something else. -- You received this message because you are subscribed to the Google

Re: Get digits of a number

2011-02-17 Thread Ken Wesson
On Thu, Feb 17, 2011 at 1:39 AM, Shantanu Kumar kumar.shant...@gmail.com wrote: On Feb 17, 11:09 am, Ken Wesson kwess...@gmail.com wrote: On Thu, Feb 17, 2011 at 12:29 AM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Is there an easy and idiomatic way of getting the digits

Re: Specialize collection

2011-02-17 Thread Ken Wesson
You can also create new types that act mostly like Clojure's existing types using deftype and implementing things like IPersistentStack. I posted code for (among other things) a bounded deque (using a ringbuffer internally) here fairly recently. The one limitation with these things is that they

Re: Realtime Clojure program

2011-02-16 Thread Ken Wesson
On Wed, Feb 16, 2011 at 3:36 AM, Marko Topolnik marko.topol...@gmail.com wrote: HOFs and lazy seqs add a bit more expense. Try deliberately throwing an exception in lazy-seq and then (first (map this (map that ... (my-exception-throwing-lazy-seq and see how deep the stack trace nests; the

Re: Creating prime? function

2011-02-16 Thread Ken Wesson
2011/2/16 Marek Stępniowski mstepniow...@gmail.com: On Thu, Feb 17, 2011 at 12:34 AM, HB hubaghd...@gmail.com wrote: I'm trying to write a function that determines if a number is a prime or not. Here is my first shot: (defn prime? [num]  (loop [i 2]    (if (= (* i i) num)      false)    

Re: Creating prime? function

2011-02-16 Thread Ken Wesson
Some clarifications. On Wed, Feb 16, 2011 at 8:50 PM, Ken Wesson kwess...@gmail.com wrote: Perfect squares are also worst-case (other than actual primes) To be exact, perfect squares /of primes/. Squares of composite integers halted on a smaller prime factor even in the original version

<    1   2   3   4   5   6   7   8   9   10   >