Re: [ClojureScript] ANN: ClojureScript 0.0-2719, JavaScript Dependencies

2015-01-26 Thread Laurent PETIT
Yet ?

Le lundi 26 janvier 2015, David Nolen  a écrit :

> Webjars doesn't package JS libs in a useful way for ClojureScript.
>
> On Sunday, January 25, 2015, Ivan L  > wrote:
>
>> To this end I would hope everyone takes a look at using webjars.org as
>> their source for frontend libraries.  imo, it's a way forward to dep mgmt
>> outside of bower/npm/node etc.
>>
>> On Sunday, January 25, 2015 at 2:42:54 PM UTC-5, David Nolen wrote:
>>>
>>> I strongly recommend the Clojure(Script) community join forces when
>>> packaging libraries to avoid duplicated effort and dependency conflicts.
>>>
>>> CLJSJS seems like a good initiative to me along these lines:
>>> http://cljsjs.github.io
>>>
>>> David
>>>
>>> On Sun, Jan 25, 2015 at 1:49 PM, Vladimir Bokov 
>>> wrote:
>>>
 Thanks David!

 I also already packaged https://github.com/razum2um/jquery-cljs using
 your react repo as example

 суббота, 24 января 2015 г., 21:10:29 UTC+6 пользователь David Nolen
 написал:

