Re: Am I holding on to the head here ?

2009-02-08 Thread Kevin Downey
I am not sure exactly how preduce differs from normal reduce, but reduce is not a lazy operation, so it will result in the realization of a lazy seq passed to it. On Sun, Feb 8, 2009 at 2:13 PM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: I have this piece of code: (defn-

Re: anonymous functions

2009-02-10 Thread Kevin Downey
fn has an implicit (do ...) #(do ...) behaves the same way. #(a b c) expands to (fn [] (a b c)) if you put in multiple forms you get #((a b)(c d)) expands to (fn [] ((a b) (c d))) note the (a b) in the operator position. On Tue, Feb 10, 2009 at 8:09 PM, Mark Volkmann r.mark.volkm...@gmail.com

Re: alternate syntax

2009-02-23 Thread Kevin Downey
You might be interested in my pet macro: pl http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj#L94 it does transformations on code using zippers. for example: (pl inc $ inc $ 0) expands to (inc (inc 2)) pl is just a toy but it might be worth

Re: Flatten a list

2009-02-24 Thread Kevin Downey
filter, http://clojure.org/api#filter On Tue, Feb 24, 2009 at 7:38 PM, Sean francoisdev...@gmail.com wrote: I've got the following list (:a nil nil :b :a) I want to call a nil-killer function, and get the following list (:a :b :a) How do I go about this?  Could someone post a quick

Re: Extensive use of let?

2009-02-25 Thread Kevin Downey
You should look at - it lest you take (op3 (op2 (op1 input))) and write it as (- input op1 op2 op3) there is also comp which composes functions, and partial for partial application. some example comp usage:

Re: transposing a small java class in clojure

2009-03-10 Thread Kevin Downey
I don't know how many arguments the method you are overriding with onLogin takes, but the function you define should take one more argument then the method you are overiding, the first argument being an explicit reference to an instance On Tue, Mar 10, 2009 at 12:16 PM, rb raphi...@gmail.com

Re: Request: Can clojure.contrib.walk provide a reduce type operation?

2009-03-11 Thread Kevin Downey
if your walk pushes the items into a Queue, you can just reduce across the Queue On Wed, Mar 11, 2009 at 9:24 AM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: Currently the clojure.contrib.walk code provides a nice way to perform a depth first map operation on trees.  However, I need

Re: Slash mystery

2009-03-18 Thread Kevin Downey
this came up on irc starting: http://clojure-log.n01se.net/date/2009-02-18.html#23:49 and the solution: http://clojure-log.n01se.net/date/2009-02-19.html#0:30 On Wed, Mar 18, 2009 at 11:03 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: Consider the following session: user= /

Re: Slash mystery

2009-03-18 Thread Kevin Downey
Symbols starting and ending with . are reserved. see http://clojure.org/reader the section on Symbols On Wed, Mar 18, 2009 at 12:58 PM, Michael Wood esiot...@gmail.com wrote: On Wed, Mar 18, 2009 at 8:22 PM, Kevin Downey redc...@gmail.com wrote: this came up on irc starting: http://clojure

Re: Help with the dot operator special form

2009-03-21 Thread Kevin Downey
you want defmacro not definline. the result of a macro is a data structure. that data structure is then evaluated in place of the call to the macro. definline (I think?) behaves similar to a function, so if it returns a data structure, you just get that data structure (the data structure is not

Re: Mapping a function over a map's values

2009-03-22 Thread Kevin Downey
(defn mapmap [fn m] (into {} (map #(vector (first %) (fn (second %))) m))) On Sun, Mar 22, 2009 at 1:10 PM, Jon Nadal jon.na...@gmail.com wrote: I often need to map a function over the values of a map while preserving keys--something like: [code] (defn mapmap [fn m]  (let [k (keys m)

Re: introspect namespace ?

2009-04-05 Thread Kevin Downey
(.toString *ns*) On Sun, Apr 5, 2009 at 12:39 PM, Stephen C. Gilardi squee...@mac.com wrote: On Apr 5, 2009, at 3:23 PM, dysinger wrote: I need coffee - too many typos.  I meant to say I am trying to avoid _typing_ 'x.y.z' twice (str (the-ns 'user)) is is even more human-error prone than

Re: Question about metadata on map keys

2009-04-10 Thread Kevin Downey
I think you misunderstand, I don't think he is expecting to being able to use :foo as a key twice with different metadata. I think he wants something like: (def x {[:a] 1 [:b] 2}) then (meta (first (keys (assoc x (with-meta [:a] {:x 1}) 2 ;(- (assoc x (with-meta [:a] {:x 1})) keys first

Re: java.lang.String cannot be cast to [Ljava.lang.CharSequence;

2009-04-16 Thread Kevin Downey
I would be interested in seeing a full stack trace and some pastbined code. there are no clojure strings, just java strings, and java strings are charsequences. On Thu, Apr 16, 2009 at 11:25 AM, prhlava prhl...@googlemail.com wrote: Hello, I am trying to use a java library (

Re: IFn?

2009-04-18 Thread Kevin Downey
ifn? returns true for things that implement clojure.lang.IFn, IFn is the interface for things that can be put in the operator position in a s-expr: functions vectors maps sets keywords symbols ...? fn? returns true for just functions On Sat, Apr 18, 2009 at 9:37 PM, tmountain

Re: areduce flaw

2009-04-27 Thread Kevin Downey
no, the syntax is not the same. user= (macroexpand-1 '(.foo bar)) (. bar foo) On Mon, Apr 27, 2009 at 2:51 PM, Boris Mizhen bo...@boriska.com wrote: Hi Meikel, thanks for the answer. I wonder if someone could explain or point me to the explanation about *why* a Java static fn can't be

Re: constructing maps

2009-05-05 Thread Kevin Downey
(into {} (apply map vector '((cars bmw chevrolet ford peugeot) (genres adventure horror mystery {ford mystery, chevrolet horror, bmw adventure, cars genres} On Mon, May 4, 2009 at 4:03 PM, Michel S. michel.syl...@gmail.com wrote: On May 4, 5:07 pm,

Re: Can for be enhanced to not have to take a binding?

2009-05-07 Thread Kevin Downey
user= (doc take-while) - clojure.core/take-while ([pred coll]) Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects. nil user= On Thu, May 7, 2009 at 2:11 PM, CuppoJava patrickli_2...@hotmail.com

Re: Help with Type Hint

2009-05-14 Thread Kevin Downey
so I took a look at with this code: http://gist.github.com/111935 output: :original Elapsed time: 369.683 msecs :redux-1 Elapsed time: 11672.329 msecs :redux-2 Elapsed time: 74.233 msecs as to why there is such a huge difference between your code and redux-2 I am not sure. I would definitely

Re: The thread ring problem

2009-05-29 Thread Kevin Downey
http://gist.github.com/120289 using queues and Threads instead of agents On Fri, May 29, 2009 at 4:11 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Hi, here is a second attempt, partly inspired by clojure's agents page, that looks better (true direct ring of agents, not just indirect

Re: Using (into {} ...) on a sequence of lists vs. vectors

2009-06-01 Thread Kevin Downey
two element vectors implement MapEntry, (into {} x) x needs to be something that seq can be called on and will return a seq of MapEntrys On Mon, Jun 1, 2009 at 10:39 AM, samppi rbysam...@gmail.com wrote: Why does using a list with into and a map throw an exception, while using a vector is

Re: New and stuck ??

2009-06-07 Thread Kevin Downey
the new entry point is clojure.main java -cp clojure.jar clojure.main ;no slash, with the corrent jar name java -cp clojure.jar clojure.main --help will print a nice help message On Sun, Jun 7, 2009 at 8:20 AM, darrelldgalli...@gmail.com wrote: OK, embarrassing Thanks, I was caught

Re: The - . nested usage

2009-06-08 Thread Kevin Downey
= (macroexpand `(String. (String.))) (new java.lang.String (java.lang.String.)) Nesting is a must :) Thank you both for your helpful reply On Jun 8, 10:51 pm, Kevin Downey redc...@gmail.com wrote: you need to pass something in. example: = (- foo String. String.) foo = (macroexpand

Re: Thoughts on bags?

2009-06-09 Thread Kevin Downey
On Tue, Jun 9, 2009 at 7:49 PM, Richard Newmanholyg...@gmail.com wrote: Thanks, Konrad and Andrew, for chipping in! There's an outline of an implementation of multisets (I think that's the same as your bags) at:        http://code.google.com/p/clojure-contrib/source/browse/trunk/src/

Re: EDT interaction

2009-06-13 Thread Kevin Downey
On Sat, Jun 13, 2009 at 2:02 PM, Wrexsould2387...@bsnow.net wrote: Now I'm working on some Swing code and came up with these, which are obviously going to be useful: (defmacro do-on-edt [ body]  `(SwingUtilities/invokeLater #(do ~...@body))) (defmacro get-on-edt [ body]  `(let [ret#

Re: EDT interaction

2009-06-13 Thread Kevin Downey
On Sat, Jun 13, 2009 at 2:55 PM, Meikel Brandmeyerm...@kotka.de wrote: Hi, Am 13.06.2009 um 23:29 schrieb Meikel Brandmeyer: (defmacro get-on-edt  [ body]  `(get-on-edt* (fn [] ~body))) Of course ~...@body instead of ~body... Sincerely Meikel I know you (Meikel) already fixed it,

Re: EDT interaction

2009-06-13 Thread Kevin Downey
it depends how often you are pushing stuff onto the EDT. I have a similar macro called EDT so I can do stuff like (EDT (.setText foo bar)) alternatively I would need to type (SwingUtilities/invokeLater #(.setText foo bar)) or even (SwingUtilities/invokeLater (fn [] (.setText foo bar))) On Sat,

Re: Primitive char Type

2009-06-13 Thread Kevin Downey
user= (def s (StringBuilder. aaa)) #'user/s user= (. s setCharAt 0 \b) nil user= s #StringBuilder baa user= (. s setCharAt (int 0) (char \b)) nil user= (. s setCharAt (int 0) (char \e)) nil user= s #StringBuilder eaa user= works for me On Sat, Jun 13, 2009 at 7:28 PM,

Re: Rebinding functions?

2009-06-16 Thread Kevin Downey
you can use apply to avoid in-lining: user= (binding [+ -] (apply + '(5 3))) 2 On Tue, Jun 16, 2009 at 11:16 AM, Michel S.michel.syl...@gmail.com wrote: On Jun 16, 1:42 pm, Paul Stadig p...@stadig.name wrote: On Tue, Jun 16, 2009 at 1:38 PM, Michel Salim michel.syl...@gmail.comwrote:

with-open binding form

2008-10-13 Thread Kevin Downey
I noticed with-open kind of stuck out because it doesn't use vectors for binding like let, loop, and others. it was a quick fix using destructuring to make the macro use square backets example: (with-open [f (new java.io.FileWriter test)] do-stuff) but as I was writing an email to this list I

is clojure known to work on any phones with javame?

2008-10-14 Thread Kevin Downey
I am in the market for a phone and it would be so cool to have clojure on it. Has anyone tried this yet? -- The Mafia way is that we pursue larger goals under the guise of personal relationships. Fisheye --~--~-~--~~~---~--~~ You received this message

Re: Getting a flat sequence from a map (and vice versa)

2008-11-14 Thread Kevin Downey
On Fri, Nov 14, 2008 at 8:17 PM, samppi [EMAIL PROTECTED] wrote: Yeah, I need to be able to do this to easily manage trees of maps. I meant, how would you idiomatically implement their algorithms? Fold isn't build into Clojure, but they should still somehow be possible...right? On Nov 14,

Re: Getting a flat sequence from a map (and vice versa)

2008-11-14 Thread Kevin Downey
On Fri, Nov 14, 2008 at 8:33 PM, Kevin Downey [EMAIL PROTECTED] wrote: On Fri, Nov 14, 2008 at 8:17 PM, samppi [EMAIL PROTECTED] wrote: Yeah, I need to be able to do this to easily manage trees of maps. I meant, how would you idiomatically implement their algorithms? Fold isn't build

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Kevin Downey
user= (reduce concat {:a 1 :b 2 :c 3}) (:c 3 :b 2 :a 1) user= On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard [EMAIL PROTECTED] wrote: On 15 Nov., 05:17, samppi [EMAIL PROTECTED] wrote: Fold isn't build into Clojure Isn't fold just clojure/reduce? Matthias -- The Mafia way is

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Kevin Downey
user= (mapcat identity {:a 1 :b 2 :c 3}) (:c 3 :b 2 :a 1) On Sat, Nov 15, 2008 at 4:05 AM, Kevin Downey [EMAIL PROTECTED] wrote: user= (reduce concat {:a 1 :b 2 :c 3}) (:c 3 :b 2 :a 1) user= On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard [EMAIL PROTECTED] wrote: On 15 Nov., 05:17

Re: strings

2008-11-18 Thread Kevin Downey
(apply str (reverse I am cold)) shorter and it does the same thing. no need to take out the spaces and put them back in On Tue, Nov 18, 2008 at 5:21 PM, Mark Volkmann [EMAIL PROTECTED] wrote: Here's another solution that came from help on the chat. Thanks Chouser! (apply str (interpose

Re: seq and vector

2008-11-23 Thread Kevin Downey
I don't think you understand. clojure data structures are IMMUTABLE. every call to conj, or anyother function returns a new object. To optimize there is sharing of structure. On Sun, Nov 23, 2008 at 4:38 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Nov 23, 1:23 am, Rich Hickey [EMAIL

Re: update a ref struct

2008-11-24 Thread Kevin Downey
I know you are asking about refs, but you might want to think about using reduce to walk the line-seq. the nature of reduce lets you have access to the line-seq, two lines at a time no need for a ref. On Mon, Nov 24, 2008 at 2:17 PM, Brian Doyle [EMAIL PROTECTED] wrote: I am parsing a file and

Re: update a ref struct

2008-11-24 Thread Kevin Downey
to know what I'm doing wrong with updating the ref for future reference. Thanks. On Mon, Nov 24, 2008 at 3:23 PM, Kevin Downey [EMAIL PROTECTED] wrote: I know you are asking about refs, but you might want to think about using reduce to walk the line-seq. the nature of reduce lets you have

Re: update a ref struct

2008-11-24 Thread Kevin Downey
On Mon, Nov 24, 2008 at 2:34 PM, Kevin Downey [EMAIL PROTECTED] wrote: ref-set needs its one set of parens, and the last thing in the ref-set call needs to be a function either (fn [x] ...) or a symbol for a var that holds a function I made a mistake here. I was thinking of alter, not ref-set

Re: loop recur vs recursion

2008-11-29 Thread Kevin Downey
the jvm does not do TCO, loop/recur allows for functional looking recursion on the jvm with constant stack size. On Sat, Nov 29, 2008 at 1:25 AM, bOR_ [EMAIL PROTECTED] wrote: Hi all, I wondered if there is a difference between using loop-recur or merely writing a recursive function. The

Re: Possible minor bug in gen-class: method name character escaping?

2009-01-16 Thread Kevin Downey
On Fri, Jan 16, 2009 at 12:22 PM, Greg Harman ghar...@gmail.com wrote: 2. If I want the Clojure functions that underlie the methods in the generated class used directly by my Clojure code as well (which I do), then I'm stuck having to either violate standard Clojure/Lisp function naming

Re: Printing Strings in Lists

2009-01-23 Thread Kevin Downey
prn On Fri, Jan 23, 2009 at 11:00 AM, Kevin Albrecht onlya...@gmail.com wrote: Below are two operations that print (1 2 3 4). How can I do something similar to print (1 2 3 4) to standard out? (println '(1 2 3 4)) - (1 2 3 4) (def x 1 2 3) (println `(~x 4)) - (1 2 3 4) --Kevin

Re: Binding values in a list of symbols and evaluating as code

2009-01-23 Thread Kevin Downey
instead of using binding and eval, you can generate a (fn ) form, eval it, keep the result function stuffed away somewhere and apply it instead of calling eval all the time On Fri, Jan 23, 2009 at 1:10 PM, Zak Wilson zak.wil...@gmail.com wrote: It does seem like a legitimate use for eval, at

Re: Length of Sequence

2009-01-28 Thread Kevin Downey
(doc count) - clojure.core/count ([coll]) Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps nil On Wed, Jan 28, 2009 at 11:15 AM, Peter Wolf opus...@gmail.com wrote: Here's a dumb

Re: Alternatives to contains?

2009-01-29 Thread Kevin Downey
actually rhickey showed up on irc and pointed something out: 15:23 rhickey : user= (.contains [1 2 3] 2) 15:23 rhickey : true 15:23 rhickey : user= (.contains '(1 2 3) 2) 15:23 rhickey : true 15:23 rhickey : what contains debate? :) so because seqs, vectors, etc are java

Re: Distributed Clojure

2009-01-29 Thread Kevin Downey
have you looked at the available java frameworks like hadoop? there is also some kind of java interface to erlang instead of reinventing the wheel again... On Thu, Jan 29, 2009 at 6:15 AM, Greg Harman ghar...@gmail.com wrote: One of Clojure's big selling points (obviously) is the support for

Re: purpose of clojure-slim.jar

2009-01-29 Thread Kevin Downey
clojure-slim.jar lacks compiled clojure code. The java code is compiled, so clojure-slim.jar is still completely usable as clojure, it just have to compile things like core.clj when it loads them. On Thu, Jan 29, 2009 at 4:56 PM, kkw kevin.k@gmail.com wrote: Hi folks, I noticed that

Re: What is defn-

2009-02-03 Thread Kevin Downey
as a namespace is to a java package, defn- is to private, and defn is to public On Tue, Feb 3, 2009 at 8:19 PM, Terrence Brannon metap...@gmail.com wrote: What is the significance of the dash after defn? How does it differ from defn? Source:

Re: Tools for parsing arguments

2009-02-06 Thread Kevin Downey
you can also use map destructuring. (defn x [{:keys [a b c]}] [a b c]) user= (x {:a 1 :b 2 :c 3}) [1 2 3] On Fri, Feb 6, 2009 at 7:52 AM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: That is remarkably simple and elegant. On Fri, Feb 6, 2009 at 10:20 AM, Stuart Sierra

Re: core.logic merge substitutions map?

2013-11-18 Thread Kevin Downey
https://github.com/sonian/Greenmail/blob/master/src/clj/greenmail/db.clj#L98-L126 has an example, using clojure.core.logic/all to make a goal which is a conjunction of the clojure.core.logic/== goals On 11/16/13, 5:04 PM, Mark wrote: d'oh! Answering my own question: Just compose the unify

Re: odd failure on recursive use of protocol member

2013-12-10 Thread Kevin Downey
extend mutates some state (the protocol definition), so what is happen here is comp is returning a new function built from the value of the rest-serialize var (the protocol function before the extend changes it) and the value of the deref var. I have not verified this, but I suspect if you use

Re: let bindings

2014-01-20 Thread Kevin Downey
On 1/20/14, 12:38 PM, Andy Smith wrote: Hi, (let bindings form) is a special form. As I understand it, let can be reformulated in terms of functions e.g. (let [x 2] (* x 20)) equivalent to ((fn [x] (* x 20)) 2) (let [x 3 y (* x x)] (- y x)) equivalent to ((fn [x] ((fn [x y] (- y x)) x

Re: test.check, quickcheck concurrency

2014-03-31 Thread Kevin Downey
On 3/28/14, 9:48 PM, Brian Craft wrote: Re: John Hughes' talk at clojure/west, at the end he did a fairly incredible demo of testing concurrency. It doesn't look like this was implemented in test.check (or I'm not finding it). Are there any plans? from my understanding his approach is

Re: Adding type hint causes compiler error

2009-07-05 Thread Kevin Downey
On Sun, Jul 5, 2009 at 5:18 AM, philip.hazel...@gmail.comphilip.hazel...@gmail.com wrote: Hi, The following code works as expected: (import 'javax.imageio.ImageIO 'java.io.File 'java.awt.image.BufferedImage) (defn bi-get-pixels  [bi]  (vec (.. bi (getData) (getPixels 0 0 (.getWidth bi)

Re: ArithmeticException with doubles

2009-07-10 Thread Kevin Downey
On Fri, Jul 10, 2009 at 1:00 PM, Daniel Lyonsfus...@storytotell.org wrote: On Jul 10, 2009, at 12:24 PM, Sean Devlin wrote: A quick java program: public static void main(String[] args) {    System.out.println(1.0/0.0); } Infinity On Jul 10, 11:08 am, John Harrop

Re: Clojure vectors

2009-07-13 Thread Kevin Downey
the sequence functions operate on sequences. if you pass in something that is not a sequence, like a vector, they call seq on it internally. so what you get back from filter or map is a sequence. conj has consistent behavior across types, you just get a different type out of map/filter/etc then

Re: another binding issue?

2009-07-14 Thread Kevin Downey
closures capture lexical scope, binding creates dynamic scope. lexical scope is where a closure is defined, dynamic is when it is called. because filter is lazy, the closure is called outside the dynamic scope created by binding On Jul 14, 1:07 pm, Aaron Cohen remled...@gmail.com wrote: I'm a

Re: another binding issue?

2009-07-14 Thread Kevin Downey
this is how you do it: user= (def a 0) #'user/a user= (binding [a 1] (map #(+ % a) (range 5))) (0 1 2 3 4) user= (binding [a 1] (let [a a] (map #(+ a %) (range 5 (1 2 3 4 5) user= you capture the dynamic scope in the lexical scope so the closure can close over it. dunno how applicable this

Re: Function overriding? Way to do it, similar to in Java

2009-07-24 Thread Kevin Downey
yes there is a way: http://clojure.org/multimethods On Fri, Jul 24, 2009 at 11:44 AM, BerlinBrownberlin.br...@gmail.com wrote: Are there ways to override functions so that if you have different parameters, you get different logic? -- And what is good, Phaedrus, And what is not good—

Re: clojure success story ... hopefully :-)

2009-08-21 Thread Kevin Downey
user= (defmulti length empty?) #'user/length user= (defmethod length true [x] 0) #MultiFn clojure.lang.mult...@1807ca8 user= (defmethod length false [x] (+ 1 (length (rest x #MultiFn clojure.lang.mult...@1807ca8 user= (length [1 2 3 4]) 4 On Fri, Aug 21, 2009 at 12:41 PM, Michel

Re: clojure classpaths

2009-09-01 Thread Kevin Downey
you could try running this test script: http://gist.github.com/179346 the script downloads clojure and does a test aot compile. if everything works the only output you should see is Hello World example: hiredman rincewind ~% sh ./clojure-aot-test.sh Hello World On Tue, Sep 1, 2009 at 11:37

Re: Dynamically Changing Functions in Compiled Code

2009-09-05 Thread Kevin Downey
gen-class generates a stub java class that dispatches to clojure functions, you can re-def the clojure functions that back the stubbed out class. On Sat, Sep 5, 2009 at 12:10 PM, Gorsals...@tewebs.com wrote: I am trying to add clojure code to an eclipse plugin. To do so, the code i compiled

Re: Dynamically Changing Functions in Compiled Code

2009-09-05 Thread Kevin Downey
it... -Original Message- From: clojure@googlegroups.com [mailto:cloj...@googlegroups.com] On Behalf Of Kevin Downey Sent: Saturday, September 05, 2009 7:46 PM To: clojure@googlegroups.com Subject: Re: Dynamically Changing Functions in Compiled Code gen-class generates a stub java class

Re: Correct idiom for looping inside a catch or finally form?

2009-09-13 Thread Kevin Downey
user= (macroexpand '(with-open [x A y Y] do stuff here)) (let* [x A] (try (clojure.core/with-open [y Y] do stuff here) (finally (. x clojure.core/close user= with-open expands to a (try (finally (.close ...))) On Sun, Sep 13, 2009 at 7:38 PM, Richard Newman holyg...@gmail.com wrote:

Re: Procedure for getting patches applied

2009-09-16 Thread Kevin Downey
have you seen http://clojure.org/patches ? On Wed, Sep 16, 2009 at 12:53 PM, Howard Lewis Ship hls...@gmail.com wrote: What is the procedure for getting patches (to clojure-contrib) committed? I've created a couple of issues in Assembla, created and attached patches. What's the next step to

Re: java/scala oneliner

2009-09-17 Thread Kevin Downey
:( map is lazy, so you'll need to wrap it in doall (dotimes [i 4] (println Happy Birthday ({2 Dear XXX} i To You))) On Thu, Sep 17, 2009 at 9:17 PM, David Nolen dnolen.li...@gmail.com wrote: Actually to be fair, here's a Clojure version that uses as little whitespace as the Scala and Java

Re: agents swallowing exceptions?

2009-10-19 Thread Kevin Downey
If any exceptions are thrown by an action function, no nested dispatches will occur, and the exception will be cached in the Agent itself. When an Agent has errors cached, any subsequent interactions will immediately throw an exception, until the agent's errors are cleared. Agent errors can be

Re: Removing duplication of redis/with-server in every function?

2009-10-23 Thread Kevin Downey
I think the point of this style of api is you just define your functions like (defn one [] ) (defn two [] ) and call the function like (redis/with-server *db* (one) (two)) On Thu, Oct 22, 2009 at 2:44 PM, Radford Smith radscr...@gmail.com wrote: I'm trying out redis-clojure. Right

Re: Constructing Java Interop calls

2009-10-28 Thread Kevin Downey
you can always just construct the call as a string or as a datastructure and pass it through read/eval On Wed, Oct 28, 2009 at 2:04 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 28.10.2009 um 20:46 schrieb Tiago Antão: But my point is to be able to construct the method name in runtime.

Re: Constructing Java Interop calls

2009-10-29 Thread Kevin Downey
user= ((eval `(fn [x#] (~(symbol .setFileSelectionMode) x# 1))) jfc) nil user= On Thu, Oct 29, 2009 at 6:38 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Oct 29, 2:07 pm, Tiago Antão tiagoan...@gmail.com wrote: The eval form still shows some problems, if I do this preparation:

Re: Constructing Java Interop calls

2009-10-30 Thread Kevin Downey
eval calls read for somethings. 2009/10/30 Tiago Antão tiagoan...@gmail.com: On Thu, Oct 29, 2009 at 1:38 PM, Meikel Brandmeyer m...@kotka.de wrote: All good here, but, if I do the eval variation, user= (eval (list (symbol .setFileSelectionMode) jfc 1)) Another example which shows that

Re: Creating custom exceptions in clojure gen--class use?

2009-11-01 Thread Kevin Downey
it'd be nice if clojure came with an Exception class that extended IMeta so you could use (catch MetaException e (if (= :my-exception (type e)) do-stuff (throw e))) On Sun, Nov 1, 2009 at 1:07 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 01.11.2009 um 20:47 schrieb Teemu Antti-Poika:

Re: Applying static java method to seq

2009-11-02 Thread Kevin Downey
(Integer/parseInt 5) is actually (. Integer parseInt 5) which works fine because . is the operator position, and . is a special form On Mon, Nov 2, 2009 at 11:32 AM, ataggart alex.tagg...@gmail.com wrote: If (Integer/parseInt 5) works, then not all functions need be an implementation of IFn;

Re: Baffled by NPE

2009-11-03 Thread Kevin Downey
(f (first items)) = nil ((f (first items)) (for-each f (rest items))) = (nil (for-each f (rest items))) = (.invoke nil (for-each f (rest items))) = calling a method on nil is a NPE lists are function applications On Tue, Nov 3, 2009 at 9:33 AM, Dean Wampler deanwamp...@gmail.com wrote: I'm

Re: Consistency of the API

2009-11-09 Thread Kevin Downey
I don't understand, the error message you get is the error that occurred. the docstring from even? says it throws an exception if the argument is not and integer. I would hope that anyone that has read the docstring for contains? would not use (contains? 'foo 'bar), because, uh, that just makes

Re: Consistency of the API

2009-11-09 Thread Kevin Downey
at 8:08 PM, Kevin Downey redc...@gmail.com wrote: I don't understand, the error message you get is the error that occurred. Both of them honor their documentation - no doubt. My point is not that, my point is that the behavior is different between the 2 functions for the same kind of issue

Re: Consistency of the API

2009-11-09 Thread Kevin Downey
of a crash early and crash hard philosophy, to increase the likelihood that a crash will happen in the block of code that is causing the problem and not later. On Mon, Nov 9, 2009 at 12:35 PM, Mark Engelberg mark.engelb...@gmail.com wrote: On Mon, Nov 9, 2009 at 12:32 PM, Kevin Downey redc

Re: clojure event handling

2009-11-12 Thread Kevin Downey
http://paste.lisp.org/display/87611#2 infinite seq of swing events On Thu, Nov 12, 2009 at 1:48 AM, Jeff Rose ros...@gmail.com wrote: On Nov 12, 1:22 am, nchubrich nicholas.chubr...@gmail.com wrote: I'm curious what the best idiomatic way of handling events is (e.g. receiving a series of

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread Kevin Downey
user= (import 'java.util.HashMap) java.util.HashMap user= (def m (doto (HashMap.) (.put 'a :a) (.put 'b :b))) #'user/m user= m #HashMap {b=:b, a=:a} user= (into {} m) {b :b, a :a} user= (class *1) clojure.lang.PersistentArrayMap user= On Tue, Nov 17, 2009 at 1:56 PM, Richard Newman

Re: String to Decimal Conversion

2009-11-22 Thread Kevin Downey
1.1 is not representable as an Integer(Java class, or primitive int) and is not an integer (mathematical sense) so expecting to be representable as one, is kind of... odd. On Sun, Nov 22, 2009 at 4:14 PM, Don josereyno...@gmail.com wrote: I am having a problem converting a string to decimal.  I

Re: String to Decimal Conversion

2009-11-22 Thread Kevin Downey
user= (read-string 1.1) 1.1 user= On Sun, Nov 22, 2009 at 4:48 PM, Don josereyno...@gmail.com wrote: Thanks a bunch Richard. On Nov 22, 4:47 pm, Richard Newman holyg...@gmail.com wrote: I am having a problem converting a string to decimal.  I want to convert 1.0 to decimal 1.0. For a

Re: Question about future

2009-11-25 Thread Kevin Downey
future also uses the same threadpool as agents, so once you call future the threadpool spins up, and just sort of sits around for a while before the jvm decides to exit, which is why the program would sit around for 50 seconds On Wed, Nov 25, 2009 at 10:30 AM, Hong Jiang h...@hjiang.net wrote:

Re: Updating Agent

2009-12-01 Thread Kevin Downey
uh, and you just want the agent to reference an empty vector? (send a (comp second list) []) (send a (constantly [])) (send a empty) ... On Tue, Dec 1, 2009 at 2:37 PM, Don josereyno...@gmail.com wrote: I actually came up with this function that takes in an agent and proceeds to pop each item

Re: Second Lisp to Learn

2009-12-21 Thread Kevin Downey
instant second lisp: just write your own interpreter On Sun, Dec 20, 2009 at 6:39 PM, Jonathan Smith jonathansmith...@gmail.com wrote: Lisp Flavored Erlang is an extremely interesting lisp. in my opinion. You get Erlang, and you also get s-expressions and macros. Common Lisp and Scheme are

Re: Proposal: clojure.io

2010-01-01 Thread Kevin Downey
I think something more abstract would be good. A function or macro where you pass it an IO Spec and it takes care of all the class stuff. (io/read [:bytes :from SOMETHING :as p] (do-stuff-with-a-byte p)) (io/read [:lines :from SOMETHING :as p] (do-stuff-with-a-string p)) (io/read [:lines

gui repl

2010-01-03 Thread Kevin Downey
I have been playing with a gui repl for clojure: http://github.com/hiredman/Repl instructions are light, but you can check it out, and use lien to jar it up, it is gen-class'ed (but does not require AOt'ing) and has a -main function so you can run it from an uberjar.

Re: gui repl

2010-01-04 Thread Kevin Downey
ah, well, the differences are: a. this repl is written in Clojure b. this repl can print arbitrary jcomponents, not just text. for example in the screenshot a ChartPanel from JFreeChart is rendered in the repl On Sun, Jan 3, 2010 at 11:42 PM, Albert Cardona sapri...@gmail.com wrote: I built a

Re: clojure unicode on Windows

2010-01-13 Thread Kevin Downey
java uses local settings, on windows the default encoding is some godawful thing (same on Mac, still godawful, but different) set file.encoding to pick something sane On Wed, Jan 13, 2010 at 1:52 PM, Lukas Lehner lehner.lu...@gmail.com wrote: Hi all The clojure unicode reading, evaluating and

Re: clojure unicode on Windows

2010-01-15 Thread Kevin Downey
file.encoding  UTF8) UTF8 user= éőó ∩┐╜o∩┐╜ user= L On 1/13/2010 11:34 PM, Kevin Downey wrote: java uses local settings, on windows the default encoding is some godawful thing (same on Mac, still godawful, but different) set file.encoding to pick something sane On Wed, Jan 13, 2010

Re: hash literal oddity?

2010-01-18 Thread Kevin Downey
what you are seeing is the transition from arraymap to hashmap On Mon, Jan 18, 2010 at 6:46 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: Is this expected behavior? {1 this 1 is 1 strange} = {1 this, 1 is, 1 strange} (into {} {1 this 1 is 1 strange}) = {1 strange} {1 this 1 is 1

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
clojure structs are an optimized version of maps for a set of shared keys. if you don't have a defined set of shared keys you just have a map. so by all means, use a map On Tue, Jan 19, 2010 at 3:52 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: Hi, I would like to know why defstruct

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
, Jan 19, 2010 at 3:59 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: On 20 Jan., 00:56, Kevin Downey redc...@gmail.com wrote: clojure structs are an optimized version of maps for a set of shared keys. if you don't have a defined set of shared keys you just have a map. so by all means, use

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
how is that not an argument? I'm pretty sure I just used it as one. keep in mind defstruct is largely to be superseded by deftype. http://clojure.org/contributing On Tue, Jan 19, 2010 at 4:10 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: I fail to see how it requires changing a lot of

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
I think your use of workaround is pejorative. And can it even be called a work around if it is a best practice even when there is nothing to work around? On Tue, Jan 19, 2010 at 4:28 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: how is that not an argument? I'm pretty sure I just used it

Re: Empty defstruct

2010-01-20 Thread Kevin Downey
empty classes in Java what does that mean? as I said, structs are an optimization on maps, that optimization doesn't work for empty structs, so empty structs of course don't make sense On Wed, Jan 20, 2010 at 12:39 AM, Andreas Wenger andi.xeno...@googlemail.com wrote: I think your use of

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Kevin Downey
for is lazy, and your code formatting is horrible. On Tue, Feb 2, 2010 at 2:48 PM, Wardrop t...@tomwardrop.com wrote: I've noticed that the output of a script, is often different to the output of the same commands if run on the REPL. This makes sense, but here's a situation which has got me a

Re: Seattle Clojure meeting

2010-02-03 Thread Kevin Downey
the 11th at Zokas is good for me On Wed, Feb 3, 2010 at 10:07 PM, ajay gopalakrishnan ajgop...@gmail.com wrote: I'm in! But on 11th. I cannot make it on 15th On Wed, Feb 3, 2010 at 7:01 PM, Phil Hagelberg p...@hagelb.org wrote: Hello, clojurists of Seattle. Let's meet! I'm thinking of

Re: Implicit style streams in Clojure

2010-02-08 Thread Kevin Downey
don't use def inside functions, ever. in scheme define is lexically scoped, so you do that sort of thing. clojure is not scheme. if you want a lexically scoped function use a lexical scoping construct like let or letfn. On Mon, Feb 8, 2010 at 12:12 PM, Brenton bashw...@gmail.com wrote: What is

Re: defn within defn

2010-02-10 Thread Kevin Downey
scheme's define is scoped inside a function. clojure is not scheme. clojure's def (which defn uses) is not lexical or scoped in anyway, it always operates on global names. if you want lexical scope please use one of clojure's lexical scoping constructs, let or letfn. On Wed, Feb 10, 2010 at 1:28

  1   2   3   >