Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Stuart Campbell
On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com wrote: You can't use `map` because `map` will return a sequence of the same size and that can blow your heap. Isn't `map` lazy too? Regards, Stuart -- You received this message because you are subscribed to the Google Groups Clojure

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Sean Neilan
I don't think so. On Wed, May 2, 2012 at 1:22 AM, Stuart Campbell stu...@harto.org wrote: On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com wrote: You can't use `map` because `map` will return a sequence of the same size and that can blow your heap. Isn't `map` lazy too?

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread László Török
Map IS lazy but it still returns the entire realized sequence, as expected. On May 2, 2012 8:31 AM, Sean Neilan s...@seanneilan.com wrote: I don't think so. On Wed, May 2, 2012 at 1:22 AM, Stuart Campbell stu...@harto.org wrote: On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Baishampayan Ghose
On Wed, May 2, 2012 at 12:01 PM, Sean Neilan s...@seanneilan.com wrote: I don't think so. Of course it is. The problem is not in laziness, but in holding on to the head. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- You received this message because you are subscribed to the

Re: Pulling constants out of interfaces

2012-05-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 1. Mai 2012 20:17:21 UTC+2 schrieb Chris Perkins: I wouldn't put too much stock in what it says at clojure.org/reader - it hasn't been updated in a long time. The implementation is probably a more definitive definition of what characters are allowed. In the past, Rich

Re: Arithmethic Evaluation

2012-05-02 Thread Jim - FooBar();
On 02/05/12 04:19, Asranz wrote: so i need some others functions to parse it and then just doing the infix i guess? basically you need to find a way to convert your string into a data-structure (a list) and then you can use a macro to rearrange things in any way you like...as long as it is a

unicode support in clojurescript reader

2012-05-02 Thread Dave Sann
I needed unicode support for the clojurescript reader so I have made an attempt at adding it. This works for me - but it is my first foray into changes to this source. my commit is here https://github.com/davesann/clojurescript/commit/1f142d283959eead06ba0d00f9cba7fe3053d4a8 I have done the

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Allen Johnson
My example included a use of `map`. It is lazy and will work but you have to be sure that you aren't using it in a way that would hold onto the head of the sequence. When experimenting in a repl it might not seem that it is lazy since the repl will attempt to print the result of calling map when

Data vs API

2012-05-02 Thread Mark
I've read in some recent posts that Clorujians prefer data to APIs. I'm not sure I understand what this means, in practice. When I'm in the early stages of developing an application, the data structures undergo a great deal of change. One of the ways, I isolate parts of the code from these

Re: Data vs API

2012-05-02 Thread Baishampayan Ghose
I've read in some recent posts that Clorujians prefer data to APIs.  I'm not sure I understand what this means, in practice.  When I'm in the early stages of developing an application, the data structures undergo a great deal of change.  One of the ways, I isolate parts of the code from these

Re: Data vs API

2012-05-02 Thread Raoul Duke
On Wed, May 2, 2012 at 7:03 AM, Mark markaddle...@gmail.com wrote: I've read in some recent posts that Clorujians prefer data to APIs.  I'm not sure I understand what this means, in practice.  When I'm in the early stages of developing an application, the data structures undergo a great deal

Re: Arithmethic Evaluation

