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.


Leiningen template in private maven repo

2015-09-11 Thread Michael Willis
I'm trying to write a leiningen template for company internal use.  I have 
deployed it to our internal Artifactory instance, and added the Artifactory 
URL to :repositories in ~/.lein/profiles.clj, but `lein new` can't resolve 
it:

$ lein new rest-microservice my-new-api
Failed to resolve version for rest-microservice:lein-template:jar:RELEASE: 
Could not find metadata rest-microservice:lein-template/maven-metadata.xml 
in local (~/.m2/repository)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment 
variable.
Could not find template yodle-service on the classpath.

Incidentally, I get more information if I pass in the --snapshot flag:

$ lein new rest-microservice my-new-api --snapshot
Could not find metadata rest-microservice:lein-template/maven-metadata.xml 
in local (~/.m2/repository)
Failure to find rest-microservice:lein-template/maven-metadata.xml in 
https://repo1.maven.org/maven2/ was cached in the local repository, 
resolution will not be reattempted until the update interval of central has 
elapsed or updates are forced
Failure to find rest-microservice:lein-template/maven-metadata.xml in 
https://clojars.org/repo/ was cached in the local repository, resolution 
will not be reattempted until the update interval of clojars has elapsed or 
updates are forced
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment 
variable.
Could not find template rest-microservice on the classpath.

It seems like `lein new` doesn't look for templates in the internal 
repository, even though I have configured ~/.lein/profiles.clj such that I 
have successfully made a project.clj use dependencies from Artifactory.

Is there some other configuration required to use leiningen templates from 
an internal repo?

Thanks,
Michael

-- 
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: Leiningen template in private maven repo

2015-09-11 Thread Michael Willis
I figured it out - leiningen looks for template in the default repos, and 
anything configured under {:user {:plugin-repositories ...}}


On Friday, September 11, 2015 at 11:38:24 AM UTC-5, Michael Willis wrote:
>
> I'm trying to write a leiningen template for company internal use.  I have 
> deployed it to our internal Artifactory instance, and added the Artifactory 
> URL to :repositories in ~/.lein/profiles.clj, but `lein new` can't resolve 
> it:
>
> $ lein new rest-microservice my-new-api
> Failed to resolve version for rest-microservice:lein-template:jar:RELEASE: 
> Could not find metadata rest-microservice:lein-template/maven-metadata.xml 
> in local (~/.m2/repository)
> This could be due to a typo in :dependencies or network issues.
> If you are behind a proxy, try setting the 'http_proxy' environment 
> variable.
> Could not find template yodle-service on the classpath.
>
> Incidentally, I get more information if I pass in the --snapshot flag:
>
> $ lein new rest-microservice my-new-api --snapshot
> Could not find metadata rest-microservice:lein-template/maven-metadata.xml 
> in local (~/.m2/repository)
> Failure to find rest-microservice:lein-template/maven-metadata.xml in 
> https://repo1.maven.org/maven2/ was cached in the local repository, 
> resolution will not be reattempted until the update interval of central has 
> elapsed or updates are forced
> Failure to find rest-microservice:lein-template/maven-metadata.xml in 
> https://clojars.org/repo/ was cached in the local repository, resolution 
> will not be reattempted until the update interval of clojars has elapsed or 
> updates are forced
> This could be due to a typo in :dependencies or network issues.
> If you are behind a proxy, try setting the 'http_proxy' environment 
> variable.
> Could not find template rest-microservice on the classpath.
>
> It seems like `lein new` doesn't look for templates in the internal 
> repository, even though I have configured ~/.lein/profiles.clj such that I 
> have successfully made a project.clj use dependencies from Artifactory.
>
> Is there some other configuration required to use leiningen templates from 
> an internal repo?
>
> Thanks,
> Michael
>
>

-- 
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: Largest Clojure codebases?

2015-11-16 Thread Michael Willis
For what it's worth, here's the way that I always count lines of code, 
should work on any unix-like system:

