Re: shortcut for anonymous function literal and syntax quote

2011-10-19 Thread Alan Malloy
Not really. In _Let Over Lambda_'s section on reader macros, he creates a reader macro #`(foo bar a1 a2) that expands to (lambda (a1 a2) `(foo bar ,a1 ,a2)), but this is not possible in Clojure. A nice example of something you can do with reader macros, in case Clojure ever gets them. And you

Re: Type hints and records

2011-10-19 Thread Alan Malloy
You can't really fix that, because (:foo bar) means call function :foo on bar, and in general the function :foo returns Object. (.foo bar) says look at the Java object bar, and give me its foo member. Because there is a typehint on that, Clojure can know what return type to expect. On Oct 19,

Re: Macro not working - newbie question

2011-10-19 Thread Alan Malloy
The compiler, and the macro system, work with data structures like lists and vectors, which have already been parsed from characters by the reader. If you want the field names as well, it's not hard to change my original answer: (defmacro defrecord-withstr [name include? columns fields] (let

Re: Clojure jar files.

2011-10-19 Thread Alan Malloy
Do whatever you want. Look inside clojure.jar - do you see a project.clj file? That said, I think it's polite to provide them if you're using lein or cake yourself, so that other users can read a config file that's not a POM. On Oct 19, 10:07 pm, mmwaikar mmwai...@gmail.com wrote: Hi, Is it

Re: About metadat and #^ macro.

2011-10-19 Thread Alan Malloy
I agree with the general sentiment: add typehints later, and only if you need performance in this particular part of the code. I object to the characterization as a small loss of performance, though. A reflective method call takes about five hundred times as long as a hinted method call in the

Re: Macro not working - newbie question