2012-05-02 Thread Armando Blancas
Though I'm opposed to posting solutions to school assignments --in principle-- here's this little something in the hope that it might get you interested in lisp: (defn value [e] (cond (number? e) e (= (second e) '+) (+ (value (first e)) (value (nth e 2))) (= (second e) '-) (-

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Michał Marczyk
Note also that in the REPL the last three values returned are kept available under *1, *2 and *3. M. On 2 May 2012 15:40, Allen Johnson akjohnso...@gmail.com wrote: My example included a use of `map`. It is lazy and will work but you have to be sure that you aren't using it in a way that

Re: Data vs API

2012-05-02 Thread Stuart Sierra
The data *is* the API. Design the data structures you're going to accept return at all the public entry-points of your library or application. That's your API design. It's kind of like web APIs returning JSON or XML: the structure of the data you get back is part of the contract. -S -- You

ClojureScript and Google Closure Type Annotations

2012-05-02 Thread Robert Stuttaford
Forgive me if this has been asked before. I am writing a GClosure app at the moment (using the long-form java-style Google Closure javascript *blecch*), and I'm using JSDoc type-annotations for everything: /** @type {number} */ var x = parseInt( data['foo'], 10 ); These annotations allow

question with macro!

2012-05-02 Thread 金山
I defined a macro like this: (defmacro randomly [ exprs] (let [len (count exprs) ind (rand-int len) conditions (map #(list '= ind %) (range len))] `(cond ~@(interleave conditions exprs and then defined a function : (defn randomly-fn [ exprs] (randomly exprs)) I

Re: [ANN] Leiningen 2.0.0-preview3

2012-05-02 Thread adrians
I'm also getting this error, with same spec Windows but with Java 7. Unfortunately, I also get this with lein 1.7.1. Tried to build from source, but lein install generates a snapshot jar that only includes a few source files. Can anyone offer a solution to building your own lein? Thanks,

Re: Data vs API

2012-05-02 Thread Raoul Duke
On Wed, May 2, 2012 at 12:27 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: The data *is* the API. Design the data structures you're going to accept return at all the public entry-points of your library or application. That's your API design. It's kind of like web APIs returning JSON

Re: Data vs API

2012-05-02 Thread kovas boguta
Can you give an example of how your data structure changes? Getters and setters are only a problem when they come baked into your datastructure, as the only way to access the contents. If you require more custom getting/setting logic than the built-in datastructures provide, you can always just

Re: question with macro!

2012-05-02 Thread Joop Kiefte
randomly-fn reads the commands first (that's why you need a macro in the first place) so it prints 1 2 and 3 straight away. If you really need a function, use lambdas (as in #(print 1) #(print 2) #(print 3)) 2012/5/2 金山 si262...@gmail.com I defined a macro like this: (defmacro randomly [

Re: Data vs API

2012-05-02 Thread kovas boguta
A nice example of this in clojure is ring: https://github.com/mmcgrana/ring The essence of it is what keys are present in the request/response maps, laid out here https://github.com/mmcgrana/ring/blob/master/SPEC On Wed, May 2, 2012 at 3:27 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote:

Re: [ANN] Leiningen 2.0.0-preview3

2012-05-02 Thread Stuart Sierra
Just want to say thanks to Phil and everyone else who has contributed to Leiningen. It's been pleasing to see the evolution from a limited script to a solid development tool. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: [ANN] Leiningen 2.0.0-preview3

2012-05-02 Thread Jim - FooBar();
On 02/05/12 20:56, Stuart Sierra wrote: Just want to say thanks to Phil and everyone else who has contributed to Leiningen. It's been pleasing to see the evolution from a limited script to a solid development tool. -S -- You received this message because you are subscribed to the Google

Re: question with macro!

2012-05-02 Thread thomas
the arguments to randomly-fn are evaluated before the macro-expansion of randomly kicks in. (that's what macros are for: control if, where and how often an expression is evaluated) So why would you need randomly-fn anyway? You can just write randomly (print 1) (print 2) (print 3)) and this

infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();
Hey everyone, I've been trying all morning (more than 3 hours) to improve my macro but with little success...basically what I had before i started fiddling with it was a macro which would take an expression of the form (1 + 4 * 5 - 1 / 2) and would return the expression in prefix form: (/ (-

Re: Data vs API

2012-05-02 Thread Stuart Halloway
I've read in some recent posts that Clorujians prefer data to APIs. I'm not sure I understand what this means, in practice. When I'm in the early stages of developing an application, the data structures undergo a great deal of change. One of the ways, I isolate parts of the code from

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Aaron Cohen
On Wed, May 2, 2012 at 4:24 PM, Jim - FooBar(); jimpil1...@gmail.comwrote: Hey everyone, I've been trying all morning (more than 3 hours) to improve my macro but with little success...basically what I had before i started fiddling with it was a macro which would take an expression of the

Re: Clojurescript long polling questions

2012-05-02 Thread Daniel Renfer
I think your issue is, you say you want long polling, but it seems like what you're looking for is more of HTTP streaming. The result channel you get in the aleph handler is set up to receive only a single message and then close. If you want a streaming response, create a new channel and a request

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();
On 02/05/12 21:33, Aaron Cohen wrote: (if-not (empty? (filter #(list? %)) '~expr)) This looks suspicious. filter is being called with 1st parameter anon function, and no second parameter. How does that compile? I apologise for the typo...it was originally (filter (fn [k] (list? k))

Re: New release of Domina (now with reworked eventing)

2012-05-02 Thread David Nolen
Michal Marczyk submitted a patch - should be fixed in master. David On Sat, Apr 28, 2012 at 3:26 PM, Luke VanderHart luke.vanderh...@gmail.comwrote: Yep, still happens against master. Trying to reduce it to a simpler test case now (and also see if it still happens when I take lein-cljsbuild

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Sam Ritchie
Hey Jim, what do you think of something like this? (defmacro infix-prefix [form] (loop [[a op b more :as form] form] (if (not op) a (recur (cons (list op a b) more) This transforms the list by plucking off three items at a time, rearranging them into prefix notation then

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Alex Baranosky
Nice one Sam. I think you could add order of operations by transforming the form in multiple passes. First /, then *, then + and -. Not the most efficient solution but a start. Alex On Wed, May 2, 2012 at 6:14 PM, Sam Ritchie sritchi...@gmail.com wrote: Hey Jim, what do you think of

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();
Hmm, it does look neater with destructuring i have to admit, but it won't handle nested parens will it? basically we 're doing the same thing - mine is just more verbose and self-explanatory. what to do next though? how do you expose all nested parens to the reader and feed the result value

Interaction of map-R and AOT compilation

2012-05-02 Thread Edmund
Hi Folks, It seems that map-R returns different types in the presence/absence of AOT classes. I have constructed a minimal example here: https://github.com/ejackson/aotquestion The namespace in https://github.com/ejackson/aotquestion/blob/master/src/aots/core.clj is not AOT compiled and

[ANN] lein-license 0.1.0

2012-05-02 Thread Phil Hagelberg
Hello folks. I just released a Leiningen plugin that walks your dependencies and lists the licenses of each. You can see the output below. This should be helpful for folks needing to do an audit on the licenses of their projects before releasing. It gets license information from the pom file,

How to handle dependencies on multiple versions of the same library?

2012-05-02 Thread Andy Fingerhut
I haven't actually run across this before, but I suspect someone else has. I was curious how people handle it. Suppose you have your project A, and it uses Leiningen (the issue is more widely applicable, but for the sake of example). * A depends on some version of library B, which in turn

Re: Data vs API

2012-05-02 Thread Takahiro
I've read in some recent posts that Clorujians prefer data to APIs.  I'm not sure I understand what this means, in practice.  When I'm in the early stages of developing an application, the data structures undergo a great deal of change.  One of the ways, I isolate parts of the code from these

Re: Leiningen-noobie question

2012-05-02 Thread Larry Travis
Phil: I now can't get the behavior to reproduce either. I have no idea what kind of dumb mistake I was making in the first place, and I'm very sorry to have wasted your time. (For what it's worth, both dependency-vector versions work in my reproduction attempts -- but you probably already

How to handle dependencies on multiple versions of the same library?

2012-05-02 Thread kurtharriger
OSGI is one way to solve this problem, but it is rarely worth the effort. It requires adding lots of meta data to every dependency which only a few major libraries actually provide. There are some tools to help with this process but they dont generally work with dynamic languages. Honestly,

what is js/ in clojurescript?

2012-05-02 Thread Rob
Hi, Syntax like this doesn't work in normal Clojure, right? js/document.body.style It just did in a ClojureScript repl. Is there something magic about js/ ? What is it? thanks, Rob -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: what is js/ in clojurescript?

2012-05-02 Thread Tamreen Khan
A quick explanation is that functions/other javascript objects that otherwise exist in the global namespace (ie. document, console, window) are accessed through the js/ in Clojurescript. This is a JS-specific thing and therefore you don't find js/ in regular Clojure. However, doing the form

Re: question with macro!

2012-05-02 Thread Qiu Xiafei
all function arguments will be evaluated so, 123 was printed On Thu, May 3, 2012 at 4:06 AM, thomas thomas.ka...@googlemail.com wrote: the arguments to randomly-fn are evaluated before the macro-expansion of randomly kicks in. (that's what macros are for: control if, where and how often

Re: what is js/ in clojurescript?

2012-05-02 Thread Rob
On Thursday, May 3, 2012 12:17:03 AM UTC-4, Tamreen Khan (Scriptor) wrote: However, doing the form (MyClass/MyStaticMethod arg1 arg2 ...) *does* exist in Clojure. It's a way of calling static Java methods or accessing static fields. See http://clojure.org/java_interop for more info.

Re: Using dynamic variables in libraries [Re: ANN clojure.java.jdbc 0.2.0]

2012-05-02 Thread Sean Corfield
Sorry for the slow response - we've been wrapped up in a gigantic data migration at work... On Tue, May 1, 2012 at 4:26 AM, Wolodja Wentland babi...@gmail.com wrote: It certainly does, but I am none the wiser. I always had the feeling/impression that dynamic variables are something to be

In clojurescript (extend-protocol undefined ...) should be error?

2012-05-02 Thread Rob
This should probably throw something, right? (extend-protocol undefined js/Text (foo [x] x)) I had mis-typed the name of the protocol and I didn't get an error until later. ( Is it helpful to post things like this here? I'm trying out Clojurescript and I can post possible bugs as I find

Re: Leiningen-noobie question

2012-05-02 Thread Sean Corfield
On Wed, May 2, 2012 at 5:44 PM, Larry Travis tra...@cs.wisc.edu wrote: I now can't get the behavior to reproduce either.  I have no idea what kind of dumb mistake I was making in the first place, and I'm very sorry to have wasted your time. (For what it's worth, both dependency-vector versions