> ClojureScript, the Clojure compiler that emits JavaScript source code.
>
> README and source code: https://github.com/clojure/clojurescript
>
> New release version: 0.0-2719
>
> Leiningen dependency information:
>
> [org.clojure/clojurescript "0.0-2719"]
>
> ClojureScript is not an island, like Clojure on the JVM, ClojureScript
> embraces the many benefits provided by the host. However this goal
> has been hampered by another goal - the compilation stragey. Google
> Closure Compiler offers superior optimization and minification for
> ClojureScript while simultaneously making it considerably more
> difficult to integrate non-Closure compatible libraries. Using popular
> libraries like jQuery, React or D3 is an error prone process: "which
> extern did I forget?", "which script tag did I miss for development?",
> "are these script tags in dependency order?".
>
> No more. 0.0-2719 delivers full support for non-Closure compatible
> libraries through some less known features that have been lurking
> around for almost three years - `deps.cljs` and the :foreign-libs
> compiler option.
>
> `deps.cljs` is a simple EDN file provided at the root of a JAR that
> describes additional build information for the ClojureScript
> compiler. For example here is the `deps.cljs` for the React JAR I
> maintain:
>
> {
>  :foreign-libs [{:file "react/react.js"
>  :file-min "react/react.min.js"
>  :provides ["com.facebook.React"]}
> {:file "react/react_with_addons.js"
>  :file-min "react/react_with_addons.min.js"
>  :provides ["com.facebook.ReactWithAddons"]}]
>  :externs ["react/externs/react.js"]
> }
>
> This file provides all the information ClojureScript needs to
> correctly manage the foreign dependency for you under all compilation
> modes and REPLs.
>
> In a REPL:
>
>cljs.user> (require 'com.facebook.React)
>cljs.user> (. js/React
> (renderToString
>   (. js/React (DOM.div nil "Hello!"
>
> In your project:
>
>(ns foo.bar
>  (:require com.facebook.React))
>
>(enable-console-print!)
>
>(println
>  (. js/React
>(renderToString
>  (. js/React (DOM.div nil "Hello!")
>
> The above works under all compilation modes. There is no need to
> include React as a script tag under development, there is no need to
> put
> script tags in dependency order, there is no need to add React to
> :preamble under :advanced, and there is no need to explicitly provide
> :externs.
>
> All that is required is that JavaScript libraries be packaged in JARs
> with a `deps.cljs`.
>
> Some of you might reasonably ask why not a tool like Bower for this
> instead?  Bower requires an additional dependency on Node.js. While
> ClojureScript embraces Node.js as a useful target it is not a
> requirement to be productive. Bower manages dependencies, but in the
> Clojure world we have already embraced Maven for this task and have
> done the same for ClojureScript. Finally Bower does not address the
> problem of loading libraries at runtime. This is challenging to do -
> some JavaScript libraries adopt CommonJS, some AMD, and the most
> popular ones make no assumptions at all allowing users to simply use
> script tags as they have done for nearly two decades. The above
> solution addresses the issue for all ClojureScript users by
> eliminating paralysis of choice. Finally none of the above
> precludes Bower usage in any way whatsoever.
>
> This new feature addresses a long outstanding pain point with
> ClojureScript development. All that is required is that we tak

Re: Copy binary files in leiningen template

2015-01-26 Thread Sven Richter
After searching through github I found this method unpack: 
https://github.com/tailrecursion/hlisp-template/blob/65b89bd257eca86c4ce76b82066a0b059323cdfb/src/leiningen/new/hlisp.clj
 
which does the trick.

In the end it manually copies from the jar file to a local folder. I wonder 
if there is a simpler way to do this?

Thanks,
Sven

Am Sonntag, 25. Januar 2015 23:34:27 UTC+1 schrieb Sven Richter:
>
> Hm, I don't understand this, it seems like everyone is doing it like this:
>
> https://github.com/stammi/slides2-lein-template/blob/97c2df63b3fbddf0b09e8b501efce75ef4cb233e/src/leiningen/new/slides2_lein_template.clj
>  
> (l. 15)
> And I get a copied file when I do that in my new application, but I cannot 
> open it. It is not recognized as a gif file.
>
> Any Ideas what might be wrong here?
>
> You can find the complete source here: 
> https://github.com/sveri/closp/blob/master/src/leiningen/new/closp.clj
>
> Thanks,
> Sven
>
> Am Sonntag, 25. Januar 2015 18:18:10 UTC+1 schrieb Sven Richter:
>>
>> Hi,
>>
>> I am creating a new leiningen template. Now I do have a binary file (gif) 
>> which I want to copy.
>>
>> I tried several things like:
>>
>> ["resources/public/img/browser_carousel_small.jpg" (io/resource 
>> "loading.gif")] for instance, but none of it worked.
>> Sometimes I got it copied, but it was not readable as an image and could not 
>> be opened.
>>
>> What is the correct way to copy binary files within a leiningen template?
>>
>> Thanks,
>> Sven
>>
>>
>>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ClojureScript] ANN: ClojureScript 0.0-2719, JavaScript Dependencies

2015-01-26 Thread David Nolen
On Mon, Jan 26, 2015 at 3:08 AM, Laurent PETIT 
wrote:

> Yet ?


Right if Webjars was open to including the necessary information that would
be great. I suspect this will be challenging since Webjars has chosen
RequireJS as the runtime loading mechanism whereas deps.cljs provides
Google Closure runtime dependency information for a specific compile to
JavaScript language.

Likely the most promising way to integrate Webjars is to extract Google
Closure information from the RequireJS file located in RequireJS supporting
JARs. This processing could be performed by other tools like cljsbuild.

Still I have concerns about ClojureScript discoverability and Webjars - "is
this Webjar fully ClojureScript compatible?".

David

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Hi I am a new user of clojure ,I am not being able to use lein

2015-01-26 Thread Bis
I am trying from some time but cant install lein.

Tried with the MSI installer and it finishes properly but no repl is 
created neither lein
tried with lein.bat ,getting errors everytime ,
"Exception calling Downloadfile with two arguement.the remote server 
returned an error 403 forbidden.(set http client to "wget" and tried also 
,btw lein.bat is taken from the official site so not sure if the official 
version of the bat file is trying to get some unstable release or not )
tried with chocolatey but chocolatey tries to install JDK 7 and its failing 
,although I have JDK8 in my system 
Please some one help to debug ,I am getting frustrated 

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


lein discovery issues

2015-01-26 Thread andrea crotti
Hello everyone

A couple of questions about Lein and how to find templates/libraries.

I found out now that "lein search" allows me to search for the last
stable version of a library, however every time I run it it takes
forever downloading the index:

Downloading 
https://repo1.maven.org/maven2/.index/nexus-maven-repository-index.gz

Is that normal and if yes how can I make it usable?

Then if I want to find out the correct version of clojurescript I go to Clojars:
https://clojars.org/search?q=clojurescript

And there I find a lot of things but  none of them seems the correct
thing, this is probably not the right thing:
https://clojars.org/clojurescript

I also noticed that many things in clojars don't have code available or
links to the project, how am I supposed to know what they are actually
useful for if there is no Readme/Source code or any other information?

And the last thing is that it would be interesting to see all the
possible project templates that can be used with a "lein new", but from
what I can understand it depends on the plugins that are currently
installed with lein, is that correct?

Thanks a lot,
Andrea

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple procedure for updating a value one level down

2015-01-26 Thread Erik Price
Many functions that affect keyed collections will work on vectors if you
supply the numeric index as a key.

e

On Monday, January 26, 2015, Josh Stratton  wrote:

> I'm new to clojure and FP in general.  One thing that has always been a
> little confusing for me is working with immutable trees.  I have a vector
> of categories, each category containing a vector of items--each one a
> hashmap.  In that hashmap I have a bunch of attributes including an
> item-id.  Now, assuming I have an item id, what's the easiest way to update
> the appropriate hashmap?  I can't use an assoc, I believe, because my data
> is in a vector--not keyed by the id.
>
> What I have been doing is writing a function that maps the categories to
> new categories and then write another function that is called on every item
> and updates it iff the item id matches.  This works, but it seems really
> clunky and I'm assuming there's a simpler way to do it.
>
> ; categories is a vector of item vectors, where the item is a hash
> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [
> { :id 3 :age 7 } ] ])
>
> Is there a more elegant workflow for updating categories?  Let's say I
> want to update item of id 3 with { :age 12 :somethingElse 29 }, what's the
> easiest way to do this?
>
> ; so the return would be
> [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3 :age 12
> :somethingElse 29 } ] ]
>
> --
> 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, send email to
> clojure+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple procedure for updating a value one level down

2015-01-26 Thread Michael Willis
(def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ 
{ :id 3 :age 7 } ] ])
#'user/categories
(update-in categories [1 0] merge { :age 12 :somethingElse 29 })
[[{:text "foo", :id 1} {:text "bar", :ack 5, :id 2}] [{:age 12, 
:somethingElse 29, :id 3}]]


On Monday, January 26, 2015 at 8:54:58 AM UTC-6, Erik Price wrote:
>
> Many functions that affect keyed collections will work on vectors if you 
> supply the numeric index as a key.
>
> e
>
> On Monday, January 26, 2015, Josh Stratton  > wrote:
>
>> I'm new to clojure and FP in general.  One thing that has always been a 
>> little confusing for me is working with immutable trees.  I have a vector 
>> of categories, each category containing a vector of items--each one a 
>> hashmap.  In that hashmap I have a bunch of attributes including an 
>> item-id.  Now, assuming I have an item id, what's the easiest way to update 
>> the appropriate hashmap?  I can't use an assoc, I believe, because my data 
>> is in a vector--not keyed by the id.  
>>
>> What I have been doing is writing a function that maps the categories to 
>> new categories and then write another function that is called on every item 
>> and updates it iff the item id matches.  This works, but it seems really 
>> clunky and I'm assuming there's a simpler way to do it.  
>>
>> ; categories is a vector of item vectors, where the item is a hash
>> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] 
>> [ { :id 3 :age 7 } ] ])
>>
>> Is there a more elegant workflow for updating categories?  Let's say I 
>> want to update item of id 3 with { :age 12 :somethingElse 29 }, what's the 
>> easiest way to do this?  
>>
>> ; so the return would be
>> [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3 :age 
>> 12 :somethingElse 29 } ] ]
>>
>> -- 
>> 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, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple procedure for updating a value one level down

2015-01-26 Thread Michael Willis
Now that I think about it, I wonder why your categories aren't keyed by id, 
like this:

(def categories [ {1 {:text "foo"} 2 {:text "bar" :ack 5}} {3 {:age 7}}])

Then the update-in can take the category id, instead of having to know its 
index within a vector:

(update-in categories [1 3]  merge { :age 12 :somethingElse 29 })
[{1 {:text "foo"}, 2 {:text "bar", :ack 5}} {3 {:age 12, :somethingElse 
29}}]


