Re: JSON library for clojure 1.3

2011-08-02 Thread OGINO Masanori
> FWIW, many functions from c.c.string were migrated to the core clojure.string > namespace starting in Clojure v1.2.0 Indeed but others aren't there yet. Will the rest be migrated in clojure.string until 1.3 release date? If not, probably we need modular c.c.string for performance-sensitive code

Re: Trying to understand performance of two simple functions

2011-08-02 Thread yair
I suspect this is because concat-ing is more expensive than cons-ing for non-vectors... On Aug 3, 11:25 am, Mark Feeney wrote: -- 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 po

Re: java.lang.StackOverflowError when calling function name instead of recur

2011-08-02 Thread yair
To add a bit to this, the JVM does not support tail call recursion. As I understand it, Clojure compiles into bytecode that effectively turns the recurs into an iterative process. Scala does something similar but automatically (i.e. you don't have to use a specific keyword). The advantage to Cloj

Trying to understand performance of two simple functions

2011-08-02 Thread Mark Feeney
Hi, all. A while ago I came across this SO question: Best way to lazily collapse multiple contiguous items of a sequence into a single item Long story short, I posted an

Re: Slow static file handing with lein ring server

2011-08-02 Thread sailormoo...@gmail.com
Hi : Thanks for the reply. The entire page costs about 5 seconds loading about 40 pictures with each picture about 3K. And when I put the pictures under some static web server (Nginx), the picture loading time is down to 0.4 seconds, while the main page (compojure/ring/enlive) costs still

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Mark
The compiler might not be able to do better but the runtime system certainly could. In this case, both filtered and more information is what's needed. Why couldn't the runtime generate a message like: Symbol "fac" of type clojure.lang.IFn is used where type java.lang.Number is expected in #2 o

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Luc Prefontaine
I've been coding in Clojure since mid-2008, I have a Lisp background but coded mainly in Java for a number of years (2000-2010) I still goof from time to time with parenthesis. Just yesterday, I screwed up some expression imbrication in a module and it took me at least 30 mns to figure it out. Ok

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Lee Spector
On Aug 2, 2011, at 8:23 PM, Armando Blancas wrote: > Check out the work of Warren Teitelman on > Conversational LISP and Do What I Mean, way back when most in this > board weren't even born. CLISP could handle your typo, > unsympathetically called "careless" in the paper; oh, well... Ah, INTERLIS

Re: java.lang.StackOverflowError when calling function name instead of recur

2011-08-02 Thread Brent Millare
To be even more pedantic, clojure does not guarantee that tail calls will be optimized. This is due to the lack of support in many of the jvm implementations. There is a post on using avian, a jvm implementation that supports TCO, that allows clojure to support TCO with little modification. http://

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Brent Millare
The following code may prove useful as well. (defmacro log "for debugging, output code and code->val to stdout or optional writer, returns val, custom-fn accepts two arguments, the code, and the result, it must return a string" ([code] `(let [c# ~code] (prn '~code) (clojur

Re: clojurescript additional js dependencies

2011-08-02 Thread Luc Prefontaine
Hi Rich, Zero footprint ? If you ever approach that goal I suggest a name change like ClojureRTA (Clojure Running on Thin Air:)) Luc P. On Tue, 2 Aug 2011 20:25:43 -0400 Rich Hickey wrote: > That said, it is our intention to look at minimizing the base > footprint as far as we can, but that's

Re: clojurescript additional js dependencies

2011-08-02 Thread Rich Hickey
That said, it is our intention to look at minimizing the base footprint as far as we can, but that's not top priority at the moment. It is unlikely we can get all the way to zero, but I hope we can do better. Until then, we won't compare favorably on very small programs. But the fact is the core

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Armando Blancas
> It's encouraging to see the community is thinking of > ways to improve this. We shouldn't, however, expect any significant improvements, IMO. For the reasons explained, and the fact that lisp has almost no syntax, this is a difficult problem to solve. Not that it has prevented people from trying

Re: clojurescript additional js dependencies

2011-08-02 Thread Luc Prefontaine
28k after gclosure compilation is not insane considering that cljs.core is above 350K. ClojureScript needs some runtime code afterall and that at some point cannot get compressed/slashed away endlessly. ClojureScript will take some footprint but the gclosure compiler does a great job here to sli

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread recurve7
Hi Jeremy, I'm not just thinking about Clojure from the perspective of a Java person, but also from the perspective of someone new to programming and for kids. For the latter, it's best if languages have maximum friendliness in error wording and error messages pointed at a specific character posit

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread recurve7
Thank you, Ken. It's encouraging to see the community is thinking of ways to improve this. On Aug 2, 6:39 am, Ken Wesson wrote: > On Tue, Aug 2, 2011 at 3:11 AM, recurve7 wrote: > > Here's one example where recursion and lack of positional error > > feedback make it hard for me, as someone comin

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread recurve7
Thanks for the replies. I see 1.3 Beta 1 provides some more Java context that helps me find the problem, although it still doesn't afford Clojure its own uniquely-searchable error system or positional error references. On Aug 2, 6:31 am, Sergey Didenko wrote: > It got improved a lot in Clojure 1.

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Sean Corfield
On Tue, Aug 2, 2011 at 12:11 AM, recurve7 wrote: > user=> (defn fac [n] (if (= n 1) 1 (* n fac (- n 1 > #'user/fac > user=> (fac 3) > java.lang.ClassCastException: user$fac cannot be cast to > java.lang.Number (NO_SOURCE_FILE:0) > Let's assume you'd put the code in a source file and run that

Re: java.lang.StackOverflowError when calling function name instead of recur

2011-08-02 Thread David Nolen
On Tue, Aug 2, 2011 at 4:43 PM, Trastabuga wrote: > I just came across the issue of getting the StackOverflowError in the > function reading long file and recursively building a list of data. > After I replaced function name with "recur" the problem went away. > Hence a couple of questions. It's

java.lang.StackOverflowError when calling function name instead of recur

2011-08-02 Thread Trastabuga
I just came across the issue of getting the StackOverflowError in the function reading long file and recursively building a list of data. After I replaced function name with "recur" the problem went away. Hence a couple of questions. It's the programmer's responsibility to put recur instead of func

Re: JSON library for clojure 1.3

2011-08-02 Thread Chas Emerick
On Aug 1, 2011, at 6:49 PM, OGINO Masanori wrote: >> Similar question: where is clojure.contrib.string for 1.3? > +1 > > http://dev.clojure.org/display/design/Contrib+Library+Names > c.c.string is not included in this list. > Is there any plans to go to modular contrib (string.incubator, > tools

Re: ClojureScript Presentation - video

2011-08-02 Thread Bill Robertson
Didn't for me. I was pretty surprised. On Aug 2, 10:05 am, Claudia Doppioslash wrote: > > Trying to get the avi to play on the mac... > > vlc? Works for me :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: ClojureCLR NotImplementedException

2011-08-02 Thread dmiller
It is the same for ClojureCLR. -David On Aug 2, 8:22 am, "Meikel Brandmeyer (kotarak)" wrote: > Hi, > > Am Dienstag, 2. August 2011 11:03:31 UTC+2 schrieb Ralph Moritz: > > > > >     (defn details [] > >       (let [hash (System.Collections.Hashtable.)] > >         (doto hash > >           (. Ad

Aw: Re: How to import and use an enum enclosed in an java interface?

2011-08-02 Thread finbeu
This works also! thx a lot. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from thi

Aw: Re: How to import and use an enum enclosed in an java interface?

2011-08-02 Thread finbeu
Works! Ken, thx. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group,

Re: Problem calling third-party library from ClojureScript code when advanced optimization used

2011-08-02 Thread Alen Ribic
Just to add to this. The part that sticks out to me is the way I call the third-party library function. It screams at me with a big NO, (js* "new Showdown.converter().makeHtml(~{b-txt},~{safe})"). Perhaps I should declare (def showdown (js* "Showdown")) and then work my way through the host intero

Re: JSON library for clojure 1.3

2011-08-02 Thread Vincent
yes ..it is working / great Thanks a lot Vincent -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To

Problem calling third-party library from ClojureScript code when advanced optimization used

2011-08-02 Thread Alen Ribic
I have the following function in my cljs that is bound to a click event. It makes a call to an external library via js* as seen in the last body form of the preview function. (defn preview [] (let [body-el(dom/getElement "body_id") preview-el (dom/getElement "preview_pane") b

Re: ClojureScript Presentation - video

2011-08-02 Thread Claudia Doppioslash
> Trying to get the avi to play on the mac... vlc? Works for me :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with y

Re: Including additional js in clojurescript compilation

2011-08-02 Thread Mark Rathwell
Some basic information and tips (start at page 5 or so on [1]): [1] http://dojo-toolkit.33424.n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t [2] http://code.google.com/closure/compiler/docs/api-tutorial3.html#dangers On Tue, Aug 2, 2011 at 7:59 AM, A

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Jeremy Heiler
On Tue, Aug 2, 2011 at 3:11 AM, recurve7 wrote: > Here's one example where recursion and lack of positional error > feedback make it hard for me, as someone coming from Java, to spot the > error (and seeing "ClassCastException" threw me off and had me > wondering where/how I had done something lik

Re: How to import and use an enum enclosed in an java interface?

2011-08-02 Thread Meikel Brandmeyer (kotarak)
Hi, and with import: (import 'com.api.test.Foo$BarType) (.theMethod myObject Foo$BarType/One) Sincerely Meikel -- 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 me

Re: How to import and use an enum enclosed in an java interface?

2011-08-02 Thread Ken Wesson
On Tue, Aug 2, 2011 at 9:37 AM, finbeu wrote: > Hello, > > how do I have to use an enum in clojure that is enclosed in an java > interface? I decomplied it in IDEA and I got something like that: > > package com.api.test; > > public interface Foo { >     . >     . >     static final enum Ba

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Ken Wesson
On Tue, Aug 2, 2011 at 3:11 AM, recurve7 wrote: > Here's one example where recursion and lack of positional error > feedback make it hard for me, as someone coming from Java, to spot the > error (and seeing "ClassCastException" threw me off and had me > wondering where/how I had done something lik

How to import and use an enum enclosed in an java interface?

2011-08-02 Thread finbeu
Hello, how do I have to use an enum in clojure that is enclosed in an java interface? I decomplied it in IDEA and I got something like that: package com.api.test; public interface Foo { . . static final enum BarType { public static final ONE, public static final TWO

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Sergey Didenko
It got improved a lot in Clojure 1.3 which is beta for a while. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your

Re: ClojureCLR NotImplementedException

2011-08-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 2. August 2011 11:03:31 UTC+2 schrieb Ralph Moritz: > > (defn details [] > (let [hash (System.Collections.Hashtable.)] > (doto hash > (. Add "Name" "Ralph") > (. Add "Age" 27)) > hash)) > > > (gen-class :name "ClrExperiments.

Re: Published a library for archive handling.

2011-08-02 Thread Andreas Liljeqvist
Thanks for noticing. I designed it with more or less that flow in mind. In my own project I use pacl to rescale images from archives and then write them to new archives. Only touching the disk when writing the final archive. 2011/8/2 Eric Lavigne > I like that both its packing and unpacking fu

Re: character encoding issue in compiled .js

2011-08-02 Thread HaiColon
I've encountered this problem too, on Ubuntu 11.04 with Emacs 23.2.1 and the ClojureScript repo cloned with Git 1.7.4.1. For me, using a meta tag doesn't resolve the problem though. Without a meta tag that sets the encoding to UTF-8, an i with two dots above it is diplayed. With the meta tag added

ClojureCLR NotImplementedException

2011-08-02 Thread Ralph Moritz
I can compile the following simple program, but when I try to run it I get an error: Unhandled Exception: System.NotImplementedException: details at ClrExperiments.Employee.details() at ClojureClrExperiment.Program.Main() Here is the Clojure code: (ns clr-experiments.core

New to Clojure -- Errors Are Frustrating

2011-08-02 Thread recurve7
In browsing this group I see this topic has been brought up several times over the past 3 years, so I apologize for revisiting it. I just downloaded Clojure and was excited to try it, but so far trying to move beyond simple examples has often resulted in me making a mistake that yields a Java exce

Re: Convert Map to string for use in URL as parameters question

2011-08-02 Thread Brad
Great. Encoding the parameters was the next thing to figure out. Thank you. On Aug 2, 12:51 am, Matjaz Gregoric wrote: > Depending on your input, you might also want to make sure to properly > urlencode the keys and values. > There is a function in hiccup that does what you want (including > urle

Re: Convert Map to string for use in URL as parameters question

2011-08-02 Thread Brad
Thanks. This is much more succinct. On Aug 2, 12:19 am, Sean Corfield wrote: > On Mon, Aug 1, 2011 at 3:47 PM, Brad wrote: > > ;; My test input map > > (def input {:a 1 :b 2 :c 3 :d 4}) > ... > > Is there a simpler, better way to do this? > > How about: > > (require '[clojure.string :as str]) >

Re: Including additional js in clojurescript compilation

2011-08-02 Thread Alen Ribic
> Any Google Closure compliant JavaScript can be pulled into the build > process by using the :libs option. Is there any information/resource on what makes the Javascript library Google Closure compliant? I have a third-party library that I have included via {:libs []} option, however it doesn't

Re: Best Way To Remove vector from vector of vectors?

2011-08-02 Thread octopusgrabbus
Got it. I'll go make up different test data; I do get back strings. Thanks. On Aug 2, 7:51 am, "Meikel Brandmeyer (kotarak)" wrote: > Hi, > > Am Dienstag, 2. August 2011 13:48:33 UTC+2 schrieb Ken Wesson: > > > What are you actually wanting to check the integers for? Being zero? > > There's a fun

Re: Best Way To Remove vector from vector of vectors?

2011-08-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 2. August 2011 13:48:33 UTC+2 schrieb Ken Wesson: > What are you actually wanting to check the integers for? Being zero? > There's a function named "zero?" for that. > I rather suspect, that he gets back strings from his CSV code, but manually tested with numbers. Sincerely Mei

Re: Best Way To Remove vector from vector of vectors?

2011-08-02 Thread Ken Wesson
On Tue, Aug 2, 2011 at 7:42 AM, octopusgrabbus wrote: > I'm having trouble with the suggested fix (shortened function name for > testing). > > Here is some test data: > (def vv1 [[49 48 47 46 nil 1 2 3 4][5 6 7 8 9 10 11 12 13]]) > > (defn f1 >  [all-csv-rows] >  (let [clean-rows (vec (filter #(an

Re: Best Way To Remove vector from vector of vectors?

2011-08-02 Thread octopusgrabbus
I'm having trouble with the suggested fix (shortened function name for testing). Here is some test data: (def vv1 [[49 48 47 46 nil 1 2 3 4][5 6 7 8 9 10 11 12 13]]) (defn f1 [all-csv-rows] (let [clean-rows (vec (filter #(and (pos? (count %)) (not (cstr/ blank? (nth % 5 nil all-csv-rows)

Re: clojurescript advanced compile error

2011-08-02 Thread David Powell
On Mon, Aug 1, 2011 at 5:10 PM, Tero Parviainen wrote: > This is a known "feature" with Closure templates: > http://code.google.com/p/closure-templates/issues/detail?id=25 > > The Closure compiler does name replacement on the template parameters, > so that after the compilation the argument names

Re: Predicate problem

2011-08-02 Thread Petr Gladkikh
On Tue, Aug 2, 2011 at 4:27 PM, Stefan Kamphausen wrote: > Hi, > > can't you just use the set itself as the function determining whether the > items contains the ID. Set-as-function was the first thing I tried but it did not work either. Based on my tweaking, type mismatch is more likely the prob

Re: Predicate problem

2011-08-02 Thread Stefan Kamphausen
Hi, can't you just use the set itself as the function determining whether the items contains the ID. The following example uses just a vector of maps for the new-states and thus uses -> instead of .. but it seems to work user=> (def pinned-ids #{200, 210}) #'user/pinned-ids user=> (def new-

Re: clojurescript additional js dependencies

2011-08-02 Thread Sergey Didenko
Yes, after compiling this example and its raw Google Closure equivalent: (ns bgcolor (:require [goog.fx.dom :as fx-dom])) (defn ^:export animate [elem start end] (let [ anim (fx-dom/BgColorTransform. elem start end 2000)] (.play anim ( After compilation through the Google co

Re: Predicate problem

2011-08-02 Thread Oskar Kvist
I'm stupid today... I meant: (contains? #{(int 1)} (long 1)) false On Aug 2, 10:19 am, Oskar Kvist wrote: > Btw, that should be fixed in 1.3 I think. > > On Aug 2, 10:18 am, Oskar Kvist wrote: > > > > > > > > > Sorry, didn't read your post properly. Maybe it's because the ints are > > of differ

Re: Predicate problem

2011-08-02 Thread Oskar Kvist
Btw, that should be fixed in 1.3 I think. On Aug 2, 10:18 am, Oskar Kvist wrote: > Sorry, didn't read your post properly. Maybe it's because the ints are > of different types. > > (contains? [(int 1)] (long 1)) > false > > On Aug 2, 10:13 am, Oskar Kvist wrote: > > > > > > > > > "Returns true if

Re: Predicate problem

2011-08-02 Thread Oskar Kvist
Sorry, didn't read your post properly. Maybe it's because the ints are of different types. (contains? [(int 1)] (long 1)) false On Aug 2, 10:13 am, Oskar Kvist wrote: > "Returns true if _key_ is present in the given collection, otherwise > returns false." > > For sets like #{200, 210} the values

Re: Predicate problem

2011-08-02 Thread Oskar Kvist
"Returns true if _key_ is present in the given collection, otherwise returns false." For sets like #{200, 210} the values also count as keys. On Aug 2, 10:10 am, Petr Gladkikh wrote: > I spent hour already and can not understand what is wrong here. > > I want to filter collection based on a nest

Predicate problem

2011-08-02 Thread Petr Gladkikh
I spent hour already and can not understand what is wrong here. I want to filter collection based on a nested field of collection element having some value: (println pinned-ids) ; #{200, 210} (println (contains? pinned-ids 200)) ; true (println (map #(.. % :field :id) new-states)) ; (10 20 21 1