Re: scoped local memoize

2010-03-19 Thread Greg Fodor
Ah, I think I have the solution: (defn foo [] (let [bar-memoized (memoize bar)] ; Do stuff with bar-memoized )) Seems to work -- to verify, this will GC the memoized cache for bar after each call to foo, right? On Mar 19, 1:56 am, Greg Fodor gfo...@gmail.com wrote: Hi there -- I am

clojure-mode-like syntax highlighting for the SLIME REPL

2010-03-19 Thread Michał Marczyk
Hi Group, there was a Stack Overflow question recently re: syntax highlighting Clojure REPLs. This got me thinking that since I was going to tweak SLIME REPL font-lock for quite some time now (I find the default a bit too aggressive), I might as well do it now and have it use clojure-mode's

Re: Java method call irritation

2010-03-19 Thread Laurent PETIT
Hi, In this particular case, his get-properties macros was a demonstration of how to write a macro, but could have been replaced with an out-of-the-box clojure.core/bean call. 2010/3/19 Per Vognsen per.vogn...@gmail.com: My experience as a newcomer to Clojure is that one of the most surprising

Re: scoped local memoize

2010-03-19 Thread B Smith-Mannschott
On Fri, Mar 19, 2010 at 06:56, Greg Fodor gfo...@gmail.com wrote: I would like to memoize bar such that the memory used for memoization is GC'ed at the end of the call to foo, and additionally the cache used for memoization is thread local (so no need for heavyweight synchronization tools

Re: scoped local memoize

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 7:05 am, Greg Fodor gfo...@gmail.com wrote: Ah, I think I have the solution: (defn foo []   (let [bar-memoized (memoize bar)]     ; Do stuff with bar-memoized )) Seems to work -- to verify, this will GC the memoized cache for bar after each call to foo, right? Yes. I

Re: scoped local memoize