On Monday, January 26, 2015 at 9:42:56 AM UTC-6, Michael Willis wrote:
>
> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ 
> { :id 3 :age 7 } ] ])
> #'user/categories
> (update-in categories [1 0] merge { :age 12 :somethingElse 29 })
> [[{:text "foo", :id 1} {:text "bar", :ack 5, :id 2}] [{:age 12, 
> :somethingElse 29, :id 3}]]
>
>
> On Monday, January 26, 2015 at 8:54:58 AM UTC-6, Erik Price wrote:
>>
>> Many functions that affect keyed collections will work on vectors if you 
>> supply the numeric index as a key.
>>
>> e
>>
>> On Monday, January 26, 2015, Josh Stratton  wrote:
>>
>>> I'm new to clojure and FP in general.  One thing that has always been a 
>>> little confusing for me is working with immutable trees.  I have a vector 
>>> of categories, each category containing a vector of items--each one a 
>>> hashmap.  In that hashmap I have a bunch of attributes including an 
>>> item-id.  Now, assuming I have an item id, what's the easiest way to update 
>>> the appropriate hashmap?  I can't use an assoc, I believe, because my data 
>>> is in a vector--not keyed by the id.  
>>>
>>> What I have been doing is writing a function that maps the categories to 
>>> new categories and then write another function that is called on every item 
>>> and updates it iff the item id matches.  This works, but it seems really 
>>> clunky and I'm assuming there's a simpler way to do it.  
>>>
>>> ; categories is a vector of item vectors, where the item is a hash
>>> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] 
>>> [ { :id 3 :age 7 } ] ])
>>>
>>> Is there a more elegant workflow for updating categories?  Let's say I 
>>> want to update item of id 3 with { :age 12 :somethingElse 29 }, what's the 
>>> easiest way to do this?  
>>>
>>> ; so the return would be
>>> [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3 :age 
>>> 12 :somethingElse 29 } ] ]
>>>
>>> -- 
>>> 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, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple procedure for updating a value one level down

2015-01-26 Thread Josh Stratton
They're not keyed by id because order in both the category and its items is
important. I could maintain the order explicitly, but that just makes other
problems like reordering more difficult.

As a couple people have suggested I could access the page using vector
indexing, but then I'd need to figure out what those induces are for the
category and the page given the item id. That seems reasonable, but I'm not
sure the best way to do that. I'm sure there's some python enumerate
equivalent where I can map all categories and items and filter down just
the pair with the matching item id.
On Jan 26, 2015 7:47 AM, "Michael Willis"  wrote:

> Now that I think about it, I wonder why your categories aren't keyed by
> id, like this:
>
> (def categories [ {1 {:text "foo"} 2 {:text "bar" :ack 5}} {3 {:age 7}}])
>
> Then the update-in can take the category id, instead of having to know its
> index within a vector:
>
> (update-in categories [1 3]  merge { :age 12 :somethingElse 29 })
> [{1 {:text "foo"}, 2 {:text "bar", :ack 5}} {3 {:age 12, :somethingElse
> 29}}]
>
>
> On Monday, January 26, 2015 at 9:42:56 AM UTC-6, Michael Willis wrote:
>>
>> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ]
>> [ { :id 3 :age 7 } ] ])
>> #'user/categories
>> (update-in categories [1 0] merge { :age 12 :somethingElse 29 })
>> [[{:text "foo", :id 1} {:text "bar", :ack 5, :id 2}] [{:age 12,
>> :somethingElse 29, :id 3}]]
>>
>>
>> On Monday, January 26, 2015 at 8:54:58 AM UTC-6, Erik Price wrote:
>>>
>>> Many functions that affect keyed collections will work on vectors if you
>>> supply the numeric index as a key.
>>>
>>> e
>>>
>>> On Monday, January 26, 2015, Josh Stratton  wrote:
>>>
 I'm new to clojure and FP in general.  One thing that has always been a
 little confusing for me is working with immutable trees.  I have a vector
 of categories, each category containing a vector of items--each one a
 hashmap.  In that hashmap I have a bunch of attributes including an
 item-id.  Now, assuming I have an item id, what's the easiest way to update
 the appropriate hashmap?  I can't use an assoc, I believe, because my data
 is in a vector--not keyed by the id.

 What I have been doing is writing a function that maps the categories
 to new categories and then write another function that is called on every
 item and updates it iff the item id matches.  This works, but it seems
 really clunky and I'm assuming there's a simpler way to do it.

 ; categories is a vector of item vectors, where the item is a hash
 (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 }
 ] [ { :id 3 :age 7 } ] ])

 Is there a more elegant workflow for updating categories?  Let's say I
 want to update item of id 3 with { :age 12 :somethingElse 29 }, what's the
 easiest way to do this?

 ; so the return would be
 [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3 :age
 12 :somethingElse 29 } ] ]

 --
 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, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>  --
> 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, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are su

Re: simple procedure for updating a value one level down

2015-01-26 Thread Lucas Bradstreet
Given these points I would probably just do:

(defn update-val-with-id [values m]
(map (fn [v]
 (if (= (:id v) id)
 (merge v m)
  v))
  values))

I'm not that happy with it either, so other suggestions are welcome.