find -name "*.clj" | wc -l

On Sunday, November 15, 2015 at 5:23:01 PM UTC-6, Colin Yates wrote:
>
> Exactly this. I couldn’t find a reliable way of counting LOC but my 
> (Clojure/ClojureSciprt) src tree (excluding test) in the project I have to 
> hand is 1.5MB.
>
>
> On 15 Nov 2015, at 21:27, Timothy Baldridge  > wrote:
>
> It's funny, because most of the larger OOP projects I worked on were large 
> because of class bloat, not because of business concerns. For example, the 
> C# app I used to work on was a more or less simple CRUD app. We had a ORM 
> that served up objects to a Silverlight UI. So if we wanted to display 
> information about a person on the UI we normally had to modify around 5 
> classes in 5 files. We had the following layers
>
> ORM - 1.4MB of generated C# for interfacing with the 200 or so SQL tables 
> we had
> DTO - Data Transfer Object, where used "normal" C# objects to abstract the 
> ORM. This is where we had the "Person" object 
> API - A web service that served up DTOs over HTTP
> Data Model - Processed views of DTOs formatted in a way that was easily 
> viewable by the UI
> View Model - UI classes that would take data from a Data Model and emit UI 
> controls. 
>
> All of that ceremonythat is replaced by one thing in Clojure...data. 
> Hashmaps and vectors replace all the junk you see above. 
>
> So that's where I often assert "Yes, you may have 1 million lines of Java 
> codebut that would only be ~10,000 lines of Clojure." With proper 
> application of data driven systems (data that configures pipelines and 
> writes code) you can easily get a 100:1 ratio of Java to Clojure code. 
>
> Timothy
>
>
> On Sun, Nov 15, 2015 at 12:48 PM, Marc O'Morain  > wrote:
>
>> We have a large app at CircleCI - as of September:
>>
>> "The repo for our main app contains 93,983 lines of Clojure code. The src 
>> directory 
>> of our main app contains 369 namespaces."
>>
>> http://blog.circleci.com/why-were-no-longer-using-core-typed/
>>
>>
>>
>> On Sun, Nov 15, 2015 at 7:22 PM, dilettan...@live.com  <
>> dilettan...@live.com > wrote:
>>
>>> I've been having a (friendly) argument with a friend who is an 
>>> old-school OOP programmer.  He insists that you need objects to make 
>>> large-scale codebases legible and maintainable over the long run.  Quite 
>>> apart from this argument's virtues or lack thereof, this made me curious -- 
>>> what are the largest programs written in Clojure in terms of LOC?  I know 
>>> I've seen mentions of 50k-100k LOC projects (World Singles, if I'm 
>>> remembering correctly), but are there any that are larger?
>>>
>>>Vikram
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@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 clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> “One of the main causes of the fall of the Roman Empire was that–lacking 
> zero–they had no way to indicate successful termination of their C 
> programs.”
> (Robert Firth) 
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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

Re: [ANN] Brute 0.4.0 - A lightweight Entity Component System library for writing games

2016-01-26 Thread Michael Willis
Nice!  I'm curious if you have thought of any way to index the entities by 
component values.  For example, let's say your game has thousands of 
entities, and you want to write a system that does something with all 
entities in proximity of a given location, or maybe it does something to 
all entities with health less than 10%.  It would be nice if the systems 
didn't have to filter through thousands of entities.

On Thursday, January 21, 2016 at 8:14:35 PM UTC-6, Mark Mandel wrote:
>
> Brute is a simple and lightweight Entity Component System library for 
> writing games with Clojure and ClojureScript.
>
> This release is essentially just a move from CLJX to Reader Conditionals 
> to implement support for both CLJ and CLJS.
>
> Full details, and how the conversation process went can be found in the 
> full blog post:
> http://www.compoundtheory.com/brute-0-4-0-from-cljx-to-reader-conditionals/
>
> Project can be found on Github at:
> https://github.com/markmandel/brute
>
> As always feedback and pull requests are welcome.
>
> -- 
> E: mark@gmail.com 
> T: http://www.twitter.com/neurotic
> W: www.compoundtheory.com
>
> 2 Devs from Down Under Podcast
> http://www.2ddu.com/
>

