Check my idioms?

2010-03-21 Thread Mark J. Reed
(I'd say something about my own particular idiom, but that's more of a Python thing.) Anyway, new to Clojure but not to Lisp or Java. Writing something to interoperate with some Perl code that stores a hash in a simple flat file syntax: key1value1key2value2... sorted on the keys. These are my

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Mark J. Reed
7;t have Java, click here and follow the instructions.") JRuby's installation is more manual, but includes examples. All three install on Ubuntu with apt-get, though the latest Clojure there is 1.0.  It does come with a "clojure" shell script for starting up a REPL, though. -

Re: Help optimizing array-to-integer operation?

2010-03-23 Thread Mark J. Reed
to me. In particular, (byte 0xFF) throws an error. What version? It works here: Clojure 1.1.0 user=> (byte 0xff) -1 In fact, it seems that (byte) doesn't check the range at all: user=> (byte -129) 127 -- Mark J. Reed -- You received this message because you are subscribed to the

Re: Can't call public method of non-public class

2010-03-24 Thread Mark J. Reed
problem here; Clojure is not even getting as far as compiling the code because its reflection code is too strict when matching methods to candidates. I submit the attached patch as a more general solution than Armando's, although whether it's worthwhile I'll leave up to Rich and co

Re: Can't call public method of non-public class

2010-03-24 Thread Mark J. Reed
Clojure could adapt/adopt that solution. On Tue, Mar 23, 2010 at 4:26 PM, Mark J. Reed wrote: > As far as I can tell, you're doing nothing wrong and just hitting a > bug in Clojure.  Which is still in 1.2.0-master... > > On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Bar

Re: Can't call public method of non-public class

2010-03-24 Thread Mark J. Reed
ogle > 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 > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups

Re: Help optimizing array-to-integer operation?

2010-03-24 Thread Mark J. Reed
x27;s not hard to write a fix: (defmacro unsigned-byte [bval] (byte (if (> bval 127) (- bval 256) bval))) Or call it (ubyte) for less wordiness... -- Mark J. Reed -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Can't call public method of non-public class

2010-03-25 Thread Mark J. Reed
Is this it? > http://www.assembla.com/spaces/clojure/tickets/259 > > On Mar 23, 8:26 pm, "Mark J. Reed" wrote: >> As far as I can tell, you're doing nothing wrong and just hitting a >> bug in Clojure.  Which is still in 1.2.0-master... >> >> >

Re: Nubie Question

2010-03-25 Thread Mark J. Reed
p! saved-colors conj :red) [:black :white :red] user=> start-colors [:black :white] user=> saved-colors # user=> @saved-colors [:black :white :red] user=> -- Mark J. Reed -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: Choosing a Clojure build tool

2010-03-25 Thread Mark J. Reed
ou don't have C dev tools installed. You can often get modules with prebuilt binaries, but the mechanism is platform-dependent. For instance, each module is its own apt package for Debian/Ubuntu, while ActivePerl on Windows uses its own Perl Package Manager (ppm.exe). -- Mark J. Reed --

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
e+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > To unsubscribe from this group, send email to > clojure+unsubscribegooglegroups.com or reply to this email with the words > "REMOVE ME" as the subject.

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
gt; your first post. >>> To unsubscribe from this group, send email to >>> clojure+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en >>> >>> To unsubscribe from this group, send email

Re: intuitive stack trace

2010-03-29 Thread Mark J. Reed
send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/cloj

Re: Getting started with open source Clojure projects

2010-03-30 Thread Mark J. Reed
" ]; then CLASSPATH="$CLASSPATH:$f" fi done fi rlwrap java clojure.main "$@" The actual java invocation can of course be replaced to e.g. use JLine instead of rlwrap; I use the latter because JLine doesn't seem to have a vi mode. (Yes, I kno

Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
> first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > To unsubscribe from this group, send email to > clojure+unsubscribegooglegroups.com or

Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
Addendum: I highly recommend Jeffrey Friedl's book _Mastering_Regular_Expressions_ if you want to learn how to use regexes well. There are also a number of introductions/tutorials online, but I'm not familiar enough with them to recommend any. On Tue, Mar 30, 2010 at 12:50 PM, Ma

Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
great!  i guess I can also just leave out the > parenthesis all together. > >  but, what if i wanted just the portion inside??  the duplicate I > wanted to get rid of? > > also any way to return the sequence without all those bars or do i > have to use a seperate regex and or fil

Re: formatting hex string