2011-10-18 Thread Alan Malloy
Simpler to just use the field names which are already bound, rather than constructing keywords out of them and calling them with juxt: (defmacro defrecord-withstr [name fields columns include?] (let [displayed (if include? columns (remove (set columns) fields))] `(defrecord ~name ~fields

Re: What changed 1.2/1.3 to cause this program slowdown?

2011-10-18 Thread Alan Malloy
I'm not an expert on the topic, but the threadring example has some suspicious ^Integer hints on values that were integers in 1.2 and are longs in 1.3 (ie, they were created from numeric literals). The hints don't seem to be actually being used, so I don't think this has an impact, but perhaps

Re: when quotes and when syntax-quotes?

2011-10-17 Thread Alan Malloy
On Oct 17, 12:50 pm, Marshall T. Vandegrift llas...@gmail.com wrote: Guofeng Zhang guof...@radvision.com writes: I do not understand why `'~v has be to used this way. If I used `~v instead (that is, remove the quote), it still works. So my question is, why ~v needs to be first quoted and

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-16 Thread Alan Malloy
An infinite loop on large inputs is unrelated to his null-pointer problem. As SICP makes clear, the imprecision of floating-point arithmetic means this particular algorithm will not terminate for large inputs. That is, rounding errors stop it from making progress when the numbers are large and the

Re: Pipe function

2011-10-15 Thread Alan Malloy
On Oct 14, 11:16 pm, Sean Corfield seancorfi...@gmail.com wrote: On Fri, Oct 14, 2011 at 5:50 PM, Alan Malloy a...@malloys.org wrote: I really liked this one too, though my first draft of it was more like (defn pipe [test f]  (fn [value]    (...))) ... fix is basically your pipe

Re: Pipe function

2011-10-15 Thread Alan Malloy
On Oct 15, 1:23 am, Sean Corfield seancorfi...@gmail.com wrote: On Sat, Oct 15, 2011 at 12:59 AM, Alan Malloy a...@malloys.org wrote: As you notice lower, I like this argument-order so that I can chain operations on values better Yes. But, that map is handy, so we have (to-fix), which

Re: Unexpected behavior with satisfies?

2011-10-15 Thread Alan Malloy
The most common cause of issues like this is if you reload ns1 after loading ns2, then T2 will be implementing an old version of pro-1, while fun will be testing for satisfaction of the current version. On Oct 15, 8:04 am, Eric in San Diego eric.sc...@acm.org wrote: Hi all - I'm experiencing

Re: Sum on a list of maps

2011-10-14 Thread Alan Malloy
Probably CSV or some other externally-input data. And FWIW I like BG's solution - it's what I would have written, except it's better. On Oct 14, 2:11 pm, Sean Corfield seancorfi...@gmail.com wrote: On Fri, Oct 14, 2011 at 10:25 AM, der derealme.derea...@gmail.com wrote: Given a list of maps of

Re: Pipe function

2011-10-14 Thread Alan Malloy
I really liked this one too, though my first draft of it was more like (defn pipe [test f] (fn [value] (...))) I've since expanded and generalized it into three related functions you can see at https://github.com/flatland/useful/blob/develop/src/useful/fn.clj#L16 fix is basically your

Re: ISeq protocol-like support

2011-10-11 Thread Alan Malloy
Interfaces are more java-y, which has pluses and minuses. Here for example, I think the compiler itself, which is written in java, needs to be able to seq things (ie, your source-code forms). *Maybe* you could make seqable a protocol, but it would make the compiler much less convenient as

Re: metadata on function objects

2011-10-11 Thread Alan Malloy
This. Metadata on functions in 1.2 was mostly accidental, from what I can tell. On Oct 11, 6:39 pm, Sam Ritchie sritchi...@gmail.com wrote: I remember not really understanding the way defn hung metadata off of its functions. In 1.2, it returned different responses on successive calls to defn.

Re: Libraries supporting 1.31.2 and bignums

2011-10-10 Thread Alan Malloy
(def +M (first [+' 1])) seems like it should work in both versions? On Oct 10, 4:28 pm, Brian Marick mar...@exampler.com wrote: I may be missing something obvious. Midje has a checker that lets users say things like    (fact (my-computation) = (roughly 15  2)) Where the first number in

Re: ANN: core.match 0.2.0-alpha5

2011-10-09 Thread Alan Malloy
On Oct 9, 12:31 pm, David Nolen dnolen.li...@gmail.com wrote: I've removed some fairly big bugs in the algorithm. This will probably the be the last alpha release before I cut a beta. Would love to hear any and all feedback. - clojure.core.match instead of clojure.core.match.core Those both

Re: How to Collapse Nested Map into a Sequence of Flat Maps

2011-10-09 Thread Alan Malloy
Your input isn't a legal Clojure form, and the correlation between input and output is difficult to spot, so it is hard to guess what you mean. Try a simpler example, preferably with less repetition of similar-looking values. On Oct 9, 5:34 pm, Ari ari.brandeis.k...@gmail.com wrote: Hi, I'd

Re: Oxjure - Oxford Clojure Group

2011-10-08 Thread Alan Malloy
He is talking about going to a location in the real world. I'm sure you would be welcome at the Oxford group next time you are in Oxford. On Oct 8, 8:00 pm, jaime xiejianm...@gmail.com wrote: Why not use this group directly?? I personally think separating people in different groups will

Re: How to use realized? on a lazy sequence?

2011-10-07 Thread Alan Malloy
Can't you write that function yourself? (defn realized-length [xs] (loop [n 0 xs xs] (if (realized? xs) (recur (inc n) (rest xs)) n))) drop returns a new lazy sequence, with no realized elements, so naturally you can't ask if the sequence under it is realized. If you want to

Re: how to use record as a value

2011-10-06 Thread Alan Malloy
-foo is new in 1.3. I'm surprised so many people are recommending it without mentioning that. -foo is like foo., except that it's a real clojure function and as such can be passed as a function; you can call apply on it; and so forth. On Oct 6, 11:05 am, Razvan Rotaru razvan.rot...@gmail.com

Re: Reference a function dynamically in a macro?

2011-10-05 Thread Alan Malloy
This fix has some bugs - you let finder but never use it. Adjusted below: (defmacro unique? [name value msg] (let [finder (symbol (str by- (clojure.core/name name)))]) `(let [value# ~value] (when-not (str/blank? value#) (when-let [existing# (~finder value#)] (duplicate

Re: defprotocol problem in 1.3?

2011-10-04 Thread Alan Malloy
Doesn't java have kinda-sorta union types now? Like, you could declare a method as: public T extends Closeable Serializable void serializeAndClose(T thing) {...} It seems like marker interfaces are no longer necessary for this sort of thing. Likewise in Clojure, instead of having a

Re: unable to resolve symbol: doc

2011-09-30 Thread Alan Malloy
C-c C-d d, right? On Sep 30, 1:38 pm, Phil Hagelberg p...@hagelb.org wrote: On Fri, Sep 30, 2011 at 12:12 PM, Andrew ache...@gmail.com wrote: When I do M-x clojure-jack-in on one project.clj which uses clojure 1.2.1, I'm able to evaluate (doc map). But with another project.clj which uses

Re: break-on-gaps - just curious if there is a more idiomatic way to do this

2011-09-28 Thread Alan Malloy
I wrote a generalized version of this called partition-between, which you can see at https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L181 if you're interested. Using that as a primitive, your break-on-gaps function is simple: user (partition-between (fn [[a b]] (not= a (dec

Re: Does macros evaluates its arguments before?

2011-09-27 Thread Alan Malloy
a symbol (argument of macro), it does. So, need to have comprehensive and profound knowledge about its behavior, including subtleties, even in very simple use cases. Your explanation show this quite clearly. On 27 сен, 02:42, Alan Malloy a...@malloys.org wrote: I suspect your repl

Re: Does macros evaluates its arguments before?

2011-09-26 Thread Alan Malloy
Noo, then you can't do, for example, (let [x 1] (infix (x + 1))). On Sep 26, 8:34 am, Bronsa brobro...@gmail.com wrote: or simply replace ~e with '~e -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Does macros evaluates its arguments before?

2011-09-26 Thread Alan Malloy
I suspect your repl was stale, since this doesn't work at all. By an amusing coincidence, though, it doesn't break, just returns the wrong answer: user= (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#))) #'user/infix user= (infix (5 + 4)) 4 That is, the *symbol* +, not the function +, is

Re: Randomly select an element from a sorted-set (rand-nth (sorted-set ..))

2011-09-26 Thread Alan Malloy
On Sep 26, 2:12 pm, Paul Richards paul.richa...@gmail.com wrote: On Sep 26, 2:12 pm, Paul Richards paul.richa...@gmail.com wrote: Hi, How can I efficiently pick a random element from a sorted-set? I've come up with a bit of a hack, which relies on me not caring about non-uniform

Re: Display elapsed time in REPL

2011-09-25 Thread Alan Malloy
(time (expr)) On Sep 25, 2:43 am, captobvious chrismmag...@gmail.com wrote: How do you get the REPL to display the elapsed time for a function? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: beginner question

2011-09-24 Thread Alan Malloy
This is about right, though instead of a loop/recur you can just (map render (iterate next-state start-state)) On Sep 24, 12:36 pm, Dennis Haupt d.haup...@googlemail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 in java, i would start coding a game with a loop like this: while

Re: Partitioning problem

2011-09-23 Thread Alan Malloy
In the general case this is an NP-complete problem (ie, no algorithm you can write will be good enough), but many simpler cases can be solved quickly by some heuristic or other. See http://en.wikipedia.org/wiki/Partition_problem#Methods for some examples. On Sep 23, 4:51 am, Michael Jaaka

Re: Addition of new a priori distinct element to a vector

2011-09-23 Thread Alan Malloy
On Sep 23, 3:02 pm, F Lengyel florian.leng...@gmail.com wrote: On Sep 23, 2:20 am, Kevin Livingston kevinlivingston.pub...@gmail.com wrote: what's the actual use case where you want this? it seems pretty weird just on it's own.  it may in practice be more clever than other solutions, but

Re: StackOverflowError in prime function

2011-09-22 Thread Alan Malloy
FWIW there's a lot of prior threads about this problem in various guises. The one I like to refer people to is on stackoverflow, and is for exactly what you're doing: http://stackoverflow.com/questions/2946764/recursive-function-causing-a-stack-overflow On Sep 22, 9:36 am, Alf Kristian Støyle

Re: How does clojure class reloading work?

2011-09-22 Thread Alan Malloy
On Sep 22, 5:52 pm, Phil Hagelberg p...@hagelb.org wrote: On Thu, Sep 22, 2011 at 2:19 PM, Chouser chou...@gmail.com wrote: It looks like each top-level form currently gets its own fresh DynamicClassLoader. [...] (do (def a #()) (def b #())) If you'll pardon a nit-pick, this example

Re: Is there a reason that def- isn't part of the core lib?

2011-09-18 Thread Alan Malloy
I would rather see defn- removed, than add any more foo- functions. If there are any more function attributes we want to tag things with (say, automatically memoized?) that would be 2^N new convenient definition forms, in an already-packed clojure.core namespace. And it's not hard at all to (let

Re: Is there a reason that def- isn't part of the core lib?

2011-09-18 Thread Alan Malloy
On Sep 18, 10:44 am, Chas Emerick cemer...@snowtide.com wrote: On Sep 18, 2011, at 1:10 PM, Stuart Halloway wrote: The other example that immediately leaps to mind is that the family of get-in, get, and update-in implies the existence of update.  It is rather startling to me that update

Re: Is there a reason that def- isn't part of the core lib?

2011-09-18 Thread Alan Malloy
What really puzzles me is that it doesn't seem to be generally regarded as idiomatic Clojure style to just use top-level (let)s for your private globals. This has lots of benefits: - If you do this you can make them actually, genuinely private, rather than just marked as please don't use this -

Re: misuse of or bug in transients?

2011-09-16 Thread Alan Malloy
Certainly looks like a valid use of transients. Might be related to http://dev.clojure.org/jira/browse/CLJ-829 but I dunno. On Sep 16, 9:55 am, Sergey Didenko sergey.dide...@gmail.com wrote: When I convert the following code to use transients it returns different result. Am I doing anything

Re: small project to learn clojure

2011-09-16 Thread Alan Malloy
Notice something you do often, and try to automate it. Or find an open- source project you use, and you wish were better in some way, and improve it. Learning a language by means of I need to learn something, what should I do is not as effective, or as fun, as learning it by doing something you

Re: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Alan Malloy
You can prefer anything you want, but (a) to say that Clojure prefers loop/recur is nonsense, and (b) you can't make an incorrect algorithm work just by preferring it. Jeff is correct that your algorithm requires space for each level of the tree, and so cannot be converted into a constant-space

Re: Calling a Java call with array from Clojure

2011-09-13 Thread Alan Malloy
Varargs are a fiction of javac, and do not exist at the bytecode level. In real life, this method takes two args, a String and a String[]. Use into-array to create a string array, and pass that as the second arg. On Sep 13, 6:21 pm, ron peterson peterson.ron...@gmail.com wrote: I have a

Re: puzzlement over lazy sequences

2011-09-11 Thread Alan Malloy
Integer overflow. user (mod 9876543210 (bigint (Math/pow 2 32))) 1286608618 On Sep 11, 9:44 pm, George Kangas gwkan...@gmail.com wrote: I believe the bug can be blamed on nth. Using nth, I make a function which should be identity on natural numbers: Clojure 1.2.1 user= (defn ident [n]

Re: lambda function returning a constant?

2011-09-06 Thread Alan Malloy
As Laurent says, you should just use the built-in `identity` function, but you can write it yourself: as you noticed, (fn [x] x) works, but if you want to do it with the shorthand syntax you can use #(do %). On Sep 4, 1:56 pm, julianrz julia...@yahoo.com wrote: Hello All, I am new to Clojure.

Re: An open call to the community: Let's prepare for 1.3

2011-09-04 Thread Alan Malloy
On Sep 4, 12:54 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 03.09.2011 um 23:12 schrieb Alan Malloy: Huh, interesting. I assumed ^:foo meta syntax was new to 1.3, and wouldn't compile at all in 1.2. But now I see that in 1.2 it's equivalent to ^{:tag :foo} - not useful

Re: new Getting Started page

2011-09-04 Thread Alan Malloy
On Sep 4, 6:00 pm, Ken Wesson kwess...@gmail.com wrote: On Sat, Sep 3, 2011 at 2:11 AM, Kevin Downey redc...@gmail.com wrote: The idea that the way to get started is with a fancy editor and a fancy ide is just crazy. The way to get started with Clojure is: write functions, and run them, and

Re: Differences Between seq? and sequential?

2011-09-03 Thread Alan Malloy
user (map (juxt seq? sequential?) '([1 2] (1 2))) ([false true] [true true]) All seqs are sequential, but not all sequential things are seqs. On Sep 3, 12:14 pm, octopusgrabbus octopusgrab...@gmail.com wrote: I've noticed that solutions to rolling your own Clojure flatten involve the

Re: An open call to the community: Let's prepare for 1.3

2011-09-03 Thread Alan Malloy
I prefer to use ^{:dynamic true} instead of ^:dynamic, unless you're recommending intentionally breaking compatibility with 1.2 so as to encourage people to move to 1.3. On Sep 3, 12:27 pm, Chris Granger ibdk...@gmail.com wrote: Hey Folks, With the release of 1.3 growing ever nearer, it's time

Re: not= counterintuitive?

2011-09-03 Thread Alan Malloy
(= (seq v) (distinct v)) will short-circuit as soon as an inequality is found. On Sep 3, 12:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 03.09.2011 um 19:30 schrieb Despite: So, you want to make sure each value in the vector is unique?  My first thought was to put them into a set,

Re: not= counterintuitive?

2011-09-02 Thread Alan Malloy
On Sep 2, 11:14 am, ax2groin ax2gr...@gmail.com wrote: This code doesn't return the value I intuitively expect:   user= (not= 1 2 1)   true When I write that, I was expecting the equivalent of (and (= 1 2) (= 1 1)), but the macro expansion is essentially (not (= 1 2 1)). This is not a

Re: generic math, comparator and arithmetic libs

2011-09-01 Thread Alan Malloy
I don't see any reason for it to include !=, which can be implemented as (not (= a b)). Conversely, = could be implemented as (or ( a b) (= a b)), but if either of those is expensive operations he gives you a chance to do a more-optimized =. There's not much point in forcing people to implement

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Alan Malloy
Well, the two calls to subseq are unpleasant and possibly slow. I was thinking there's a way to write it as a single operation that returns three items, say (subseq s = (dec 50)) to get the items before and after 50, but of course that doesn't work unless you know 49 is in there, and in that case

Re: is there a 4Clojure forum anywhere?

2011-08-31 Thread Alan Malloy
Hey, thanks for that. I'll add a link in the next build, though I haven't decided what to call it: Forums sounds like it's part of 4clojure, Unofficial forum sounds kinda untrue if the official site is linking to it, ... Anyway, I'd appreciate having admin rights but I don't really plan to use

Re: JVM 7 support (invokedynamic)

2011-08-28 Thread Alan Malloy
On Aug 28, 12:41 pm, Tal Liron tal.li...@gmail.com wrote: If you look at the links in my previous e-mail (specifically this one https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/C...). The reflection is done in the compiler only when there is a tag (i.e. a type hint).

Re: mutability in the let-form!?

2011-08-27 Thread Alan Malloy
Perhaps you'd be more comfortable considering this equivalent syntax: (let [x 1] (let [y 2] (let [x (+ x y)] x))) In principle, the multiple-binding let is transformed to this version and thus has identical semantics; in practice, the compiler does something more efficient but

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Alan Malloy
On Aug 26, 12:40 pm, Tassilo Horn tass...@member.fsf.org wrote: Paul  Mooser taron...@gmail.com writes: Hi Paul, If you search for filter and StackOverflowError in this group, you will find people discussing related issues. Thanks, I've found some explanation by Meikel Brandmeier who

Re: is there a 4Clojure forum anywhere?

2011-08-26 Thread Alan Malloy
I haven't heard of one either, and I'm maintainer and co-founder of 4clojure. If someone (that means you!) starts such a forum, I'm happy to link to it from 4clojure proper. On Aug 26, 5:59 pm, Bob Shock shock...@gmail.com wrote: Is there a recovery group for 4clojure.com addicts? Stop now!

Re: Peculiar transients behaviour

2011-08-25 Thread Alan Malloy
-- Clojure/corehttp://clojure.com On 08/24/2011 04:32 AM, Alan Malloy wrote: On Aug 24, 12:27 am, Alan Malloya...@malloys.org  wrote: On Aug 23, 11:38 pm, Ken Wessonkwess...@gmail.com  wrote: What does zipmap do if the key seq contains duplications? That was my instinct too

Re: Peculiar transients behaviour

2011-08-25 Thread Alan Malloy
Update: just built master, and issue still exists. If you want to be sure you get it, just add another zero to the input range. I'll mention that in the ticket as well. On Aug 25, 10:14 am, Alan Malloy a...@malloys.org wrote: I did, of course. I searched for transient, and didn't find any

Re: Peculiar transients behaviour

2011-08-24 Thread Alan Malloy
On Aug 23, 11:38 pm, Ken Wesson kwess...@gmail.com wrote: What does zipmap do if the key seq contains duplications? That was my instinct too, but (a) a few thousand numbers won't collide very often at all given the problem space, and (b) some experimenting indicates that the key-seq is always

Re: Peculiar transients behaviour

2011-08-24 Thread Alan Malloy
On Aug 24, 12:27 am, Alan Malloy a...@malloys.org wrote: On Aug 23, 11:38 pm, Ken Wesson kwess...@gmail.com wrote: What does zipmap do if the key seq contains duplications? That was my instinct too, but (a) a few thousand numbers won't collide very often at all given the problem space

Re: Creating a Clojure Record from a string

2011-08-23 Thread Alan Malloy
On Aug 23, 3:39 pm, Craig Andera cand...@wangdera.com wrote: (Class/forName java.lang.String) Oh, does that work in 1.3? Because (new (Class/forName user.Foo)) was the first thing I tried (under 1.2) and it doesn't work. Perhaps unsurprisingly given that new is a special form. No. But you

Re: syntax quoting and namespaces misbehaving in test?

2011-08-16 Thread Alan Malloy
java.lang.Exception] On Mon, Aug 15, 2011 at 8:56 PM, Alan Malloy a...@malloys.org wrote: I either disagree or don't understand. The deftest macro doesn't touch your body arg; it's expanded as-is. For example, (let [x 'foo] `(inc ~x)) doesn't result in foo getting qualified, and most macros behave

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
On Aug 15, 6:16 am, Richard Rattigan ratti...@gmail.com wrote: I don't understand why this test would fail - can anyone explain why? (ns learn.clojure.test.core   (:use [clojure.test])) (deftest namespaces   (in-ns 'my.new.namespace)   (is (= my.new.namespace (str *ns*)))   (is (=

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
Is it? That's neat; I guess I've never thought about how the compiler treats def. Thanks for the explanation. On Aug 15, 3:03 pm, Mark Rathwell mark.rathw...@gmail.com wrote: deftest is a macro.  Macros are expanded at compile time.  So, in this case, at compile time, a function called

Re: syntax quoting and namespaces misbehaving in test?

2011-08-15 Thread Alan Malloy
to be clear, it is namespace resolved because of syntax quote: (defmacro deftest   [name body]   (when *load-tests*     `(def ~(vary-meta name assoc :test `(fn [] ~@body))           (fn [] (test-var (var ~name)) On Mon, Aug 15, 2011 at 7:23 PM, Alan Malloy a...@malloys.org wrote

Re: defining tests for an api to be called by the implementations

2011-08-15 Thread Alan Malloy
On Aug 15, 10:16 pm, Kevin Livingston kevinlivingston.pub...@gmail.com wrote: I am working on an api that has an interface and two distinct implementations lets call them: foo and bar. I have a testing routine with a bunch of functions that each call a function to get a clean instance of an

Re: is my understanding correct for function identity?

2011-08-13 Thread Alan Malloy
On Aug 13, 12:45 pm, jaime xiejianm...@gmail.com wrote: I found an interesting function identity which will do nothing but only returns the parameter passed to it. The next minute I came up a question: then what's the purpose of this function? -- I've tried to figure out reasons of existence

Re: rebind var for all threads

2011-08-11 Thread Alan Malloy
On Aug 11, 12:31 pm, Ken Wesson kwess...@gmail.com wrote: On Thu, Aug 11, 2011 at 2:05 PM, Mark Rathwell mark.rathw...@gmail.com wrote: (This is all moot at this point, since the author or Noir has made changes that allow it to be compatible with App Engine.) App Engine. Background:

Re: reverse a sequence without reverse or rseq

2011-08-08 Thread Alan Malloy
(into () [1 2 3 5]) On Aug 8, 11:29 am, MarisO maris.orbid...@gmail.com wrote: Do you know of any trick to reverse a sequence without reverse or rseq ? I wrote it like this: ((fn rev    ([s] (rev '() s))    ([r s] (if (seq s) (rev (cons (first s) r) (rest s)) r )) )  '[1 2 3 5]  )

Re: standalone indentation tool

2011-08-07 Thread Alan Malloy
On Aug 7, 11:10 am, Eric Lavigne lavigne.e...@gmail.com wrote: The pprint function in the Clojure standard library indents Clojure source code.      http://richhickey.github.com/clojure/clojure.pprint-api.html Er, won't you lose all comments and have reader macros expanded if you

Re: deftypes that implement IPersistentCollection#equiv: argument order

2011-08-04 Thread Alan Malloy
On Aug 3, 5:54 pm, Brian Marick mar...@exampler.com wrote: In Midje, I have reason to create a type Metaconstant whose instances are equal to a symbol with the same name. Here's the relevant bits of the definition:     (deftype Metaconstant [name storage]       Object       (equals [this

Re: dynamically generated let bindings

2011-07-30 Thread Alan Malloy
On Jul 29, 2:02 pm, Ken Wesson kwess...@gmail.com wrote: (fn [ args]   (let [argmap__5673__auto (#'some-ns/parse-args args)         foo (or (:foo argmap__5673__auto) 42)         bar (or (:bar argmap__5673__auto) nil)         ...]     (body goes here))) where you define a private parse-args

Re: dynamically generated let bindings

2011-07-29 Thread Alan Malloy
a function called by a macro to do some processing of forms. Yep, this is precisely what I was considering. I should have explicitly made mk-dynamically-bound-fn a macro in my example - a miscommunication on my part. On 29 Jul 2011, at 02:12, Alan Malloy wrote: It's not clear how much

Re: passing value to functions

2011-07-28 Thread Alan Malloy
On Jul 28, 12:22 pm, Thorsten Wilms t...@freenet.de wrote: On 07/28/2011 06:34 PM, Tuba Lambanog wrote: The determination of whether a called function will apply is left as a responsibility of the function itself, rather than the calling function. The motivation is that a function may be

Re: dynamically generated let bindings

2011-07-28 Thread Alan Malloy
On Jul 28, 3:48 pm, Sam Aaron samaa...@gmail.com wrote: Hi there, I'm trying to create a fn which does the following: * returns a fn which takes an arbitrary number of args * calls a helper fn, passing the incoming args returning a vector of alternating symbols and vals * creates a let

Re: passing value to functions

2011-07-28 Thread Alan Malloy
On Jul 28, 8:11 pm, Resty Cena restyc...@gmail.com wrote: Hi, Masanori, Yes, I noticed the similarity. I'm using Laurent's 'manual way' for now. I'll look at Alan's and Laurent's more concise solution in a few days. The manual way is easy to debug as all I have to do is println the

Re: How to write `when-lets`

2011-07-27 Thread Alan Malloy
On Jul 27, 5:50 am, Feng Shen shen...@gmail.com wrote: Clojure core.clj has a macro when-let, I am wondering how to write a macro `when-lets` (when-lets [symbol-1 test-1                    symbol-2 test-2             ...             ]            body            ) body only get evaluated

Re: How to write `when-lets`

2011-07-27 Thread Alan Malloy
On Jul 27, 11:11 am, Alan Malloy a...@malloys.org wrote: On Jul 27, 5:50 am, Feng Shen shen...@gmail.com wrote: Clojure core.clj has a macro when-let, I am wondering how to write a macro `when-lets` (when-lets [symbol-1 test-1                    symbol-2 test-2

Re: How to write `when-lets`

2011-07-27 Thread Alan Malloy
On Jul 27, 11:57 am, Aaron Cohen aa...@assonance.org wrote: On Wed, Jul 27, 2011 at 2:39 PM, Ken Wesson kwess...@gmail.com wrote: On Wed, Jul 27, 2011 at 2:35 PM, Aaron Cohen aa...@assonance.org wrote: I may be wrong, but don't you need to swap the order of the arguments to f? You can

Re: How to write `when-lets`

2011-07-27 Thread Alan Malloy
On Jul 27, 11:56 am, Dmitry Gutov raa...@gmail.com wrote: First: Why doesn't macroexpand expand the inner when-lets? It's not supposed to, see the doc. To do full expansion, you can use `clojure.walk/macroexpand-all`. Is the gensym in the two expands the same thing, or do they get the

Re: format and printf can't be used with BigInt

2011-07-27 Thread Alan Malloy
On Jul 27, 11:45 am, Andrea Tortorella elian...@gmail.com wrote: Hi everyone, I don't know where to post about bugs (if this is a bug). Anyway in clojure 1.3 with the new numerics: (format %d 2N) throws IllegalFormatConversionException, is it a bug? are there any workarounds? Unlikely to

Re: Java object field access

2011-07-26 Thread Alan Malloy
On Jul 25, 11:10 pm, Petr Gladkikh petrg...@gmail.com wrote: I am trying to construct java object and assign it's fields from a map. That is given Java object of class Something { long id; String name; } and Clojure map {:id 12, :name Impostor} I would like to set fields of java object to

Re: Invitation for Open Source Project

2011-07-26 Thread Alan Malloy
On Jul 26, 9:27 am, Peter Penzov peter.pen...@gmail.com wrote: Hi,     I'm starting a open source project which involves web based Java, JBoss application server and JBoss Seam 3. I'm a student and I work on the project in my free time for training. Every one who want to take a part in this

Re: Parsing double with default value

2011-07-25 Thread Alan Malloy
On Jul 25, 1:18 pm, siyu798 siyu...@gmail.com wrote: Tassilo,    The reason a generic default macro being used here is because we can use the same macro to parse other data type like integer: (with-default 1 (Integer. my-value)) Thanks, siyu You can still do the same with a function:

Re: Why that slowness?

2011-07-22 Thread Alan Malloy
On Jul 21, 2:39 pm, Tassilo Horn tass...@member.fsf.org wrote: Alan Malloy a...@malloys.org writes: Hi Alan, Any hints? (1) The first version is doing way less work. It tries the first rule until it runs out of steam, then the second rule, then the third rule. If the third rule

Re: Argh - was Re: Re: Re: Re: Re: Re: The Last Programming Language

2011-07-22 Thread Alan Malloy
On Jul 22, 3:35 am, Nick oinksoc...@letterboxes.org wrote: On 22/07/11 05:30, daly wrote: On Thu, 2011-07-21 at 23:03 -0400, Jeff Dik wrote: On Tue, Jul 19, 2011 at 9:04 PM, daly d...@axiom-developer.org wrote: On Tue, 2011-07-19 at 20:14 -0400, Adam Richardson wrote: On Tue, Jul 19, 2011

Re: Why that slowness?

2011-07-22 Thread Alan Malloy
On Jul 21, 11:23 pm, Alan Malloy a...@malloys.org wrote: On Jul 21, 2:39 pm, Tassilo Horn tass...@member.fsf.org wrote: Alan Malloy a...@malloys.org writes: Hi Alan, Any hints? (1) The first version is doing way less work. It tries the first rule until it runs out of steam

Re: better community docs: getting started

2011-07-22 Thread Alan Malloy
On Jul 22, 3:32 pm, Phil Hagelberg p...@hagelb.org wrote: Stuart Halloway stuart.hallo...@gmail.com writes: As a first pass, I have trimmedhttp://clojure.org/getting_started, and quite clearly linked out tohttp://dev.clojure.org/display/doc/Getting+Startedfor advice on tools, IDEs, etc.

Re: Why that slowness?

2011-07-21 Thread Alan Malloy
On Jul 21, 12:15 pm, Tassilo Horn tass...@member.fsf.org wrote: Hi all, probably I don't see the forest for trees, but anyhow.  In my graph transformation lib I have these functions for applying rules: --8---cut here---start-8--- (defn iteratively  

Re: The Last Programming Language

2011-07-19 Thread Alan Malloy
On Jul 19, 1:23 pm, Sean Corfield seancorfi...@gmail.com wrote: On Tue, Jul 19, 2011 at 4:50 AM, Ken Wesson kwess...@gmail.com wrote: What video? The only video I see linked from there is over an hour long. Obviously you can't mean that one, since no one around here has that kind of spare

Re: The Last Programming Language

2011-07-19 Thread Alan Malloy
On Jul 19, 3:23 pm, Brian Hurt bhur...@gmail.com wrote: What's this awk-a-mel he speaks of?  Ocaml, pronounced oh-camel, I know very well, but I've never heard of this awk-a-mel.  :-) Seriously, his pronunciation of ocaml highlights, I think, the core problem of his talk.  There has been

Re: Questions About Assoc-in, Dissoc-in, etc.

2011-07-16 Thread Alan Malloy
On Jul 16, 7:11 pm, Asim Jalis asimja...@gmail.com wrote: I've been using assoc-in and dissoc-in to navigate through nested associative structures (HTTP requests). Had some questions: 1. Why doesn't dissoc-in take multiple key-sequences? For example: (dissoc-in m [:a :b :c] [:a :b :d]) I

Re: Namespace Docstrings?

2011-07-15 Thread Alan Malloy
On Jul 15, 3:10 pm, Rasmus Svensson r...@lysator.liu.se wrote: 2011/7/14 OGINO Masanori masanori.og...@gmail.com: Hello. What is the right way to display namespace docstrings? One day, as usual, I typed: (doc 'clojure.core) ; or other namespace Then the REPL said clojure.lang.Cons

Re: Noobie needs help

2011-07-14 Thread Alan Malloy
For what it's worth, Giancarlo makes a good (though vague) point when recommending maps. You rarely (but not never!) want to def something programmatically: defs are for things you as the programmer want to give names to and have access to directly in source code. Often, this sort of define a

Re: monads macros

2011-07-12 Thread Alan Malloy
On Jul 12, 9:33 am, Thorsten Wilms t...@freenet.de wrote: It's not my perception that there is a lot of noise about macros, whereas articles about monads are like bunnies and have taken to the meta-level. I was going to write an article about how to use monads to simplify the implementation of

Re: monads macros

2011-07-12 Thread Alan Malloy
On Jul 12, 12:01 pm, Konrad Hinsen konrad.hin...@fastmail.net wrote: The composability issue with macros lies in writing them, not using them. Strongly disagree. Macros compose reasonably well when writing them (eg, using let in the implementation of with-open is trivial); it's composing

Re: a lazy version of shuffle.

2011-07-11 Thread Alan Malloy
If the sequence is already realized, or is cheap, and you want only a very small random subset of it, you can do better than shuffling the whole thing. Fliebel and I played around with several solutions to this, some time ago. I can't find the whole thing, but some interesting examples and

Re: How to add jar files to leiningen projects?

2011-07-11 Thread Alan Malloy
Maven will give you this list of instructions if you just add a dependency to project.clj, and it can't find the required artifact. So write your project.clj as though your external jars were available to maven, and then maven will tell you how to make it available. It's the same as Mark's

<    1   2   3   4   >