-- 
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: Java API type hint question

2016-01-26 Thread Michael Willis
What's not practical about quoting?  I thought it was considered more 
idiomatic than doing (list ...)

On Sunday, January 17, 2016 at 2:48:29 PM UTC-6, Ritchie Cai wrote:
>
> Hi all,
>
> I'm trying to create a Java ArrayList object from a Clojure collection to 
> pass to another Java API. I get reflection warnings when the elements are 
> not primitive types, in this case I'm using SparseIndexedVector class 
> from vectorz library.
>
> (ArrayList. [c0 c1 c2])
> Reflection warning, *cider-repl localhost*:77:11 - call to 
> java.util.ArrayList ctor can't be resolved.
>
> where c0 c1 c2 are of type SparseIndexedVector. Alternatively, I can 
> create create ArrayList then add elements one by one in a loop.
>
> (doto (ArrayList.)
>(.add c0)
>(.add c1)
>(.add c2))
>
> But I'm wondering if there is away to get rid of the the reflection 
> warning when calling ArrayList constructor. 
>
> Also, quoting a list will not give reflection warning:
>
> (ArrayList. '(c0 c1 c2))  ;; no warning
>
> (ArrayList. (list c0 c1 c2)) 
> Reflection warning, *cider-repl localhost*:77:11 - call to 
> java.util.ArrayList ctor can't be resolved.
>
> However, quoting is not very practical.
>
> Thanks
> Ritchie
>
>

-- 
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] Graclj 0.1.0 -- New Gradle Plugin for Clojure

2016-02-15 Thread Michael Willis
In the event that you're looking for a logo, consider an artistic icon 
based on this: https://en.wikipedia.org/wiki/Common_grackle

On Sunday, February 14, 2016 at 8:11:00 PM UTC-6, Andrew Oberstar wrote:
>
> I just released the first version of Graclj, which is a new Gradle plugin 
> for Clojure. The goal is to make something that feels native to Gradle, 
> while giving the creature comforts Clojurians are used to from lein or 
> boot. For those familiar with Gradle, this targets their new (and still 
> evolving) software model support.
>
> Current features include:
>
> - Packaging Clojure code into JARs
> - AOT compilation
> - clojure.test execution
> - Publishing to any repo supported by Gradle (including Clojars)
>
> I wouldn't suggest dropping your current build tool yet, but if you'd like 
> to try it out, you can walk through the learning-graclj repo. I'd welcome 
> any feedback on the plugin or documentation.
>
> Source: https://github.com/graclj/graclj
> Documentation: 
> https://github.com/graclj/learning-graclj/tree/learning-0.1.0
>
> Thanks,
> Andrew Oberstar
>
>

-- 
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.


defmacro/gen-class/annotation woes

2013-02-27 Thread Michael Willis
Hi Folks,

I'm attempting to write a clojure macro that uses gen-class to replace 
several manually written Java classes that all follow a similar pattern.

Yes, in my magic world of unicorns and mermaids, I would just rewrite them 
in pure clojure, but for the context of this question my solution has to 
generate Java classes (I can elaborate if anybody really wants to know).

The problem is that my macro is apparently unable to emit gen-class code 
that will include annotations in the class.  I've boiled my problem down to 
this example:

(gen-class
  :name ^{Deprecated true} Test1
  :prefix Test1-
  :methods [[^{Deprecated true} getValue [] Integer]])

(defn Test1-getValue [] 42)

