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 wrote: > On Thu, Mar 18, 2010 at 4:25 PM, alux wrote: > > Hell

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 wrote: > > >> But using symbols for something like this is a bit cont

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: .m

Re: Java method call irritation

2010-03-19 Thread Per Vognsen
On Fri, Mar 19, 2010 at 2:46 PM, Konrad Hinsen 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 of course I can't k

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 obst

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: http://www.bestinclass.dk/index.php/2009/12/dyna

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 wo

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 wrote: > On 18 March 2010 23:40, Dave M wrote: > > > ... > > >> (game-action weld chain bucket attic > >>          (if ((and (have 'bucket) (alter-var

Re: Parser irritation

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 9:16 am, alux 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 interpretation as Java >

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 wrote: > Hi, > > On Mar 19, 9:16 am, alux wrote:

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 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 Wood wrote: > >

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 wrote: > My brain is a sive, I forgot the github link > o.Ohttp://github.com/Licenser/clj-

Re: Parser irritation

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 9:49 am, alux 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 this group,

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 (iterat

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 11:27 am, alux 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 (r

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 th

Re: REPL behaviour / time / lazyness

2010-03-19 Thread alux
You didnt try this, as I can judge, because you responded in finite time ;-) (fib0 35) takes 20 seconds already. So your suggestion (time (doall (map fib0 (range 100))) will do all up to 100, time it, and print the first ten, in that order. (fib0 100) takes a good while (I just estimaded 15 mill

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)) > (getInp

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 wrote: > Eugen, > > Fantastic insight - I cant wait to work that into a blogpost :) > > Lau > > On 17 Mar., 15:56, Eugen Dück wrote: > > > All, > > > Developing in clojure is a lot of fun, at least it

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

2010-03-19 Thread Rick Moynihan
On 19 March 2010 06:08, Michał Marczyk 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 aggressive), I mig

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 12:34 pm, alux 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? Because with ran

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, al

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 somethin

Re: Instance predicates for deftyped types

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 12:09 pm, 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 someth

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 moder

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 au

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 clojure.contr

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 you

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 bo

Re: Name suggestions

2010-03-19 Thread Frank Hale
clojure + native = clotive On Thu, Mar 18, 2010 at 10:36 AM, Alexandre Patry wrote: > >>> On Wed, Mar 17, 2010 at 3:08 AM, mac 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

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 9

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 G

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) (= '~sub

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 make

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 Grou

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 sun.reflect.NativeConstructorAccessorImpl.newInstance0

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 wrote: > Hi, > > On Mar 19, 12:09 pm, Per Vognsen wrote: > >> It

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Laurent PETIT
2010/3/19 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

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Meikel Brandmeyer
Hi, On Mar 19, 1:39 pm, alux 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))) > "Elaps

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 sta

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 : > 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 a

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 wrote: > On 19.03.2010, at 13:50, Per Vognsen wrote: > >> It would still be nice to have an auto-generated na

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))) "El

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 mem

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 wrote: > JC Petkovich, thank you. I couldnt see your

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 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! > java.lang.Excepti

Re: Java method call irritation