2010-03-19 Thread Greg Fodor
Ah, is there any concern with pummeling that var? On Mar 19, 2:22 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Mar 19, 7:05 am, Greg  Fodor gfo...@gmail.com wrote: Ah, I think I have the solution: (defn foo []   (let [bar-memoized (memoize bar)]     ; Do stuff with bar-memoized

Re: scoped local memoize

2010-03-19 Thread Per Vognsen
No, it won't force a GC. But it should be eligible for GC, if that's what you mean. Hopefully the memo cache will stay in the generation-zero nursery, in which case it will incur effectively no GC cost since the nursery collector runs in time O(live objects in nursey) rather than O(total objects

Re: Translation from Common Lisp 1

2010-03-19 Thread alux
David, thank you. Your answer seems to be nearest possible to the origninal spirit. Obviousely the way syntax-quote is resolved qualified with a namespace makes the easier way impossible. Regards, alux On 18 Mrz., 22:17, David Nolen dnolen.li...@gmail.com wrote: On Thu, Mar 18, 2010 at 4:25 PM,

Re: Translation from Common Lisp 1

2010-03-19 Thread alux
But using symbols for something like this is a bit contrived anyway. Yes, But sometimes it needs contrived examples to get the message. Especially if you have misleading preconceptions. And to me, symbols had always been a way to refer to stuff. And only that. That had to be shaken an is now.

Re: Translation from Common Lisp 1

2010-03-19 Thread Christophe Grand
If you really wan't to go that way you can also choose to remove the namespaces: (defn describe-path [[where what]] (map (comp symbol name) `(there is a ~what going ~where from here.))) On Fri, Mar 19, 2010 at 8:17 AM, alux alu...@googlemail.com wrote: But using symbols for something like

Re: Java method call irritation

2010-03-19 Thread Konrad Hinsen
On 18 Mar 2010, at 16:55, Per Vognsen wrote: Is there any reason why a .method occurrence in non-operator position doesn't just do the closure wrapping automagically? There is two reasons I can think of, though of course I can't know if they are the real ones. First, a technical reason:

Re: Java method call irritation

2010-03-19 Thread Per Vognsen
On Fri, Mar 19, 2010 at 2:46 PM, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 18 Mar 2010, at 16:55, Per Vognsen wrote: Is there any reason why a .method occurrence in non-operator position doesn't just do the closure wrapping automagically? There is two reasons I can think of, though

Re: Java method call irritation

2010-03-19 Thread LauJensen
Konrad, Im not following where this would be a problem in terms of optimization. In the definition for map, all that needs to be added is a check for a symbol? and the resulting sequence could look and act exactly like it would, had you manually added the #(.method %) right? If the technical

Re: Java method call irritation

2010-03-19 Thread Per Vognsen
I don't think passing symbols around and having special case behavior scattered around different functions is going to help beginners. If anything, it would confuse them when they try to treat .methods as first-class functions in their own code and discover that it doesn't work. -Per On Fri, Mar

Re: Clojure 101 - Slime installation

2010-03-19 Thread LauJensen
To avoid confusion Im pasting from another thread: Getting ready: http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-cloju... Doing simple pages: http://www.bestinclass.dk/index.php/2009/12/beating-the-arc-challenge... Including SQL:

Parser irritation

2010-03-19 Thread alux
Hello, is this a bug or a feature? (And how could I know.) spels= (macroexpand `(huhu huhu.)) (spels/huhu huhu.) If the symbol ends with a dot, it doesnt get resolved with name space. I suspect thats because it will get special interpretation as Java constructor. But what kind of magic is at

Re: Translation from Common Lisp 2

2010-03-19 Thread alux
Hello Michael, hello Dave, its actually been the parenthesis. Thank you. (Now I still have to understand it ;-) On 18 Mrz., 22:43, Michael Wood esiot...@gmail.com wrote: On 18 March 2010 23:40, Dave M damncan...@gmail.com wrote: ... (game-action weld chain bucket attic          (if

Re: Parser irritation

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 9:16 am, alux alu...@googlemail.com wrote: is this a bug or a feature? (And how could I know.) spels= (macroexpand `(huhu huhu.)) (spels/huhu huhu.) If the symbol ends with a dot, it doesnt get resolved with name space. I suspect thats because it will get special

Re: Parser irritation

2010-03-19 Thread alux
Ah. Interesting. (btw the exported in you second line certainly should be imported) So it interprets huhu. as full qualified class name and leaves it alone. Thank you for the explanation. Regards, alux On 19 Mrz., 09:38, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Mar 19, 9:16 am, alux

Re: Translation from Common Lisp 2

2010-03-19 Thread alux
By the way, you may find a working version at http://paste.lisp.org/+22IH/1 Kind regards, alux On 19 Mrz., 09:18, alux alu...@googlemail.com wrote: Hello Michael, hello Dave, its actually been the parenthesis. Thank you. (Now I still have to understand it ;-) On 18 Mrz., 22:43, Michael

Re: clj-sandbox

2010-03-19 Thread Rayne
I'm ecstatic about this. I've been writing a Clojure IRC bot over the last week or so, and this will really help me get sandboxed Clojure evaluation working. Thanks. On Mar 15, 5:22 am, Heinz Nikolaus Gies he...@licenser.net wrote: My brain is a sive, I forgot the github link

Re: Parser irritation

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 9:49 am, alux alu...@googlemail.com wrote: (btw the exported in you second line certainly should be imported) Woops. Yes. You are right. Should be imported. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

REPL behaviour / time / lazyness

2010-03-19 Thread alux
Hello, I played a bit with Fibonacci again. The slow and inefficient way ;-) (defn fib0 [n] (if ( n 1) 1 (+ (fib0 (- n 1)) (fib0 (- n 2) user= (time (fib0 35)) Elapsed time: 20874.18345 msecs 24157817 I use (set! *print-length* 10) and tried some mapping: user= (time (map fib0 (iterate

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 11:27 am, alux alu...@googlemail.com wrote: user= (time (fib0 35)) Elapsed time: 20874.18345 msecs 24157817 user= (time (map fib0 (iterate inc 1))) Elapsed time: 0.913524 msecs (2 3 5 8 13 21 34 55 89 144 ...) Everything fine. Now what puzzles me: user= (time (map fib0

getRuntime exec call?

2010-03-19 Thread TimDaly
(defn cmdresult [cmdstr] (let [args (into [] (seq (.split cmdstr )))] (BufferedReader. (InputStreamReader. (. (. (. Runtime (getRuntime)) (exec args)) (getInputStream)) (defn readLine [cmdresult] (. cmdresult (readLine))) (def a (cmdresult ls *.o)) This fails claiming: No

Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
It looks like there isn't a way to get at the class behind a deftyped type other than constructing a dummy instance and taking its class, because the generated class has a gensymmed name. I was doing something where I needed to test when something was an instance of a deftype, so I added this to

Re: getRuntime exec call?

2010-03-19 Thread alux
The call to a static method is special, try (.exec (Runtime/getRuntime) ls) Regards, alux TimDaly schrieb: (defn cmdresult [cmdstr] (let [args (into [] (seq (.split cmdstr )))] (BufferedReader. (InputStreamReader. (. (. (. Runtime (getRuntime)) (exec args))

Re: web starting clojure apps without Java code

2010-03-19 Thread Eugen Dück
That would be great! Please post the link here when you're done. On Mar 18, 5:15 pm, LauJensen lau.jen...@bestinclass.dk wrote: Eugen, Fantastic insight - I cant wait to work that into a blogpost :) Lau On 17 Mar., 15:56, Eugen Dück eu...@dueck.org wrote: All, Developing in clojure

Re: clojure-mode-like syntax highlighting for the SLIME REPL

2010-03-19 Thread Rick Moynihan
On 19 March 2010 06:08, Michał Marczyk michal.marc...@gmail.com wrote: Hi Group, there was a Stack Overflow question recently re: syntax highlighting Clojure REPLs. This got me thinking that since I was going to tweak SLIME REPL font-lock for quite some time now (I find the default a bit too

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 12:34 pm, alux alu...@googlemail.com wrote: You didnt try this, as I can judge, because you responded in finite time ;-) Ah, yes. Intersperse with (take 10 ...) at will. :) My main irritation is still: Why do my range and my iterate version differer in their print beheavior?

Re: REPL behaviour / time / lazyness

2010-03-19 Thread alux
;-) Still, I dont believe. I get the same difference with user= (time (map fib0 (range 100))) Elapsed time: 1.916445 msecs more than 5 seconds (0 1 1 2 3 5 8 13 21 34 ...) user= (time (map fib0 (iterate inc 0))) Elapsed time: 0.104203 msecs (0 1 1 2 3 5 8 13 21 34 ...) Hm. Regards, alux

Re: Instance predicates for deftyped types

2010-03-19 Thread Konrad Hinsen
On 19.03.2010, at 12:09, Per Vognsen wrote: It looks like there isn't a way to get at the class behind a deftyped type other than constructing a dummy instance and taking its class, because the generated class has a gensymmed name. I was doing something where I needed to test when something

Re: Instance predicates for deftyped types

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 12:09 pm, Per Vognsen per.vogn...@gmail.com wrote: It looks like there isn't a way to get at the class behind a deftyped type other than constructing a dummy instance and taking its class, because the generated class has a gensymmed name. I was doing something where I needed

Re: Simple functional programming lexicon?

2010-03-19 Thread Michael A Wright
You might want to check out: http://peepcode.com/products/functional-programming-with-clojure -- 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

Wrapping a java api...

2010-03-19 Thread Martin Hauner
Hi, I'm trying to wrap the apfloat (arbitrary precision float, http://www.apfloat.org/apfloat_java) java library for a small project. The idea is that the parameters of apfloat calculations get automatically converted to the Apfloat class. My test function is sqrtf (square root float) and the

overrding function from other namespace

2010-03-19 Thread Martin Hauner
Hi, I trying to use clojure.contrib.mock. It says to override the function report-problem to integrate it into other test framework like clojure.test. I've got this working, but the namespace switching looks a bit ugly. Is there a better way to handle this? Maybe something like (ns

Re: Quines

2010-03-19 Thread yubeshi
Ok, I golfed it. (def s[(def s%s)(printf(s 0)s)])(printf(s 0)s) -- 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 - please be patient with your

Re: Simple functional programming lexicon?

2010-03-19 Thread Michael Richter
Also the Learn you a Haskell for Great Good tutorial is a pretty nice and light-hearted introduction to FP with Haskell which might also help you to understand some of the concepts better: http://learnyouahaskell.com/ If you don't mind taking a detour into the Haskell world, the book Real

Re: Name suggestions

2010-03-19 Thread Frank Hale
clojure + native = clotive On Thu, Mar 18, 2010 at 10:36 AM, Alexandre Patry patry...@iro.umontreal.ca wrote: On Wed, Mar 17, 2010 at 3:08 AM, mac markus.gustavs...@gmail.com wrote: After just a little more test and polish I plan on calling clj-native 1.0. But clj-native is a *really*

Re: Clojure Koans?

2010-03-19 Thread Timothy McGuire
On a recent Java Ranch, Dick Wall mentioned that he was working with Clojure and F# people on functional language Koans that are like the Ruby Koans at http://github.com/relevance/functional-koans/ the branch for clojure is: at http://github.com/relevance/functional-koans/tree/clojure There are

Long post with some questions about getting started...

2010-03-19 Thread Nick
I want to learn Clojure and the first idea for a simple app that popped into my head was some sort of roguelike (because I'm a gamer and this is what I like to do...) I could go on making hello world apps and tiny test apps that serve little purpose, but the way I learn is by setting an end goal

ANN: clj-facebook, a Clojure client library for Facebook apps

2010-03-19 Thread Don Jackson
I'd like to announce the initial release of clj-facebook, a Facebook client library in Clojure. The code can be found here: http://github.com/rnewman/clj-facebook We welcome comments and proposed code improvements. Don -- You received this message because you are subscribed to the

Re: Translation from Common Lisp 2

2010-03-19 Thread JC Petkovich
You just needed to edit your translation from CL a bit more, there were some extra brackets in your if statements. The following should work: (defspel game-action [command subj obj place rest] `(defspel ~command [subject# object#] `(if (and (= *location* '~'~place) (=

zipentry-seq based on clojure.core/resultset-seq

2010-03-19 Thread MakotoSatoh
Hi, I want a function that takes byte array in zip format and returns sequence of included ZipEntrys. I wrote zipentry-seq based on clojure.core/resultset-seq as below. (entries) returns sequence of included ZipEntrys and many nils, so I added ad-hoc filter at the last. Please advice me to

ANN: clj-facebook, a Clojure client library for Facebook apps

2010-03-19 Thread Don Jackson
I'd like to announce the initial release of clj-facebook, a Facebook client library in Clojure. The code can be found here: http://github.com/rnewman/clj-facebook We welcome comments and proposed code improvements. Don -- You received this message because you are subscribed to the Google

How to use Clojure with Robocode

2010-03-19 Thread ubolonton
Hi, Has anyone been able to use Clojure with Robocode? I've followed this http://www.fatvat.co.uk/2009/05/clojure-and-robocode.html but got the error Round 1 initializing.. Let the games begin! java.lang.ExceptionInInitializerError at

Re: Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
Thanks, I had seen that ::Foo use and was a bit confused. Now it all makes sense. It would still be nice to have an auto-generated name?-style predicate in deftype, I think. -Per On Fri, Mar 19, 2010 at 7:44 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Mar 19, 12:09 pm, Per Vognsen

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Laurent PETIT
2010/3/19 alux alu...@googlemail.com: ;-) Still, I dont believe. I get the same difference with user= (time (map fib0 (range 100))) Elapsed time: 1.916445 msecs more than 5 seconds (0 1 1 2 3 5 8 13 21 34 ...) user= (time (map fib0 (iterate inc 0))) Elapsed time: 0.104203 msecs (0

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 1:39 pm, alux alu...@googlemail.com wrote: Still, I dont believe. You should... I get the same difference with user= (time (map fib0 (range 100))) Elapsed time: 1.916445 msecs more than 5 seconds (0 1 1 2 3 5 8 13 21 34 ...) user= (time (map fib0 (iterate inc 0)))

Re: Instance predicates for deftyped types

2010-03-19 Thread Konrad Hinsen
On 19.03.2010, at 13:50, Per Vognsen wrote: It would still be nice to have an auto-generated name?-style predicate in deftype, I think. I haven't yet made my mind up about this. I have used such auto-generated predicates in my unit library (http://code.google.com/p/clj-units/) for dimension

Re: Translation from Common Lisp 2

2010-03-19 Thread alux
JC Petkovich, thank you. I couldnt see your message before March 19, 6:00 group time, i.e. 13:00 UTC, but thats exactly the solution that was needed. Regards, alux JC Petkovich schrieb: You just needed to edit your translation from CL a bit more, there were some extra brackets in your if

Re: Java method call irritation

2010-03-19 Thread Laurent PETIT
Where would you place the type hint needed to avoid reflection ? 2010/3/19 LauJensen lau.jen...@bestinclass.dk: Konrad, Im not following where this would be a problem in terms of optimization. In the definition for map, all that needs to be added is a check for a symbol? and the resulting

Re: Instance predicates for deftyped types

2010-03-19 Thread Per Vognsen
It's pretty common in the Lisp world at large. For example, Common Lisp's (defstruct foo ...) automatically defines a foo-p predicate. -Per On Fri, Mar 19, 2010 at 7:53 PM, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 19.03.2010, at 13:50, Per Vognsen wrote: It would still be nice to

Re: REPL behaviour / time / lazyness

2010-03-19 Thread alux
Meikel, you are right, I changed horses, uh, definitions inbetween. So the REPL interaction of my last response should read Clojure 1.1.0 user= (set! *print-length* 10) 10 user= (defn fib0 [n] (if ( n 1) 1 (+ (fib0 (- n 1)) (fib0 (- n 2) #'user/fib0 user= (time (map fib0 (range 100)))

Re: Name suggestions

2010-03-19 Thread Alexandre Patry
Frank Hale wrote: clojure + native = clotive or clo-jive, like clojure dancing with another language. Alex -- 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

Re: Translation from Common Lisp 2

2010-03-19 Thread Conrad
Yeah, the Clojure namespacing does make translating symbol references in my game-action macro a bit cumbersome... But I think Clojure's straight-forward approach to namespacing is well worth this small inconvenience :-) On Mar 19, 8:54 am, alux alu...@googlemail.com wrote: JC Petkovich, thank

Re: How to use Clojure with Robocode

2010-03-19 Thread Jeff Foster
Could you post the source code? On Mar 19, 7:56 am, ubolonton ubolon...@gmail.com wrote: Hi, Has anyone been able to use Clojure with Robocode? I've followed thishttp://www.fatvat.co.uk/2009/05/clojure-and-robocode.html but got the error Round 1 initializing.. Let the games begin!

Re: Java method call irritation

2010-03-19 Thread Chouser
On Fri, Mar 19, 2010 at 4:04 AM, Per Vognsen per.vogn...@gmail.com wrote: On Fri, Mar 19, 2010 at 2:46 PM, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 18 Mar 2010, at 16:55, Per Vognsen wrote: Is there any reason why a .method occurrence in non-operator position doesn't just do the

Re: REPL behaviour / time / lazyness

2010-03-19 Thread alux
Laurent, Could chunked seqs explain something here ? sounds possible. If I only knew what this is ;-) Regards, alux Laurent PETIT schrieb: 2010/3/19 alux alu...@googlemail.com: ;-) Still, I dont believe. I get the same difference with user= (time (map fib0 (range 100)))

Re: Long post with some questions about getting started...

2010-03-19 Thread Sean Devlin
Nick, Welcome to Clojure! On Mar 18, 5:04 pm, Nick nschub...@gmail.com wrote: I want to learn Clojure and the first idea for a simple app that popped into my head was some sort of roguelike (because I'm a gamer and this is what I like to do...)  I could go on making hello world apps and tiny

Re: type hint puzzler

2010-03-19 Thread cageface
That was it. I was fixated on the ResultSet object and didn't consider overloading. Adding the (int) hint sped things up considerably. Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: scoped local memoize

2010-03-19 Thread Jason Wolfe
For recursive one-shot memoized functions, I've been using this: (defmacro memoized-fn [name args body] `(let [a# (atom {})] (fn ~name ~args (let [m# @a# args# ~args] (if-let [[_# v#] (find m# args#)] v# (let [v# (do ~...@body)]

Re: Name suggestions

2010-03-19 Thread David Andrews
ffinagle (Merriam-Webster says: to obtain by indirect or involved means, to obtain by trickery, to use devious or dishonest methods to achieve one's ends) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: scoped local memoize

2010-03-19 Thread Greg Fodor
Excellent -- thanks all. The binding approach works very well. On Mar 19, 11:40 am, Jason Wolfe jawo...@berkeley.edu wrote: For recursive one-shot memoized functions, I've been using this: (defmacro memoized-fn [name args body]   `(let [a# (atom {})]      (fn ~name ~args        (let [m#

Sequential vs. divide and conquer algorithm

2010-03-19 Thread Andrzej
I've been toying with various implementations of reduce-like functions, trying to do something smarter than a simple iteration over a collection of data. This hasn't worked out very well, my implementation is a lot (~50x) slower than a simple loop. Could anyone point out any bottlenecks in this

Re: getRuntime exec call?

2010-03-19 Thread Tim Daly
The call I coded works if you only pass a string with no spaces. However, if the string has spaces there is no result. If you break the string into String[] then clojure cannot match the appropriate exec(String[]) method in Runtime. I do not know how to convince clojure to call this method.

Re: clojure-mode-like syntax highlighting for the SLIME REPL

2010-03-19 Thread Phil Hagelberg
On Thu, Mar 18, 2010 at 11:08 PM, Michał Marczyk michal.marc...@gmail.com wrote: there was a Stack Overflow question recently re: syntax highlighting Clojure REPLs. This got me thinking that since I was going to tweak SLIME REPL font-lock for quite some time now (I find the default a bit too

Re: Sequential vs. divide and conquer algorithm

2010-03-19 Thread Sean Devlin
What type of improvement are you expecting to see? 1. A linear improvement based on throwing more cores at the problem? In this case you would need to use pmap to compute items in parallel. Your implementation appears to be single threaded. 2. An algorithmic improvement, like going from a DFT

map-filter, is this in the API?

2010-03-19 Thread Greg Fodor
Very simple function: (defn map-filter [f coll] (map f (filter f (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 maps of a certain key that is optional: Clojure= (map-filter :k [{:a :b :c :d :k :found} {:a :b :c

Re: Ensure

2010-03-19 Thread Jim Blomo
On Mon, Mar 15, 2010 at 3:34 PM, Raoul Duke rao...@gmail.com wrote: On Mon, Mar 15, 2010 at 1:13 AM, Christophe Grand christo...@cgrand.net wrote: It hasn't blocked in the sense of wait and continue: it retries the transaction after growing the history of the ref (refs have an adaptive

Re: getRuntime exec call?

2010-03-19 Thread alux
Sorry, I'm a bit in a hurry ;-) You give a vector, it needs an array. Try something like: spels= (make-array (.getClass ) 2 ) #String[] [Ljava.lang.String;@ad8659 spels= (def arr (make-array (.getClass ) 2 )) #'spels/arr spels= (aset arr 0 write) write spels= (aset arr 1 c:\\config.sys)

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 Sean Devlin
Nope. (map f (filter f ...)) is currently the way to go. On Mar 19, 1:54 pm, Greg Fodor gfo...@gmail.com wrote: Very simple function: (defn map-filter [f coll]   (map f (filter f (coll))) Is there an API function for this that I am missing? For example, it is useful for pulling out all

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: Sequential vs. divide and conquer algorithm

2010-03-19 Thread Andrzej
On Sat, Mar 20, 2010 at 2:15 AM, Sean Devlin francoisdev...@gmail.com wrote: What type of improvement are you expecting to see? 1.  A linear improvement based on throwing more cores at the problem? Yes. In this case you would need to use pmap to compute items in parallel. I haven't looked

Re: Long post with some questions about getting started...

2010-03-19 Thread Terje Norderhaug
On Mar 18, 2010, at 2:04 PM, Nick wrote: I'm having an interesting (to me) question around a using REPL. Once it's shut down, where does this code go? I feel like I'm in the old TRS-80 volatile coding days where you write some code, and if you shut down you've lost it all. Is this the case?

Re: getRuntime exec call?

2010-03-19 Thread Patrik Fredriksson
Also, have a look at http://richhickey.github.com/clojure-contrib/shell-api.html /Patrik On Mar 19, 7:00 pm, Michael Gardner gardne...@gmail.com wrote: On Mar 19, 2010, at 6:07 AM, TimDaly wrote: (defn cmdresult [cmdstr]  (let [args (into [] (seq (.split cmdstr )))]  (BufferedReader.  

Re: getRuntime exec call?

2010-03-19 Thread Meikel Brandmeyer
Hi, On Fri, Mar 19, 2010 at 11:00:34AM -0700, alux wrote: spels= (make-array (.getClass ) 2 ) #String[] [Ljava.lang.String;@ad8659 spels= (def arr (make-array (.getClass ) 2 )) #'spels/arr spels= (aset arr 0 write) write spels= (aset arr 1 c:\\config.sys) c:\\config.sys spels= (.exec

Re: getRuntime exec call?

2010-03-19 Thread alux
;-) I'm still at letter b in clojure.core. Grin. Regards, a. Meikel Brandmeyer schrieb: Hi, On Fri, Mar 19, 2010 at 11:00:34AM -0700, alux wrote: spels= (make-array (.getClass ) 2 ) #String[] [Ljava.lang.String;@ad8659 spels= (def arr (make-array (.getClass ) 2 )) #'spels/arr

Re: Java method call irritation

2010-03-19 Thread Stuart Sierra
On Mar 18, 11:55 am, Per Vognsen per.vogn...@gmail.com wrote: Is there any reason why a .method occurrence in non-operator position doesn't just do the closure wrapping automagically? It's been discussed as a possibility; it may be added to Clojure in the future. -SS -- You received this

Re: Name suggestions

2010-03-19 Thread Stuart Sierra
On Mar 17, 3:08 am, mac markus.gustavs...@gmail.com wrote: After just a little more test and polish I plan on calling clj-native 1.0. But clj-native is a *really* boring name so I want to change it before 1.0 and I don't have very good imagination when it comes to these things. Personally, I

clojure.walk

2010-03-19 Thread cej38
This post has two parts. Part 1. I know that the API is trying to hit the sweet spot on the brevity vs. information curve, but there are several areas where more information is needed; one of these is clojure.walk. Let's say that I have some nested set of vectors: (def nestV [ [0 [0] ] [0 0] ])

Re: Long post with some questions about getting started...

2010-03-19 Thread Mike Meyer
On Fri, 19 Mar 2010 07:21:50 -0700 (PDT) Sean Devlin francoisdev...@gmail.com wrote: I'm having an interesting (to me) question around a using REPL.  Once it's shut down, where does this code go?  I feel like I'm in the old TRS-80 volatile coding days where you write some code, and if you

Re: clojure.walk

2010-03-19 Thread Kevin Downey
I'm not overly familiar with clojure.walk, but I think you'll find the output of (prewalk #(doto % prn) [[3 [3]] [3 3]]) very illuminating. On Fri, Mar 19, 2010 at 2:13 PM, cej38 junkerme...@gmail.com wrote: This post has two parts. Part 1. I know that the API is trying to hit the sweet spot

Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Tim Johnson
FYI: I'm using slackware 13.0, 32-bit slack has much to redeem it, but there is no apt-get, synaptic and aptitude. Thus when I unzip clojure-1.1.0.zip, the closest I can find to installation instructions are at readme.txt. Looks like a very simple process, except that I am unfamiliar with `ant'.

Re: overrding function from other namespace

2010-03-19 Thread Kevin Downey
why are you def'ing your functions in the mock namespace? why are you juggling namespaces at all? On Wed, Mar 17, 2010 at 3:12 PM, Martin Hauner martin.hau...@gmx.net wrote: Hi, I trying to use clojure.contrib.mock. It says to override the function report-problem to integrate it into other

clojure naming convention for accessors vs. local variables

2010-03-19 Thread strattonbrazil
If am creating accessors to access structures, how should they be named? (defstruct employer :employee) (defstruct employee :employer) (def employee-name (accessor employee :employer)) (def employer-name (accessor employer :employee)) In a situation where one struct is pointing to the other, is

Re: clojure-mode-like syntax highlighting for the SLIME REPL

2010-03-19 Thread Michał Marczyk
On 19 March 2010 18:12, Phil Hagelberg p...@hagelb.org wrote: On Thu, Mar 18, 2010 at 11:08 PM, Michał Marczyk Awesome. Yeah, that sounds great. Could you submit an issue to clojure-mode to do this? http://github.com/technomancy/clojure-mode/issues A patch would be even better, of course.

Re: clojure-mode-like syntax highlighting for the SLIME REPL

2010-03-19 Thread Michał Marczyk
On 19 March 2010 12:58, Rick Moynihan rick.moyni...@gmail.com wrote: Very cute!  I'd love to see this integrated into clojure-mode! Glad you like it! As mentioned above, I'll try to polish it a bit further. Sincerely, Michał -- You received this message because you are subscribed to the

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Michał Marczyk
On 20 March 2010 00:32, Tim Johnson t...@johnsons-web.com wrote: So what am I looking for? Is it apache-ant, or some other system? And where do I download it? Yes, it's Apache Ant: http://ant.apache.org/ Note: slack has very good build tools for applications with C as the source, so if ant

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Tim Johnson
* Micha?? Marczyk michal.marc...@gmail.com [100319 15:56]: On 20 March 2010 00:32, Tim Johnson t...@johnsons-web.com wrote: So what am I looking for? Is it apache-ant, or some other system? And where do I download it? Yes, it's Apache Ant: http://ant.apache.org/ Thanks. I got it.

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Michał Marczyk
I would guess that you need the ant-launcher jar too: http://repo1.maven.org/maven2/ant/ant-launcher/1.6.5/ If you find there might be something else missing, check out the whole ant group: http://repo1.maven.org/maven2/ant/ HTH. Sincerely, Michał -- You received this message because you

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Tim Johnson
* Micha?? Marczyk michal.marc...@gmail.com [100319 16:46]: I would guess that you need the ant-launcher jar too: http://repo1.maven.org/maven2/ant/ant-launcher/1.6.5/ If you find there might be something else missing, check out the whole ant group: http://repo1.maven.org/maven2/ant/

Re: Long post with some questions about getting started...

2010-03-19 Thread Terje Norderhaug
On Mar 19, 2010, at 4:17 PM, Mike Meyer wrote: On Fri, 19 Mar 2010 07:21:50 -0700 (PDT) Sean Devlin francoisdev...@gmail.com wrote: I'm having an interesting (to me) question around a using REPL. Once it's shut down, where does this code go? I feel like I'm in the old TRS-80 volatile coding

Re: clojure naming convention for accessors vs. local variables

2010-03-19 Thread ataggart
As the doc for 'accessor notes, you should really eschew this stuff altogether, and be more idiomatic by just using the keyword. If you absolutely know that you need that (slightly) more efficient access, then naming the struct with an uppercase first letter works, and isn't too uncommon; besides

Re: clojure.walk

2010-03-19 Thread cej38
Kevin, thank you for your example. Ok here is what I get: (prewalk #(doto % prn) [[3 [3]] [3 3]]) [[3 [3]] [3 3]] [3 [3]] 3 [3] 3 [3 3] 3 3 [[3 [3]] [3 3]] Thus, it appears that an element of my nested vectors isn't just the values within the vectors, but also stands for the inner vectors as

Re: overrding function from other namespace

2010-03-19 Thread ataggart
I'd imagine you should be using with-bindings: user= (ns foo) nil foo= (defn bar [x] (inc x)) #'foo/bar foo= (ns user) nil user= (foo/bar 5) 6 user= (with-bindings {#'foo/bar #(dec %)} (foo/bar 5)) 4 On Mar 17, 3:12 pm, Martin Hauner martin.hau...@gmx.net wrote: Hi, I trying to use

Re: Simple functional programming lexicon?

2010-03-19 Thread Michał Marczyk
On 18 March 2010 20:56, Ben Armstrong synerg...@gmail.com wrote: On 18/03/10 06:57 AM, Michael Kohl wrote: There's a really nice article series on monads in Clojure: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/ Oh, wow!  Lucidly written.  And it gives me

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Michał Marczyk
Actually that Maven repo suggestion strikes me as misguided now, seeing how your purpose is to have a usable ant command and not access ant as a library... You'll probably be better of with the latest ant distribution from their webpage. The installation docs are here:

lazy-xml returns 503 from w3.org

2010-03-19 Thread Wilson MacGyver
Hi, In trying to use clojure.cotrib.lazy-xml to parse a xml file. I get java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd because w3c blocks access to that dtd now. Is there any work around? Thanks, -- Omnem crede

  1   2   >