2010-03-31 Thread Mark J. Reed
(map #(let [n (Integer/parseInt % 16)] (short (if (bit-test n 15) (bit-or n -65536) (bit-and n 65535 ["ff43" "0032"]) although of course factoring some of that out into named functions is probably not the worst idea. On a related note: if I have the symbol for a type, like

Re: formatting hex string

2010-03-31 Thread Mark J. Reed
ure 1.2, (short n) blows up on n < -32768 or n > 32767. I would like a way to programmatically determine those values based on the identity of the function I'm about to call. Again, I can obviously make a lookup table; just thought there might be something introspectable. -- Mar

Re: formatting hex string

2010-03-31 Thread Mark J. Reed
ze) positive-mask (- (bit-shift-left 1 size) 1)] (type (if (bit-test value sign-bit) (bit-or value negative-mask) (bit-and value positive-mask) -- Mark J. Reed -- You received this message because you are subscribed to the Google

Re: "," is REAL whitespace...

2010-04-02 Thread Mark J. Reed
this group at > > http://groups.google.com/group/clojure?hl=en > > -- > 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

Re: removing parethesis

2010-04-12 Thread Mark J. Reed
tand that result.. but what the OP asked for is for a function foo such that (foo '((1 2 3) (4 5 6))) returns (5 7 9) - a list of the sums in order. (apply map +) does that. Except what the OP really wants the average instead of the sum.. there's probably an arithmetic mean function in c

Re: removing parethesis

2010-04-13 Thread Mark J. Reed
On Tuesday, April 13, 2010, Mark J. Reed wrote: > (defn mean [& rest] (/ (apply + reset) (count rest))) that "reset" should be "rest". > And then use the same trick with it in place of +: > (apply map mean '((1 2 4) (2 4 6) (1 3 5))) > which yiel

Re: Try + finally question

2010-04-21 Thread Mark J. Reed
ion of the [bindings] would be caught just as if it happened inside the body, and of course the bound variables would be visible to both the catch blocks and the finally block. It could be implemented as a macro that duplicated the catch/finally blocks within and outside a let... -- Mark J. R

Re: Try + finally question

2010-04-21 Thread Mark J. Reed
xceptionAfterConnect x (do-something-with conn)) (finally (API/closeConnection conn)))) (catch .ExceptionDuringConnect x (do-something-without-conn -- Mark J. Reed -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Try + finally question

2010-04-21 Thread Mark J. Reed
> > I'm not sure I phrased that clearly, please let me know if I'm not > > making sense. :-) > > > > Alex > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To

Re: Insert into an indexed seq

2010-04-27 Thread Mark J. Reed
our first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group athttp:// > groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Goog

Re: Insert into an indexed seq

2010-04-27 Thread Mark J. Reed
On Tue, Apr 27, 2010 at 3:41 PM, Mark J. Reed wrote: > I'm a bit surprised that it's not there already, at least in > clojure.contrib, but it's not hard to write, at least for vectors: > > (defn insert [vec pos item] > (apply merge (subvec vec 0 pos) item

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Mark J. Reed
h your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Mark J. Reed -- You received this message because you are subscribed to the Google Gr

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Mark J. Reed
Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Mark J. Ree

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
bers are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Mark J. Reed -- You received this message because

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
glegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
On Fri, Apr 30, 2010 at 12:25 PM, Mark J. Reed wrote: > I got an error when I tried ([a b]) instead of (list [a b]), by the way: > > Clojure 1.1.0 > user=> (cons [1 2] ([3 4])) > java.lang.IllegalArgumentException: Wrong number of args passed to: > PersistentVector (NO_SO

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
Of course. Which is what I would have done automatically with a Lispier construct. Just still not used to seeing literal vectors as functions. :) On Friday, April 30, 2010, Michael Wood wrote: > On 30 April 2010 18:25, Mark J. Reed wrote: > [...] >> (defn pairup >>   

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
Ok, so I was right the first time. It think it's past everyone's bedtime. :) On Fri, Apr 30, 2010 at 5:49 PM, Douglas Philips wrote: > On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote: > >> Of course. Which is what I would have done automatically with a >> Lispier co

Re: something stupid I'm trying to do

2010-04-30 Thread Mark J. Reed
p; args] > (map vector args (rest args))) > Nope, that doubles the middle elements: user=> (pairup 1 2 3 4) ([1 2] [2 3] [3 4]) -- Mark J. Reed -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: code review:replace-first

2010-05-08 Thread Mark J. Reed
mail to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/g