Re: reducing multiple sets

2010-05-22 Thread Michael Gardner
On May 22, 2010, at 10:00 AM, mikel wrote: Trying to get from here: #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } to here: #{[3 2] [5 4] [4 3] [2 2] [3 3] } that is, combining the set of sets into one set. (apply clojure.set/union #{#{[3 2] [5 4] [3 3]} #{[4 3] [5

Re: functional check slower than imperative?

2010-05-19 Thread Michael Gardner
On May 18, 2010, at 10:45 AM, Christophe Grand wrote: (every? f coll1 coll2) is not supported. Is there a reason for this? It seems like an obvious improvement to make every?, some, etc. take multiple args just like map. -- You received this message because you are subscribed to the Google

Re: setting vars with macro

2010-05-17 Thread Michael Gardner
On May 15, 2010, at 4:56 PM, islon wrote: I'm working in a simple single-thread console-based rpg game in clojure (a port from my own scala version) and didn't want to use any concurrency structure because the game is single threaded. I was thinking about a macro like (defmacro set!! [s

Style preference: (:key map) or (map :key)?

2010-05-17 Thread Michael Gardner
It appears the (:key map) style is more common than (map :key) among Clojurians. Is this true? So far I'm doing (map :key) because it's more familiar, and because it doesn't make me change styles when using something besides keywords as keys (admittedly rare so far). But I'd like to hear other

Re: Calling apply on java methods

2010-05-11 Thread Michael Gardner
On May 11, 2010, at 12:39 PM, Alexandre Patry wrote: I am trying to call a java method using apply, like : (apply .println [System/out hello world]) But I get an error: Unable to resolve symbol: .println in this context Am I missing something? Unfortunately, Java methods are not

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-30 Thread Michael Gardner
On Apr 30, 2010, at 6:33 AM, Rich Hickey wrote: Would contains-val? be fast for sets? As a user of sets, I consider them collections of values, and I absolutely would reach for contains-val? in any library that had it, for use with sets. If so, and I used contains-val?, and I moved code

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Michael Gardner
On Apr 29, 2010, at 3:21 AM, ataggart wrote: I know it won't matter, but for posterity if nothing else... Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to

Re: Beginners question about Don't know how to create ISeq from: Symbol

2010-04-19 Thread Michael Gardner
On Apr 19, 2010, at 4:52 PM, uap12 wrote: (defn -main (make-lotto)) ([] (-main ))) You're missing the empty arglist in your definition of -main. It should be: (defn -main [] (make-lotto)) -- You received this message because you are subscribed to the Google Groups Clojure group. To

Re: mutating multiple java swing components

2010-04-09 Thread Michael Gardner
On Apr 9, 2010, at 10:39 AM, Josh Stratton wrote: Here's an example of trying to use map to bring the two tables together together in the same scope. I'm doing this because the nth element in one sequence correlates to its nth counterpart in the second sequence. mainTables is a sequence of

Re: Mutually-referencing structures

2010-04-06 Thread Michael Gardner
On Apr 6, 2010, at 9:01 AM, Laurent PETIT wrote: * BUT : isn't the real problem that one will not content [him/her]/self with playing with in-memory data ? One will want to make the data persistent (outside-of-process, aka storage-persistance). And with this kind of problem, one will have

Re: A syntax question: positional keyword

2010-04-06 Thread Michael Gardner
On Apr 6, 2010, at 6:08 PM, Sophie wrote: Don't you think - fixed-order named parameters could (should?) be a separate issue from - optional, any-order, named parameters ? I don't see the advantage of fixed-order named parameters over keyword parameters. Note that you can require certain

Re: Mutually-referencing structures

2010-04-05 Thread Michael Gardner
On Apr 5, 2010, at 2:09 AM, Sophie wrote: (deftype Account [owner balance]) (deftype Person [accounts]) joe has 1 account. How to I create / initialize joe the account with mutual references? I'd rather not use refs. You can't do it directly without one of the two being mutable. But

Re: Mutually-referencing structures

2010-04-05 Thread Michael Gardner
On Apr 5, 2010, at 7:49 AM, Sophie wrote: Is this a Clojure restriction, or is it intrinsic to functional programming? It's a consequence of immutable data structures, which are an aspect of functional programming. An immutable object can never be changed, and you can't create multiple

Re: Mutually-referencing structures

2010-04-05 Thread Michael Gardner
On Apr 5, 2010, at 4:34 PM, Sophie wrote: But single-assignment is a quite valid (and more flexible?) form of immutability. I'm not convinced cycles are intrinsically tied to it in any way. If you can assign to it, it's mutable. What you're talking about is creating a mutable object, then

Re: getRuntime exec call?

2010-03-19 Thread Michael Gardner
On Mar 19, 2010, at 6:07 AM, TimDaly wrote: (defn cmdresult [cmdstr] (let [args (into [] (seq (.split cmdstr )))] (BufferedReader. (InputStreamReader. (. (. (. Runtime (getRuntime)) (exec args)) (getInputStream)) Why do (into [])? .exec expects a String[], exactly what

Re: map-filter, is this in the API?

2010-03-19 Thread Michael Gardner
On Mar 19, 2010, at 12:54 PM, Greg Fodor wrote: Very simple function: (defn map-filter [f coll] (map f (filter f (coll))) You have an extra parenthesis before coll. Is there an API function for this that I am missing? For example, it is useful for pulling out all values in a list of

Re: Java method call irritation

2010-03-18 Thread Michael Gardner
On Mar 18, 2010, at 10:55 AM, Per Vognsen wrote: Is there any reason why a .method occurrence in non-operator position doesn't just do the closure wrapping automagically? I'd like to know this as well. Smooth Java interop is one of Clojure's selling points, but having to wrap Java methods in

Re: Translation from Common Lisp 1

2010-03-18 Thread Michael Gardner
On Mar 18, 2010, at 4:17 PM, David Nolen wrote: On Thu, Mar 18, 2010 at 4:25 PM, alux alu...@googlemail.com wrote: Hello! I much enjoyed reading the tutorial http://www.lisperati.com/casting.html , mentioned by eyeris today. The most mind-extending thing (to me, having Java background) is

Spurious STDERR output (Picked up JAVA_TOOL_OPTIONS)

2010-03-12 Thread Michael Gardner
I noticed that when I set JAVA_TOOL_OPTIONS, clojure outputs the following to STDERR before it runs my code: Picked up JAVA_TOOL_OPTIONS: ... This interferes with e.g. running clojure scripts as cron jobs, since it's common to rely on the presence of output on STDERR to signal errors.

Re: collections within collections

2010-03-10 Thread Michael Gardner
On Mar 10, 2010, at 12:20 PM, Glen Rubin wrote: However, the output of my trips function yields multiple collections of vectors inside of a larger vector. I am completely befuddled as to how to process this behemoth. You can merge the structure into a single list of triples by applying

Re: apply-ing Java methods

2010-03-09 Thread Michael Gardner
On Mar 8, 2010, at 1:06 PM, Nurullah Akkaya wrote: Using this, http://paste.lisp.org/display/67182 would allow you to do, (let [config {:str fred :beg 2 :end 3}] (apply (jfn 'substring) (map config [:str :beg :end]))) That's quite nice. Thanks! -- You received this message because

Re: apply-ing Java methods

2010-03-09 Thread Michael Gardner
On Mar 8, 2010, at 11:20 PM, MichaƂ Marczyk wrote: It's simple to write this way... And if you provide type hints, I'd expect the resulting function to be quite performant. If you don't care about that, here's a flexible alternative using eval: user (defmacro methodfn [name] `(fn [

apply-ing Java methods

2010-03-08 Thread Michael Gardner
Given a Java instance 'store' with a .connect method that takes a host, port, user and password, and given a hash-map 'config' with corresponding keyword values, I wanted to do something like: (apply .connect store (map config [:host :port :user :password])) rather than: (.connect store

Re: apply-ing Java methods

2010-03-08 Thread Michael Gardner
On Mar 8, 2010, at 9:16 AM, Adrian Cuthbertson wrote: Maybe just; (let [{:keys host port user password} config] (.connect store host port user password)) Having to repeat the variable names rather defeats the purpose, since this version is longer than the original and still feels redundant

Unable to resolve symbol in third-party jarfile

2010-03-03 Thread Michael Gardner
As part of a project to help me learn Clojure, I'm trying to send an email using code like http://nakkaya.com/2009/11/10/using-java-mail-api-from-clojure/. For the JavaMail API I'm using GNU JavaMail, which in turn requires GNU JAF (activation.jar). When I try to run my program, I get:

Re: Unable to resolve symbol in third-party jarfile

2010-03-03 Thread Michael Gardner
On Mar 3, 2010, at 8:42 AM, Michael Wood wrote: On 2 March 2010 17:40, Michael Gardner gardne...@gmail.com wrote: As part of a project to help me learn Clojure, I'm trying to send an email using code like http://nakkaya.com/2009/11/10/using-java-mail-api-from-clojure/. For the JavaMail API

<    1   2   3