On 27 January 2015 at 00:06, Josh Stratton  wrote:
> They're not keyed by id because order in both the category and its items is
> important. I could maintain the order explicitly, but that just makes other
> problems like reordering more difficult.
>
> As a couple people have suggested I could access the page using vector
> indexing, but then I'd need to figure out what those induces are for the
> category and the page given the item id. That seems reasonable, but I'm not
> sure the best way to do that. I'm sure there's some python enumerate
> equivalent where I can map all categories and items and filter down just the
> pair with the matching item id.
>
> On Jan 26, 2015 7:47 AM, "Michael Willis"  wrote:
>>
>> Now that I think about it, I wonder why your categories aren't keyed by
>> id, like this:
>>
>> (def categories [ {1 {:text "foo"} 2 {:text "bar" :ack 5}} {3 {:age 7}}])
>>
>> Then the update-in can take the category id, instead of having to know its
>> index within a vector:
>>
>> (update-in categories [1 3]  merge { :age 12 :somethingElse 29 })
>> [{1 {:text "foo"}, 2 {:text "bar", :ack 5}} {3 {:age 12, :somethingElse
>> 29}}]
>>
>>
>> On Monday, January 26, 2015 at 9:42:56 AM UTC-6, Michael Willis wrote:
>>>
>>> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ]
>>> [ { :id 3 :age 7 } ] ])
>>> #'user/categories
>>> (update-in categories [1 0] merge { :age 12 :somethingElse 29 })
>>> [[{:text "foo", :id 1} {:text "bar", :ack 5, :id 2}] [{:age 12,
>>> :somethingElse 29, :id 3}]]
>>>
>>>
>>> On Monday, January 26, 2015 at 8:54:58 AM UTC-6, Erik Price wrote:

 Many functions that affect keyed collections will work on vectors if you
 supply the numeric index as a key.

 e

 On Monday, January 26, 2015, Josh Stratton  wrote:
>
> I'm new to clojure and FP in general.  One thing that has always been a
> little confusing for me is working with immutable trees.  I have a vector 
> of
> categories, each category containing a vector of items--each one a 
> hashmap.
> In that hashmap I have a bunch of attributes including an item-id.  Now,
> assuming I have an item id, what's the easiest way to update the 
> appropriate
> hashmap?  I can't use an assoc, I believe, because my data is in a
> vector--not keyed by the id.
>
> What I have been doing is writing a function that maps the categories
> to new categories and then write another function that is called on every
> item and updates it iff the item id matches.  This works, but it seems
> really clunky and I'm assuming there's a simpler way to do it.
>
> ; categories is a vector of item vectors, where the item is a hash
> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 }
> ] [ { :id 3 :age 7 } ] ])
>
> Is there a more elegant workflow for updating categories?  Let's say I
> want to update item of id 3 with { :age 12 :somethingElse 29 }, what's the
> easiest way to do this?
>
> ; so the return would be
> [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3 :age
> 12 :somethingElse 29 } ] ]
>
> --
> 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, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/opto

Re: simple procedure for updating a value one level down

2015-01-26 Thread Josh Stratton
This is my current solution. Again, it works fine, but seems a little
verbose. I have a function called update-item, which has to call
update-item-in-category with the same parameters plus the category I'm
currently mapping through.
On Jan 26, 2015 8:11 AM, "Lucas Bradstreet" 
wrote:

> Given these points I would probably just do:
>
> (defn update-val-with-id [values m]
> (map (fn [v]
>  (if (= (:id v) id)
>  (merge v m)
>   v))
>   values))
>
> I'm not that happy with it either, so other suggestions are welcome.
>
> On 27 January 2015 at 00:06, Josh Stratton 
> wrote:
> > They're not keyed by id because order in both the category and its items
> is
> > important. I could maintain the order explicitly, but that just makes
> other
> > problems like reordering more difficult.
> >
> > As a couple people have suggested I could access the page using vector
> > indexing, but then I'd need to figure out what those induces are for the
> > category and the page given the item id. That seems reasonable, but I'm
> not
> > sure the best way to do that. I'm sure there's some python enumerate
> > equivalent where I can map all categories and items and filter down just
> the
> > pair with the matching item id.
> >
> > On Jan 26, 2015 7:47 AM, "Michael Willis" 
> wrote:
> >>
> >> Now that I think about it, I wonder why your categories aren't keyed by
> >> id, like this:
> >>
> >> (def categories [ {1 {:text "foo"} 2 {:text "bar" :ack 5}} {3 {:age
> 7}}])
> >>
> >> Then the update-in can take the category id, instead of having to know
> its
> >> index within a vector:
> >>
> >> (update-in categories [1 3]  merge { :age 12 :somethingElse 29 })
> >> [{1 {:text "foo"}, 2 {:text "bar", :ack 5}} {3 {:age 12, :somethingElse
> >> 29}}]
> >>
> >>
> >> On Monday, January 26, 2015 at 9:42:56 AM UTC-6, Michael Willis wrote:
> >>>
> >>> (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 }
> ]
> >>> [ { :id 3 :age 7 } ] ])
> >>> #'user/categories
> >>> (update-in categories [1 0] merge { :age 12 :somethingElse 29 })
> >>> [[{:text "foo", :id 1} {:text "bar", :ack 5, :id 2}] [{:age 12,
> >>> :somethingElse 29, :id 3}]]
> >>>
> >>>
> >>> On Monday, January 26, 2015 at 8:54:58 AM UTC-6, Erik Price wrote:
> 
>  Many functions that affect keyed collections will work on vectors if
> you
>  supply the numeric index as a key.
> 
>  e
> 
>  On Monday, January 26, 2015, Josh Stratton 
> wrote:
> >
> > I'm new to clojure and FP in general.  One thing that has always
> been a
> > little confusing for me is working with immutable trees.  I have a
> vector of
> > categories, each category containing a vector of items--each one a
> hashmap.
> > In that hashmap I have a bunch of attributes including an item-id.
> Now,
> > assuming I have an item id, what's the easiest way to update the
> appropriate
> > hashmap?  I can't use an assoc, I believe, because my data is in a
> > vector--not keyed by the id.
> >
> > What I have been doing is writing a function that maps the categories
> > to new categories and then write another function that is called on
> every
> > item and updates it iff the item id matches.  This works, but it
> seems
> > really clunky and I'm assuming there's a simpler way to do it.
> >
> > ; categories is a vector of item vectors, where the item is a hash
> > (def categories [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5
> }
> > ] [ { :id 3 :age 7 } ] ])
> >
> > Is there a more elegant workflow for updating categories?  Let's say
> I
> > want to update item of id 3 with { :age 12 :somethingElse 29 },
> what's the
> > easiest way to do this?
> >
> > ; so the return would be
> > [ [ { :id 1 :text "foo" } { :id 2 :text "bar" :ack 5 } ] [ { :id 3
> :age
> > 12 :somethingElse 29 } ] ]
> >
> > --
> > 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, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to clojure+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> 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 modera