2010-03-19 Thread Chouser
On Fri, Mar 19, 2010 at 4:04 AM, Per Vognsen wrote: > On Fri, Mar 19, 2010 at 2:46 PM, Konrad Hinsen > 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? >> >>

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 : > > ;-) > > > > Still, I dont believe. > > > > I get the same difference with > > > > user=> (time (map fib0 (range 100))) > > "Elapsed

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Laurent PETIT
Yes, chunked sequences explain the behaviour, look: 1:1 user=> (set! *print-length* 10) 10 1:2 user=> (defn fib0 [n] (let [fib (fn fib [n] (if (< n 1) 1 (+ (fib (- n 1)) (fib (- n 2)] (println (str "fib0[" n "]")) (fib n))) #'user/fib0 1:7 user=> (time (map fib0 (iterate inc 0))) "

Re: REPL behaviour / time / lazyness

2010-03-19 Thread Laurent PETIT
hi, follow links from here: http://www.infoq.com/news/2009/12/clojure-11-rc1-transients chunked sequences have their first elements realized in advanced by packets of 32 Under the hoods, it seems that range uses chunked sequences ( http://github.com/richhickey/clojure/blob/master/src/clj/clojure/

Re: REPL behaviour / time / lazyness

2010-03-19 Thread alux
Ah, brilliant, many thanks Laurent! Interesteresting stuff under the hood .. Kind regards, alux Laurent PETIT schrieb: > hi, follow links from here: > http://www.infoq.com/news/2009/12/clojure-11-rc1-transients > > chunked sequences have their first elements realized in advanced by > packets of

Re: Name suggestions

2010-03-19 Thread caljunior
brain dump coming up: inclojenous c-jure cclojure full-circle c-no-free brace-yourself chickey (my favourite) On 19 mrt, 14:17, Alexandre Patry wrote: > Frank Hale wrote: > > clojure + native = clotive > > or clo-jive, like clojure dancing with another language. > > Alex -- You received

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 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 test apps that

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 clojure@googlegroups.c

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 clojure@go

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 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# @a# >          

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 a

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. alux

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 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 aggressive), I might a

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 to

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 wrote: > On Mon, Mar 15, 2010 at 1:13 AM, Christophe Grand > 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 >> history): > > i'm confused about

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 ) # 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 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 wha

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 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 values in a

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 o

Re: Sequential vs. "divide and conquer" algorithm

2010-03-19 Thread Andrzej
On Sat, Mar 20, 2010 at 2:15 AM, Sean Devlin 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 at pmap yet. Thanks fo

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? S

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 wrote: > On Mar 19, 2010, at 6:07 AM, TimDaly wrote: > > > (defn cmdresult [cmdstr] > >  (let [args (into [] (seq (.split cmdstr " ")))] > >  (BufferedReader. > >    (Inpu

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 ) > # > 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 (Runtime/get

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 ) > > # > > spels=> (def arr (make-array (.getClass "") 2 )) > > #'spels/arr > > spels=> (aset arr 0 "

Re: Java method call irritation

2010-03-19 Thread Stuart Sierra
On Mar 18, 11: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? It's been discussed as a possibility; it may be added to Clojure in the future. -SS -- You received this message because you are

Re: Name suggestions

2010-03-19 Thread Stuart Sierra
On Mar 17, 3:08 am, mac 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 much prefer library name

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 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

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 wrote: > This post has two parts. > > Part 1. > > I know that the API is trying to hit the sweet spot on the brevity v

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'. Lo

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 wrote: > Hi, > > I trying to use clojure.contrib.mock. It says to override the function > report-problem to > integrate it into other test framework lik

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 t

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

2010-03-19 Thread Michał Marczyk
On 19 March 2010 18:12, Phil Hagelberg 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. Sure thin

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

2010-03-19 Thread Michał Marczyk
On 19 March 2010 12:58, Rick Moynihan 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 Google Groups "Clojure" grou

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Michał Marczyk
On 20 March 2010 00:32, Tim Johnson 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 is written in C,

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Tim Johnson
* Micha?? Marczyk [100319 15:56]: > On 20 March 2010 00:32, Tim Johnson 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. Installed it as per instructions a

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 are

Re: Installation issues on slack 13.0 (ant?)

2010-03-19 Thread Tim Johnson
* Micha?? Marczyk [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/ I'm looking at that

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 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 som

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; beside

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 we

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 wrote: > Hi, > > I trying to use clojure.contrib.mock. I

Re: Simple functional programming lexicon?

2010-03-19 Thread Michał Marczyk
On 18 March 2010 20:56, Ben Armstrong 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 something, maybe-

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: http://ant.apache.org/manua

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 die

Re: Simple functional programming lexicon?

2010-03-19 Thread Per Vognsen
They provide elegant solutions to a great many problems, some quite simple. Here's how I would compute subobjects (subseqs, subsets), partitions and permutations monadically: (def true-or-false (constantly (either true false))) ;; computes subseqs in the seq monad and subsets in the set monad (de

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

2010-03-19 Thread Mike Meyer
On Fri, 19 Mar 2010 18:26:24 -0700 Terje Norderhaug wrote: > > > > *) InterLISP and some others were more like SmallTalk, or MS BASIC, in > >that you edited code at the REPL and saved the entire > >workspace. That did add power - I've never seen a file-based LISP > >whose error handler

  1   2   >