(defmacro create-test-class [name x]
  (let [prefix (str name "-")]
`(do
  (gen-class
 :name ~(with-meta name {Deprecated true})
 :prefix ~(symbol prefix)
 :methods [[~(with-meta 'getValue {Deprecated true}) [] Integer]])
  (defn ~(symbol (str prefix "getValue")) [] ~x

(create-test-class Test2 56)


When I compile this file, it creates a Test1.class and Test2.class - I 
inspect both with Eclipse, and find that Test1 has both class-level and 
method-level @Deprecated annotations, but Test2.class has no annotations.  
When I use macroexpand, it looks as though my Test2.class should be 
annotated: 

user=> (set! **print-meta** true) 
true 
user=> (macroexpand '(create-test-class Test2 56)) 
(do (clojure.core/gen-class :name ^{java.lang.Deprecated true} Test2 
:prefix Test2- :methods [[^{java.lang.Deprecated true} getValue [] 
java.lang.Integer]]) (user/defn Test2-getValue [] 56)) 

Is there something wrong with the way that I attempt to attach the metadata?

Thanks!
Michael Willis

-- 
-- 
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/groups/opt_out.




Re: defmacro/gen-class/annotation woes

2013-02-28 Thread Michael Willis
Hi Meikel!

Thanks for the suggestion.  I'll second what Paul said, I'm not sure if I 
would ever have guessed to syntax quote the metadata map.  I just tested it 
and it works like magic.

Cheers,
Michael Willis

On Thursday, February 28, 2013 12:21:57 AM UTC-7, Meikel Brandmeyer 
(kotarak) wrote:
>
> Hi,
>
> if you want to avoid reflection in macro-generated code you have to quote 
> the class because the compiler expects the classname and not the class 
> itself. I figured it could be similar here.
>
> Kind regards
> 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 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/groups/opt_out.




Re: Running Clojure apps using less memory.

2016-03-28 Thread Michael Willis
You can tune memory usage by passing parameters to the JVM:

http://docs.oracle.com/cd/E19900-01/819-4742/abeik/index.html

The sample leiningen project file has an example of how to pass parameters 
to the JVM:

https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L264

Hope that helps,
Michael Willis


On Monday, March 28, 2016 at 7:11:49 AM UTC-5, Jason Basanese wrote:
>
> Hello all! I'm new to this forum. My name Is Jason Basanese and I am a 
> relatively new clojurist.
>
> I recently began hosting my first small full stack Clojure web app. While 
> doing this I ran into memory problems with my admittedly small load server. 
> The maximum it can take in temp memory is 741MB. Too much of that memory is 
> consumed giving an error when I try to run two REPLs on the server. One for 
> testing and editing code and the other for leaving the app running. My 
> other dynamic content websites which use php directly with Apache use 
> minimal memory. Why is it that running a Clojure app like such "lein run -m 
> clojureweb.core/serve" takes up so much memory? Here is the code of the 
> function I am running with that command. 
>
> (defn serve [& args]
>   (org.apache.log4j.BasicConfigurator/configure)
>   (run-server
>(logger/wrap-with-logger
> (reload/wrap-reload app))
>{:port 8080}))
>
> Are the logger or the wrap-reload making it take up so much memory? Is 
> there a better way to run Clojure apps that is less robust? Or is using a 
> relatively large amount of memory just a bullet to bite when using Clojure? 
> Yes I know an obvious solution would just be to upgrade the server, but 
> where's the fun in that?
>
> Requests for more detail, comments, answers and opinions all welcome!
>
>

-- 
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: Schemas for DSLs on top of Clojure

2016-04-29 Thread Michael Willis
The convention that I've seen among the Clojure community is to represent 
these kinds of things as data structures, and define your contraints using 
something like https://github.com/plumatic/schema

On Friday, April 29, 2016 at 1:10:29 PM UTC-5, Olek wrote:
>
> Hi!
>
> Clojure data structures can express tree data structures, same as in XML 
> what is ideal for DSL. Especially that thanks to macros you can also change 
> the evaluation order and hide execution complexity and treat DSL in terms 
> of declarations and not statements nor functions. What is more the grammar 
> of such structure is simplified to what you can see in XML.
> For example let take the XML example:
>
> 
> 
> 
> 
>
> Now lets look at Clojure:
>
> (books
>   (book { :iban "31232" :title "some title" :author "some author" })
>  (book { :ban "43232" :title "another title2" :author "another author 2" 
> }) )
>
> You can notice that when you build macros & functions for that you have 
> simple structure of input arguments like:
>
> (defmacro/defn books[ attrs & books-col ]
>(do some stuff))
>
> (defn book[ attrs ]
>   (do some stuff))
>
> Now all you need is to slurp the specification made in terms of created 
> DSL, call eval on it and as the result of execution you will spit the 
> resulting data/mutate the state/do side effect.
> Finally for XML you can create XSD to constraint possibilities of tags 
> which can be put into DSL.
> But as you can see, such possibility is missing for Clojure. Do you have 
> any ready tool for that or do I have to create one?
>
> Thanks in advance,
> Olek
>
>
>
>

-- 
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: understanding a clojuredocs merge example

2016-05-12 Thread Michael Willis
As long as we're cutting out unnecessary code, this is also equivalent:

(defn baz [options]
   (merge {:opt1 "default-1" :opt2 "default-2"} options))
(baz {:opt1 "custom-1" :opt3 "custom-3"});;=> {:opt3 "custom-3" :opt1 "custom-1 
:opt2 "default-2"}



On Thursday, May 12, 2016 at 4:03:04 AM UTC-5, Dan Kersten wrote:
>
> Yes, only the first map passed into baz (only one passed in anyway in the 
> example) is kept, anything else is thrown away. Seems like a strange 
> example when something like this would have sufficed to get the point of 
> merge across:
>
> (defn baz [options]
>(let [options (merge {:opt1 "default-1" :opt2 "default-2"} 
> options)]
>   options))
> (baz {:opt1 "custom-1" :opt3 "custom-3"});;=> {:opt3 "custom-3" :opt1 
> "custom-1 :opt2 "default-2"}
>
>
> On Thu, 12 May 2016 at 07:45 hiskennyness > 
> wrote:
>
>> I do not understand something this example:
>>
>>   
>> https://clojuredocs.org/clojure.core/merge#example-54c7b859e4b0e2ac61831cdf
>>
>> Specifically:
>>
>> (defn baz [& options]
>>>(let [options (merge {:opt1 "default-1" :opt2 "default-2"} 
>>> (first options))]
>>>   options))
>>> (baz {:opt1 "custom-1" :opt3 "custom-3"});;=> {:opt3 "custom-3" :opt1 
>>> "custom-1 :opt2 "default-2"}
>>>
>>>
>> IIANM, that throws away all but the first map in the rest parameter 
>> options.
>>
>> Is there more going on here than I realize?
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@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: I knew that primitives were better, but this is ridiculous

2016-05-13 Thread Michael Willis
I'm also really interested in the topic of indexing a CES game engine.  At 
one point I was trying to build a game, and mine was designed with 
components being maps of entity-id -> value.  I found that it worked really 
well to quickly do things like running a function for all entities that 
have a hunger component (for example), but I soon found myself wanting to 
filter entities based on some arbitrary criteria, like "run this function 
for all coniferous trees with age greater than X".  If the environment has 
tens of thousands of trees, it would be nicer to have an index on the age, 
along with an index on the variety of trees, so that it doesn't have to 
iterate over more entities than necessary.

Every time I go to the hammock (so to speak) to think over how to design 
such a system, I realize that I'm just re-inventing the database, so I come 
away feeling like somewhere, somehow there must already exist an in-memory 
database that will suit the problem, but I haven't determined what it is 
yet.

On Thursday, May 12, 2016 at 11:51:31 PM UTC-5, James Reeves wrote:
>
> If we want improve lookup performance in a SQL database, we place an index 
> on a column, or a group of columns. The same idea can be applied to a data 
> structure we keep in memory.
>
> So if you know that you want to lookup entities by position and velocity, 
> you could have an indexing function like:
>
>   (fn [index entity]
> (when (and (:position entity) (:velocity entity))
>   (assoc-in index [:mobile (:id entity)] entity)))
>
> And then you just need a way to run that index each time an entity is 
> added to your in-memory database. Naturally you'd also need a "unindex" 
> function as well.
>
> I've written a game library called Ittyon that works along these lines.
>
> - James
>
>
> On 13 May 2016 at 00:31, JvJ > wrote:
>
>> I'm intrigued, but I don't know exactly what you mean.
>>
>> On Thursday, 12 May 2016 16:25:05 UTC-7, James Reeves wrote:
>>>
>>> Have you considered defining specific indexes? For instance, if you know 
>>> ahead of time that you want to search for entities that have both position 
>>> and velocity, you could define an index that keys both of those values.
>>>
>>> - James
>>>
>>>
>>>
>>> On 12 May 2016 at 23:50, JvJ  wrote:
>>>
 Maybe this is a little off-topic, but on the general topic of 
 performance, other than just numerical performance, what's the best way to 
 get information/advice on how to improve it.

 I went about doing these tests (and other tests) because I'm trying to 
 create a game scripting framework in clojure, which I want to build around
 an entity-component-system architecture.  Entities are maps of 
 components, and system functions are defined to sort of "pattern match" 
 against
 entities to see if they have the required components.  (i.e. an 
 update-position function would add velocity to position, so it only 
 applies 
 to entities
 with both a position and a velocity component).

 The first step in this process is to find a way to store these so that 
 it would be as fast as possible to iterate over "all entities with this 
 set 
 of components",
 while avoiding things like filter operations.

 I started off by making cross-map , 
 which cross-indexes any entries with keys of the form [r c], where r is a 
 row and c is a column, and allows O(1) access
 of entire rows and columns.

 Still, though, the performance tests 
  
 aren't what I expected they would be, and I'm wondering how to go about 
 dealing with that.

 Again, this isn't strictly about numerical performance, but it's why 
 I'm doing these kinds of tests in the first place.

 Thanks.

 On Thursday, 12 May 2016 15:23:07 UTC-7, raould wrote:
>
> On Thu, May 12, 2016 at 3:11 PM, Nicola Mometto  
> wrote: 
> > Fair enough, but in this case types wouldn't really have helped: the 
> author did use `Double` type hints, mistakenly assuming that would make 
> its 
> code use primitive types, which it does not since `Double` is boxed and 
> not 
> primitive. 
> > Clojure already has compile time warnings about boxed math that 
> would've helped in this case if turned on, without any need for types: 
> try 
> compiling OP's code after running `(set! *unchecked-math* 
> :warn-on-boxed)` 
>
> Thanks for the details re: double. Apologies for being annoyed/ing. 
>
> Next up: something like `(set! *unchecked-laziness* :warn-on-lazy)? We 
> can relive the ignominious history of "$!" in Haskell. 
>
 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from 

Re: What to read after 3 dozen "introduction to transducers" blog posts

2017-05-09 Thread Michael Willis
After he uses this one weird trick, you'll never guess what happens next!

On Saturday, May 6, 2017 at 11:56:13 AM UTC-6, Matching Socks wrote:
>
> This one.  
> https://tech.grammarly.com/blog/building-etl-pipelines-with-clojure
>
> "To be honest, this is a somewhat advanced usage of the transducers 
> machinery," says the Grammarly Engineering Blog, right after shoehorning a 
> BufferedReader into the mold with "reify IReduceInit".  I already felt I'd 
> got my money's worth from reading up to this half-way point.  But I was 
> astonished at what came next.  
>
>

-- 
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.