Re: ANN: ClojureScript 0.0-2719, JavaScript Dependencies

2015-01-26 Thread Daniel
Extremely happy to see you promoting cljsjs as a community solution for 
something equivalent to clojars.

On Sunday, January 25, 2015 at 1:42:54 PM UTC-6, David Nolen wrote:
>
> I strongly recommend the Clojure(Script) community join forces when 
> packaging libraries to avoid duplicated effort and dependency conflicts.
>
> CLJSJS seems like a good initiative to me along these lines: 
> http://cljsjs.github.io
>
> David
>
> On Sun, Jan 25, 2015 at 1:49 PM, Vladimir Bokov  > wrote:
>
>> Thanks David!
>>
>> I also already packaged https://github.com/razum2um/jquery-cljs using 
>> your react repo as example
>>
>> суббота, 24 января 2015 г., 21:10:29 UTC+6 пользователь David Nolen 
>> написал:
>>
>>> ClojureScript, the Clojure compiler that emits JavaScript source code.
>>>
>>> README and source code: https://github.com/clojure/clojurescript
>>>
>>> New release version: 0.0-2719
>>>
>>> Leiningen dependency information:
>>>
>>> [org.clojure/clojurescript "0.0-2719"]
>>>
>>> ClojureScript is not an island, like Clojure on the JVM, ClojureScript
>>> embraces the many benefits provided by the host. However this goal
>>> has been hampered by another goal - the compilation stragey. Google
>>> Closure Compiler offers superior optimization and minification for
>>> ClojureScript while simultaneously making it considerably more
>>> difficult to integrate non-Closure compatible libraries. Using popular
>>> libraries like jQuery, React or D3 is an error prone process: "which
>>> extern did I forget?", "which script tag did I miss for development?",
>>> "are these script tags in dependency order?".
>>>
>>> No more. 0.0-2719 delivers full support for non-Closure compatible
>>> libraries through some less known features that have been lurking
>>> around for almost three years - `deps.cljs` and the :foreign-libs
>>> compiler option.
>>>
>>> `deps.cljs` is a simple EDN file provided at the root of a JAR that
>>> describes additional build information for the ClojureScript
>>> compiler. For example here is the `deps.cljs` for the React JAR I
>>> maintain:
>>>
>>> {
>>>  :foreign-libs [{:file "react/react.js"
>>>  :file-min "react/react.min.js"
>>>  :provides ["com.facebook.React"]}
>>> {:file "react/react_with_addons.js"
>>>  :file-min "react/react_with_addons.min.js"
>>>  :provides ["com.facebook.ReactWithAddons"]}]
>>>  :externs ["react/externs/react.js"]
>>> }
>>>
>>> This file provides all the information ClojureScript needs to
>>> correctly manage the foreign dependency for you under all compilation
>>> modes and REPLs.
>>>
>>> In a REPL:
>>>
>>>cljs.user> (require 'com.facebook.React)
>>>cljs.user> (. js/React 
>>> (renderToString 
>>>   (. js/React (DOM.div nil "Hello!"
>>>
>>> In your project:
>>>
>>>(ns foo.bar
>>>  (:require com.facebook.React))
>>>
>>>(enable-console-print!)
>>>
>>>(println
>>>  (. js/React
>>>(renderToString
>>>  (. js/React (DOM.div nil "Hello!")
>>>
>>> The above works under all compilation modes. There is no need to
>>> include React as a script tag under development, there is no need to put
>>> script tags in dependency order, there is no need to add React to
>>> :preamble under :advanced, and there is no need to explicitly provide
>>> :externs.
>>>
>>> All that is required is that JavaScript libraries be packaged in JARs
>>> with a `deps.cljs`.
>>>
>>> Some of you might reasonably ask why not a tool like Bower for this
>>> instead?  Bower requires an additional dependency on Node.js. While
>>> ClojureScript embraces Node.js as a useful target it is not a
>>> requirement to be productive. Bower manages dependencies, but in the
>>> Clojure world we have already embraced Maven for this task and have
>>> done the same for ClojureScript. Finally Bower does not address the
>>> problem of loading libraries at runtime. This is challenging to do -
>>> some JavaScript libraries adopt CommonJS, some AMD, and the most
>>> popular ones make no assumptions at all allowing users to simply use
>>> script tags as they have done for nearly two decades. The above
>>> solution addresses the issue for all ClojureScript users by
>>> eliminating paralysis of choice. Finally none of the above
>>> precludes Bower usage in any way whatsoever.
>>>
>>> This new feature addresses a long outstanding pain point with
>>> ClojureScript development. All that is required is that we take the
>>> time to properly package up the most popular JavaScript libraries that
>>> fill gaps not currently served by exising ClojureScript and Google
>>> Closure Library functionality.
>>>
>>> Please kick the tires and feedback is most welcome. This feature
>>> touched many bits of code so there are likely to be wrinkles and we want
>>> to get these ironed out as quickly as possible.
>>>
>>> ## 0.0-2719
>>>
>>> ### Changes
>>> * Full support for foreign dependencies
>>> *

Heuristic search: convenient memoization?

2015-01-26 Thread David James
Background: I'm implementing a heuristic search over a tree of 
possibilities. The heuristic calculation runs over a map of state. I have a 
large number of nested functions that support this heuristic. So, for 
convenience, I often pass around `state` as the first argument in these 
functions. Inside, I use the :keys destructuring style.

Commentary: This approach is convenient; however, I feel like I've veered 
towards one of the pitfalls of OO programming, where this "convenient" 
composition of data hides the essence of the problem. In contrast, in other 
projects, I've done lots of memoization -- this is easy when all arguments 
are explicit.

Questions: Have others faced this tradeoff? How do you think about it? How 
do you strike a balance, if there is one? More pointedly, is there a way to 
get the best of both worlds (e.g. the "composed" argument style AND 
memoization)?

Possible Solution: What about writing a macro to help? It would not be hard 
to handle the memoization of some 'base-level' functions:

(defn f1 [{:keys [a b] :as state}] :costly-calculation-of-a-b)
(defn f2 [{:keys [b c] :as state}] :costly-calculation-of-b-c)

However, when it comes to a chain of functions, the memoization is not 
apparent:

(defn f3 [{:keys [x] :as state}] (+ (f1 state) (f2 state) (g x)))

In order to memoize `f3`, one would need to account for not only `x` but 
also `a`, `b`, and `c`. This would be an improvement over memoizing the 
entire state.

Any thoughts on this kind of solution? Has it already been done? Are there 
other, possibly better, ways to address this overall challenge?

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Convenient memoization with destructured arguments

2015-01-26 Thread David James
I just renamed the subject line since my question has nothing inherently to 
do with heuristic search. (That was just my particular use case.) This kind 
of thing can happen in any codebase where destructuring of function 
arguments is used.

On Monday, January 26, 2015 at 12:16:04 PM UTC-5, David James wrote:
>
> Background: I'm implementing a heuristic search over a tree of 
> possibilities. The heuristic calculation runs over a map of state. I have a 
> large number of nested functions that support this heuristic. So, for 
> convenience, I often pass around `state` as the first argument in these 
> functions. Inside, I use the :keys destructuring style.
>
> Commentary: This approach is convenient; however, I feel like I've veered 
> towards one of the pitfalls of OO programming, where this "convenient" 
> composition of data hides the essence of the problem. In contrast, in other 
> projects, I've done lots of memoization -- this is easy when all arguments 
> are explicit.
>
> Questions: Have others faced this tradeoff? How do you think about it? How 
> do you strike a balance, if there is one? More pointedly, is there a way to 
> get the best of both worlds (e.g. the "composed" argument style AND 
> memoization)?
>
> Possible Solution: What about writing a macro to help? It would not be 
> hard to handle the memoization of some 'base-level' functions:
>
> (defn f1 [{:keys [a b] :as state}] :costly-calculation-of-a-b)
> (defn f2 [{:keys [b c] :as state}] :costly-calculation-of-b-c)
>
> However, when it comes to a chain of functions, the memoization is not 
> apparent:
>
> (defn f3 [{:keys [x] :as state}] (+ (f1 state) (f2 state) (g x)))
>
> In order to memoize `f3`, one would need to account for not only `x` but 
> also `a`, `b`, and `c`. This would be an improvement over memoizing the 
> entire state.
>
> Any thoughts on this kind of solution? Has it already been done? Are there 
> other, possibly better, ways to address this overall challenge?
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-alpha5 now available

2015-01-26 Thread Jozef Wagner
With CLJ-979 applied, lein may crash when doing :aot :all. This is caused 
when lein forces recompilation of already compiled classes. Not sure 
whether this should be considered a lein of clojure bug though.

See https://github.com/wagjo/aotbug for contrived example.

Jozef

On Saturday, January 10, 2015 at 4:37:04 PM UTC+1, Alex Miller wrote:
>
> Clojure 1.7.0-alpha5 is now available.
>
> Try it via
> - Download: 
> https://repo1.maven.org/maven2/org/clojure/clojure/1.7.0-alpha5/
> - Leiningen: [org.clojure/clojure "1.7.0-alpha5"]
>
> A few of the highlights in alpha5:
>
> 1) New transducer arities for map-indexed, distinct, and interpose.
> The transducer versions are generally faster than the sequence versions.
> See CLJ-1601 for more details.
>
> 2) The set and vec functions should now be faster in many cases. Some of 
> the
> vec improvements will not kick in until CLJ-1499 is committed in the 
> future.
> See CLJ-1546 and CLJ-1618 for more details.
>
> 3) Two particularly troublesome AOT classloading bugs have been addressed 
> - 
> CLJ-979 and CLJ-1544. Many other tickets were found to be duplicates of 
> one of
> these as well. Big thanks to Nicola Mometto for doing the hard work on 
> debugging and providing fixes for these.
>
> For all changes new in alpha5, see the issues marked "(alpha5)" in the
> full changes below.
>
> 
> Clojure 1.7.0-alpha5 has the changes below from 1.6.0:
>
> ## 1 New and Improved Features
>
> ### 1.1 Transducers
>
> Transducers is a new way to decouple algorithmic transformations from their
> application in different contexts. Transducers are functions that transform
> reducing functions to build up a "recipe" for transformation.
>
> Also see: http://clojure.org/transducers
>
> Many existing sequence functions now have a new arity (one fewer argument
> than before). This arity will return a transducer that represents the same
> logic but is independent of lazy sequence processing. Functions included 
> are:
>
> * conj (conjs to [])
> * map
> * mapcat
> * filter
> * remove
> * take
> * take-while
> * drop
> * drop-while
> * cycle
> * take-nth
> * replace
> * partition-by
> * partition-all
> * keep
> * keep-indexed
> * map-indexed (alpha5)
> * distinct (alpha5)
> * interpose (alpha5)
>
> Additionally some new transducer functions have been added:
>
> * cat - concatenates the contents of each input
> * de-dupe - removes consecutive duplicated values
> * random-sample - returns items from coll with random probability
>
> And this function can be used to make completing transforms:
>
> * completing
>
> There are also several new or modified functions that can be used to apply
> transducers in different ways:
>
> * sequence - takes a transformation and a coll and produces a lazy seq
> * transduce - reduce with a transformation (eager)
> * eduction - returns a reducible/seqable/iterable seq of applications of 
> the transducer to items in coll. Applications are re-performed with every 
> reduce/seq/iterator.
> * run! - run the transformation for side effects on the collection
>
> There have been a number of internal changes to support transducers:
>
> * volatiles - there are a new set of functions (volatile!, vswap!, 
> vreset!, volatile?) to create and use volatile "boxes" to hold state in 
> stateful transducers. Volatiles are faster than atoms but give up atomicity 
> guarantees so should only be used with thread isolation.
> * array iterators - added support for iterators over arrays
>
> Some related issues addressed during development:
> * [CLJ-1511](http://dev.clojure.org/jira/browse/CLJ-1511)
> * [CLJ-1497](http://dev.clojure.org/jira/browse/CLJ-1497)
> * [CLJ-1549](http://dev.clojure.org/jira/browse/CLJ-1549)
> * [CLJ-1537](http://dev.clojure.org/jira/browse/CLJ-1537)
> * [CLJ-1554](http://dev.clojure.org/jira/browse/CLJ-1554)
> * [CLJ-1601](http://dev.clojure.org/jira/browse/CLJ-1601) (alpha5)
> * [CLJ-1606](http://dev.clojure.org/jira/browse/CLJ-1606) (alpha5)
> * [CLJ-1621](http://dev.clojure.org/jira/browse/CLJ-1621) (alpha5)
> * [CLJ-1600](http://dev.clojure.org/jira/browse/CLJ-1600) (alpha5)
>
> ### 1.2 Keyword and Symbol Construction
>
> In response to issues raised in [CLJ-1439](
> http://dev.clojure.org/jira/browse/CLJ-1439),
> several changes have been made in symbol and keyword construction:
>
> 1) The main bottleneck in construction of symbols (which also occurs 
> inside keywords) was
> interning of the name and namespace strings. This interning has been 
> removed, resulting
> in a performance increase.
>
> 2) Keywords are cached and keyword construction includes a cache check. A 
> change was made
> to only clear the cache reference queue when there is a cache miss.
>
> ### 1.3 Warn on Boxed Math
>
> One source of performance issues is the (unintended) use of arithmetic 
> operations on
> boxed numbers. To make detecting the presence of boxed math easier, a 
> warning will now
> be emitted about

Re: Dynamically creating defrecord

2015-01-26 Thread JUAN ANTONIO Ruz
Hi Sven, 
I was trying to do the same with my library tangrammer/defrecord-wrapper 
 and, just today, I found 
a couple of links that worked fine for that
http://grokbase.com/t/gg/clojure/11cjvz1jda/defrecord-based-on-runtime-metadata
http://stackoverflow.com/questions/3748559/clojure-creating-new-instance-from-string-class-name

I integrated the solution here making a lazy-seq of dynamic defrecords
https://github.com/milesian/aop/blob/master/src/milesian/aop.clj#L20


hope it helps
Juan



El sábado, 17 de enero de 2015, 17:27:05 (UTC), Sven Richter escribió:
>
> Hi,
>
> I am trying to create record definitions dynamically during runtime. What 
> I would like to do is something like this:
>
> (defn mk-rec [record-name namespace arg-list]
>   (eval '(do (ns namespace)
>(defrecord record-name arg-list
>
> And then call it like this:
> (mk-rec "A" "ns" [a b c])
> (->ns.A 1 2 3 )
>
> I am trying out different things, but struggle to get it right or find 
> some tutorial for it.
>
> So if anyone is willing to share some working code I'd be really happy.
>
> Thanks,
> Sven
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pedestal comparison to Sente/HTTPKit

2015-01-26 Thread Julio Barros
Hi,

I'm starting on a new api based (analytics and event logging) project that 
will get many http requests that I need to handle concurrently and with low 
latency.

I'm trying to understand how Pedestal (service) and Sente w/ HTTPKit 
compare for this use.

Has anyone written up experiences that might help guide that decision?

Thanks.

Julio

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pedestal comparison to Sente/HTTPKit

2015-01-26 Thread Mike Haney
I haven't had a chance to really dig into Pedestal yet, but Ryan Neufeld did a 
video sometime back that really opened my eyes to how Pedestal works:  
http://youtu.be/sFT_0v-iKVQ

Pedestal is primarily focused on letting you provide your services (RESTful or 
otherwise) while still providing some ability to push updates out to clients 
through SSE.  In my view (someone may correct me on this) it would be ideal for 
servers where you are mostly servicing api requests, but occasionally need to 
push notifications out to clients.

In contrast, Sente is purely focused on socket communications between client 
and server.  There's no real facility there for providing RESTful services, 
because that's not it's purpose.  You would either have to model your requests 
as a message going over the client->server socket, or provide a separate 
RESTful endpoint running alongside your socket connection.  So it really 
depends on your apps architecture.

I've experimented with Sente quite a bit, and it really is cool and quite 
robust, but it's fairly low level in that you would need to build your 
messaging system on top of it, since it is only concerned with managing the 
socket connection.  If you are planning a very dynamic app that needs real-time 
updates, it's a great platform on which to build it, but it is just a platform.

A third option would be to use Ring and maybe Liberator to provide a REST 
endpoint and Sente to handle mainly the server->client notifications.  This is 
comparable to the Pedestal approach, and if this is the style app you need, the 
real comparison is between Ring+Sente (or some other method of push updates) 
and Pedestal.  Comparing Pedestal directly to just Sente is apples and oranges.

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pedestal comparison to Sente/HTTPKit

2015-01-26 Thread Mike Haney
Forgot to mention, as far as raw performance/latency of HTTP servers go, you 
can find a comparison here: 
https://github.com/ptaoussanis/clojure-web-server-benchmarks

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pedestal comparison to Sente/HTTPKit

2015-01-26 Thread Julio Barros
Hi Mike,

Thanks for the reply.

Yes forgot to mention that there will also be a UI component to monitor the 
events and the status of the system. Thats why I was considering sente and 
push.

Thanks again.

Julio

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pedestal comparison to Sente/HTTPKit

2015-01-26 Thread Ryan Neufeld
Glad to hear you enjoyed the video.

Anyone taking a look at Pedestal should feel free to hit us up on our 
Google Group (https://groups.google.com/forum/#!forum/pedestal-users) 
should they have any questions.

On Monday, January 26, 2015 at 4:00:56 PM UTC-6, Mike Haney wrote:
>
> Forgot to mention, as far as raw performance/latency of HTTP servers go, 
> you can find a comparison here: 
> https://github.com/ptaoussanis/clojure-web-server-benchmarks 
> 

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hi I am a new user of clojure ,I am not being able to use lein

2015-01-26 Thread Denis Fuenzalida
Hi Bis,

I just tried Leiningen on a Windows 7 machine and what was simpler for me 
was to:

* Install JDK 8
* Save lein.bat to a location where lein could be run from the command line 
(eg. C:\WINDOWS).
* On a cmd.exe console run "lein self-install" to download lein's library. 
Didn't have to install curl or wget because lein.bat used PowerShell, which 
is bundled in Windows 7
* Leininigen was working fine afterwards, I could run "lein new app foobar" 
to create a project and "lein repl", etc. from the cmd console.

I created an album in Imgur with some screenshots so you can follow: 
http://imgur.com/a/UFqK3

Best regards,

Denis


El lunes, 26 de enero de 2015, 6:48:07 (UTC-3), Bis escribió:
>
> I am trying from some time but cant install lein.
>
> Tried with the MSI installer and it finishes properly but no repl is 
> created neither lein
> tried with lein.bat ,getting errors everytime ,
> "Exception calling Downloadfile with two arguement.the remote server 
> returned an error 403 forbidden.(set http client to "wget" and tried also 
> ,btw lein.bat is taken from the official site so not sure if the official 
> version of the bat file is trying to get some unstable release or not )
> tried with chocolatey but chocolatey tries to install JDK 7 and its 
> failing ,although I have JDK8 in my system 
> Please some one help to debug ,I am getting frustrated 
>

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ANN: Om 0.8.6, Hello CLJSJS

2015-01-26 Thread David Nolen
The only significant change is that Om now relies on the cljsjs.react
artifact instead of the one I maintained myself. cljsjs.react has the
benefit that usage of React with addons instead of plain React may be
configured via Maven in your pom.xml or your project.clj. It's exciting to
see that we are already reaping the benefits of :foreign-libs and Maven
over existing JavaScript solutions for managing dependencies.

This release also includes a fix for a very subtle set-state! bug
discovered by Brenton Ashworth.

Feedback welcome!

https://github.com/swannodette/om

David

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Convenient memoization with destructured arguments

2015-01-26 Thread Rob Lally
Graph from prismatic/plumbing  [ https://github.com/Prismatic/plumbing 
 ] provides 
memoization/delayed-execution allowing you to maintain a map-like structure 
whilst deferring and caching calculations.


Rob.


> On 26 Jan 2015, at 09:17, David James  wrote:
> 
> I just renamed the subject line since my question has nothing inherently to 
> do with heuristic search. (That was just my particular use case.) This kind 
> of thing can happen in any codebase where destructuring of function arguments 
> is used.
> 
> On Monday, January 26, 2015 at 12:16:04 PM UTC-5, David James wrote:
> Background: I'm implementing a heuristic search over a tree of possibilities. 
> The heuristic calculation runs over a map of state. I have a large number of 
> nested functions that support this heuristic. So, for convenience, I often 
> pass around `state` as the first argument in these functions. Inside, I use 
> the :keys destructuring style.
> 
> Commentary: This approach is convenient; however, I feel like I've veered 
> towards one of the pitfalls of OO programming, where this "convenient" 
> composition of data hides the essence of the problem. In contrast, in other 
> projects, I've done lots of memoization -- this is easy when all arguments 
> are explicit.
> 
> Questions: Have others faced this tradeoff? How do you think about it? How do 
> you strike a balance, if there is one? More pointedly, is there a way to get 
> the best of both worlds (e.g. the "composed" argument style AND memoization)?
> 
> Possible Solution: What about writing a macro to help? It would not be hard 
> to handle the memoization of some 'base-level' functions:
> 
> (defn f1 [{:keys [a b] :as state}] :costly-calculation-of-a-b)
> (defn f2 [{:keys [b c] :as state}] :costly-calculation-of-b-c)
> 
> However, when it comes to a chain of functions, the memoization is not 
> apparent:
> 
> (defn f3 [{:keys [x] :as state}] (+ (f1 state) (f2 state) (g x)))
> 
> In order to memoize `f3`, one would need to account for not only `x` but also 
> `a`, `b`, and `c`. This would be an improvement over memoizing the entire 
> state.
> 
> Any thoughts on this kind of solution? Has it already been done? Are there 
> other, possibly better, ways to address this overall challenge?
> 
> -- 
> 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, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Resources don't work in uberjar

2015-01-26 Thread Dan Harbin


I've created a sample project at Github[1] to demonstrate the problem I'm 
facing with accessing a resource file when using an uberjar.  Could someone 
point out what I'm doing wrong here?  Thanks!


[1]: https://github.com/RasterBurn/halp


### Given this code: ###

```clojure
(ns halp.core
  (:require [clojure.java.io :as io])
  (:gen-class))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (-> "hi.txt"
  io/resource
  io/file
  (io/copy *out*)))
```

### It runs well under leiningen ###

```
➜  halp  lein run
.
─▄──▄
▌▒█───▄▀▒▌
▌▒▒▀▄───▄▀▒▒▒▐
───▐▄▀▒▒▄▄▄▀▒▐
─▄▄▀▒▒▒█▒▒▄█▒▐
───▄▀▒▒▒▀██▀▒▌
──▐▒▒▒▄▄▄▒▀▄▒▒▌
──▌▒▒▐▄█▀▄▀█▄▒▒▒█▒▐
─▐▒▒▒▌██▀▀▄▌
─▌▒▀▄██▄▒▒▒▌
─▌▀▐▄█▄█▌▄▒▀▒▒░░▒▒▒▐
▐▒▀▐▀▐▀▒▒▄▄▒▄▒░░▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒░░▒▒▒▐
─▌▒▒▀▀▀▌
─▐▐
──▀▄▒▄▌
▀▄▒▒▄▄▄▀▄▀
───▐▀▒▀▄▄▀▀▀▒▄▄▀
──▐▀▀
```

### But not so much as an uberjar #

```
➜  halp  java -jar target/uberjar/halp-0.1.0-SNAPSHOT-standalone.jar
Exception in thread "main" java.lang.IllegalArgumentException: Not a file: 
jar:file:/home/vagrant/code/halp/target/uberjar/halp-0.1.0-SNAPSHOT-standalone.jar!/hi.txt
at clojure.java.io$fn__8588.invoke(io.clj:63)
at clojure.java.io$fn__8572$G__8556__8577.invoke(io.clj:35)
at clojure.java.io$file.invoke(io.clj:414)
at halp.core$_main.doInvoke(core.clj:11)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at halp.core.main(Unknown Source)
```

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.