Re: println / for unexpected behaviour

2013-11-26 Thread Gary Verhaegen
But it is indeed a characteristic of the seq. The repl reads and evals the
for expression, which yields a lazy seq, so basically nothing has happened
at this point.

Then the repl needs to print the result. So first it prints an open
parenthesis as the result is a seq. Then it needs to evaluate the first
element of the seq to print it. In the course of the evaluation, it
executes the println., so you get your first row after the open
parenthesis. But the rows are not part of the return value, only the seq of
nils is the return value. The fact that the rows appear to be part of the
seq is an accident of the order of evaluation.

Now you know why you don't get

[:empty ...] ... (nil ...)

But perhaps, given the explanation I just gave, you would expect something
like:

([:empty ...]nil [:empty ...]nil ...)

This is where chunked seq come in, according to Cedric. A chunked seq is a
lazy seq, but instead of evaluating its elements one at a time when they
are required, it evaluates them in chunks. So when the dirst element is
requested of the lazy seq, it immediately realize the first, say, 32
elements. So you get all the prints before any nil.

Hope that helps.

On Tuesday, 26 November 2013, wrote:

> Thanks Stefan.
>
> I had a suspicion that it was to do with for's laziness but I had assumed
> it was a characteristic of the seq it built rather than the forms inside
> it. Seems a bit strange but will have to get used to it :-)
>
> On Monday, November 25, 2013 2:11:45 PM UTC, Stefan Kamphausen wrote:
>>
>> Hi Edward,
>>
>>
>> you are being hit by laziness here.  Clojure's 'for' is not like the
>> 'for' you may know from other programming languages.  It is made for list
>> comprehensions, that is it is building new list-y things.  It does not do
>> this instantly, the items may be realized only when the caller asks for
>> them.  In your case the caller is your REPL which prints the return value,
>> thereby realizing the lazy sequence.  Thus, the output for the REPL and
>> your println mix.
>>
>> As Cedric already wrote, if you want to process the board for side-effect
>> like printing, use doseq.  Use for only for its return value and make no
>> assumptions as to when those values are created.
>>
>>
>> Kind regards,
>> Stefan
>>
>  --
> --
> 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 '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  'clojure%2bunsubscr...@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  'clojure%2bunsubscr...@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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: CloudFormation template generation with Clojure

2013-11-26 Thread Kevin Bell
Hey Craig,

Thanks for the input. Forgive my naiveté, but I gather you're implying that 
the DSL-ishness is desirable? That makes sense, and it seems to be inline 
with what I'm learning about the lisp mindset. 

You're suggestion is actually a lot more like an option that I was 
considering but didn't do because it seemed to depart from things like 
project.clj that I was emulating. But it might actually make sense to take 
it a step further to make the scoping within CloudFormation templates more 
explicit.

I updated my gist with an even more DSL-like 
concept: https://gist.github.com/bellkev/7653342

On Monday, November 25, 2013 11:49:20 PM UTC-8, Craig wrote:
>
>
> I don't know much about CF templates, but stripping some detail from your 
> middle fragment moves further from data and to a DSL:
>
> (deftemplate my-template
>   :aws-template-format-version "2010-09-09"
>   :description "My description"
>   
>   (param my-parameter :type :string :description "My string parameter")
>   
>   (mapping my-mapping
>:first-level-key-one {:second-level-key-one "Value"}
>:first-level-key-two {:second-level-key-two "Another Value"})
>   
>   (condition my-condition (not my-parameter))
>   (condition my-second-condition (= (-> my-mapping :first-level-key-one 
> :second-level-key-one) my-parameter))
>   
>   (resource my-instance aws.ec2/instance :image-id "ami-79fd7eee")
>   
>   (output my-first-output (:instance-type my-instance))
>   (output my-second-output my-parameter))
>
> Craig
>
>
> On Tuesday, November 26, 2013 3:41:29 PM UTC+11, Kevin Bell wrote:
>>
>> Hey folks, I'm working on a tool to enable the generation of AWS 
>> CloudFormation templates using a Clojure-based syntax kind of like 
>> leiningen's project.clj. I'm working on how the syntax should look to be 
>> most clojurey, and I wonder if anyone has some input: 
>> https://gist.github.com/bellkev/7653342
>>
>> I should add that I'm very new to Clojure and using this project as an 
>> opportunity to learn more about the language internals. So please forgive 
>> any particularly non-idiomatic Clojure...
>>
>> Thanks!!
>>
>

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


Best Practice For Logging vs. Functional (and Elegant)

2013-11-26 Thread Stefan Kamphausen
Hi,


logging is a side-effect and I try to keep it out of the functional parts 
of my code.

But even for the parts where I want to introduce logging I find that it 
renders code less readable.


As an example, say you've got an 'if-let' somewhere

(if-let [a (do-something-non-trivial-with-some-local-args)]
  (make-use-of-a)
  (return-a-reasonable-default))

That piece of code is concise, readable, nicely indented, etc.  However, 
when logging comes along, it becomes ugly quickly, at least to my eye:


(if-let [a (do-something-non-trivial-with-some-local-args)]
  (do (log/debug "got a reasonable a:" a)
  (make-use-of-a))
  (do (log/warn "using a dangerous default")
  (return-a-reasonable-default)))

I wonder, how you deal with such situations.  Do you get rid of all those 
do's, e.g. with a 'logged' ('debugged', 'warned', etc) macro which takes 
some logging args and a body in any way? Do you wrap functions in 
tracing-like logging entities and log e.g. at the level of '
do-something-non-trivial-with-some-local-args'? Or are you just happy with 
the 'do'?

The only other thread I could find on this list which discussed related 
issues was https://groups.google.com/d/msg/clojure/B2Wo5Oe1OrI/Y_eznCx3R7YJ 
and I will think a bit about Herwig's reader tag approach.


Regards,
stefan

-- 
-- 
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: CloudFormation template generation with Clojure

2013-11-26 Thread Jeroen van Dijk
Hi Kevin,

I've created some kind of wrapper around CF templates too. It is too
immature (and ugly) to open source it, but I think it has some nice
features, like Ref checking, templating for userdata and schema validation
of the CF resources via Prismatic Schema.

Can you elaborate on what kind of features you would like to support? Are
you just deciding on DSL syntax or do you have already some kind of Clojure
layer working?

About the DSL, in the end I decided to stick closer to the CF syntax to
avoid confusion and documentation mismatches. So for instance, all my
parameters for a CF resource are CamelCase. One of the most important
features for me is the validation on missing fields and Reference checking.

If you are interested in collaborating in this, please let me know.

Cheers,
Jeroen





On Tue, Nov 26, 2013 at 9:11 AM, Kevin Bell  wrote:

> Hey Craig,
>
> Thanks for the input. Forgive my naiveté, but I gather you're implying
> that the DSL-ishness is desirable? That makes sense, and it seems to be
> inline with what I'm learning about the lisp mindset.
>
> You're suggestion is actually a lot more like an option that I was
> considering but didn't do because it seemed to depart from things like
> project.clj that I was emulating. But it might actually make sense to take
> it a step further to make the scoping within CloudFormation templates more
> explicit.
>
> I updated my gist with an even more DSL-like concept:
> https://gist.github.com/bellkev/7653342
>
>
> On Monday, November 25, 2013 11:49:20 PM UTC-8, Craig wrote:
>>
>>
>> I don't know much about CF templates, but stripping some detail from your
>> middle fragment moves further from data and to a DSL:
>>
>> (deftemplate my-template
>>   :aws-template-format-version "2010-09-09"
>>   :description "My description"
>>
>>   (param my-parameter :type :string :description "My string parameter")
>>
>>   (mapping my-mapping
>>:first-level-key-one {:second-level-key-one "Value"}
>>:first-level-key-two {:second-level-key-two "Another Value"})
>>
>>   (condition my-condition (not my-parameter))
>>   (condition my-second-condition (= (-> my-mapping :first-level-key-one
>> :second-level-key-one) my-parameter))
>>
>>   (resource my-instance aws.ec2/instance :image-id "ami-79fd7eee")
>>
>>   (output my-first-output (:instance-type my-instance))
>>   (output my-second-output my-parameter))
>>
>> Craig
>>
>>
>> On Tuesday, November 26, 2013 3:41:29 PM UTC+11, Kevin Bell wrote:
>>>
>>> Hey folks, I'm working on a tool to enable the generation of AWS
>>> CloudFormation templates using a Clojure-based syntax kind of like
>>> leiningen's project.clj. I'm working on how the syntax should look to be
>>> most clojurey, and I wonder if anyone has some input:
>>> https://gist.github.com/bellkev/7653342
>>>
>>> I should add that I'm very new to Clojure and using this project as an
>>> opportunity to learn more about the language internals. So please forgive
>>> any particularly non-idiomatic Clojure...
>>>
>>> Thanks!!
>>>
>>  --
> --
> 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.
>

-- 
-- 
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: [ANN] Optimus - a Ring middleware for frontend performance optimization.

2013-11-26 Thread Magnar Sveen
Hi Paul! Thanks for chiming in.

I set out to create a suite of middlewares for frontend optimization. The 
first was Catenate, which concerned itself with concatenation into bundles. 
So I certainly agree with your points. You'd be hard pressed to think 
otherwise in the Clojure community, I think, with its focus on 
"decomplecting". The reason I gave up on that idea is two-fold:

- The different optimizations are not orthogonal.
- Assets aren't first class in the Ring middleware stack.

Some examples:

- When you bundle files together, your HTML has to reference either the 
bundle URL (in prod) or all the individual files (in dev). There has to be 
some sort of lookup from the bundle ID to a list of URLs, and this is 
dependent on your asset-serving strategy.
 
- When you add cache-busters to URLs, you need some sort of lookup from the 
original URL to the cache-busted URL, so you can link to them with a known 
name.

In other words, both the bundle middleware and the cache-busting middleware 
either needs to own the list of assets, or it needs to rest on a first 
class asset concept in the stack.

Now add the ability to serve WebP images to browsers that support it. Not 
only do you have to change the image URLs, but you also have to serve a 
different set of CSS to use these new images. So this middleware would have 
to know which CSS files reference which files, and rewrite them. 

All of these could be fixed with a well-thought out Asset concept in the 
ring middleware stack. Which is what Optimus is an attempt at. It adds a 
list of assets to the request, with enough information for the linking 
functions to figure out which versions of which files to link.

But then there's the orthogonality:

   - You can't add cache-busters first, and then bundle assets together, 
   since you wouldn't get cache buster URLs on your bundles.
   - If you minify first, then bundle, you'll get suboptimal minification 
   results in production. If you bundle first, then minify, you won't know 
   which file is to blame for errors in development.
   - You should never add far-future expires headers unless the asset has a 
   cache-buster URL.

So ordering matters. You can't just throw in another middleware, you have 
to order it just so-and-so. I started writing documentation for this in 
Catenate. It would say "If you're also using cache-busting middleware, make 
sure to place it after Catenate." After writing a few of those sentences, I 
came to the conclusion that they were not entirely separate things. Since 
they're so dependent on each other, they should live together.

There's also the case of *when* to optimize. In production you want to 
optimize once - either as a build step, or when starting the application. 
In development you don't want any optimization (unless you're debugging), 
but you still need to create the list of assets so you're able to link to 
it. This is something all the optimization middlewares would have to tackle 
on their own - basically each layer freezing their optimized assets on 
server start, and all but the last one doing so in vain.

Optimus solves this by creating a separate middleware stack for 
optimizations, that work on assets (not requests), and that can be done at 
different times by different asset-serving strategies.

So, in conclusion: If we can agree on a data format for assets - the one in 
Optimus has been through quite a few iterations 
(https://github.com/magnars/optimus#what-are-these-assets-anyway-they-seem-magical-to-me)
 
- then we could build on that to create separate middlewares. But not 
middlewares for the Ring stack. It would have to be Asset-specific 
middlewares.

For instance, even tho Optimus doesn't do transpiling, building a 
transpiler to fit in the Optimus asset middleware stack is pretty nice. You 
let :original-url be the original "styles.less", so the linking features 
can find it, replace the :contents with CSS, and serve it under the :path 
"styles.css". If your package takes a list of assets, and returns a list of 
assets with all .less files changed like this, you can plug it in with no 
modifications to Optimus. 

- Magnar


On Tuesday, November 26, 2013 3:12:28 AM UTC+1, Paul Biggar wrote:
>
> [FYI: I'm the author/forker of stefon]
>
> These libraries aren't bad, but to be honest, I think we've done it all 
> wrong. We're just all scratching our own itches, not writing reusable 
> components (unlike most of the rest of the clojure web ecosystem).
>
> If you look at stefon, you get a set of non-composable functions, designed 
> for my exact use case. Optimus, cornet, and dieter all suffer from the same 
> problems.
>
> Cornet, supports compilation (with different compiler and versions from 
> stefon), serving assets, and configuring itself from a JVM command line. It 
> also has :dev and :prod modes (though these mean "dont minify" and "do 
> minify". It does split out the functions in a slightly composable way (you 
> can have `(wrap-lesscss

Re: [ClojureScript] [ANN] cljs-start 0.0.5

2013-11-26 Thread Deniz Kurucu
Thanks, that worked !


On Tue, Nov 26, 2013 at 1:15 AM, Mimmo Cosenza wrote:

> you need to upgrade to leiningen >= 2.2.0
>
> lein upgrade # from the terminal
>
>
> On Nov 25, 2013, at 8:18 PM, Deniz Kurucu  wrote:
>
>
>
>
> On Mon, Nov 25, 2013 at 8:59 PM, Mimmo Cosenza wrote:
>
>> what are:
>>
>> - you operating system
>>
>
> Ubuntu 12.04 64 bit
>
>
>> - java virtual machine (java -version # from the terminal)
>>
>
> java version "1.7.0_45"
> Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
> Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
>
>
>
>> - leiningen version (lein version # from the terminal)
>>
>>
> Leiningen 2.1.3 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
>
>
>
>> Have you tried to create a project with others lein-template? e.g.
>>
>> https://github.com/konrad-garus/cljs-kickoff
>>
>
> Yes, that one works.
>
>
>>
>> thanks
>>
>> mimmo
>>
>>
> Thanks.
>
>
>> On Nov 25, 2013, at 6:02 PM, Deniz Kurucu  wrote:
>>
>>
>> Hi,
>>
>> both didn't work. Any other ideas ?
>>
>> lein new cljs-start coolappp
>>
>> Generating fresh 'lein new' cljs-start project.
>> Template resource 'leiningen/new/cljs_start/README.MD '
>> not found.
>>
>>
>> On Mon, Nov 25, 2013 at 5:20 PM, Mimmo Cosenza 
>> wrote:
>>
>>> Hi,
>>>
>>
>>
>>> try the following:
>>>
>>> rm -rf ~/.m2/repository/cljs-start
>>>
>>> and run again
>>>
>>> lein new cljs-start youlibname
>>>
>>> If this does not work try the following
>>>
>>> git clone https://github.com/magomimmo/cljs-start.git
>>> cd cljs-start
>>> lein install
>>>
>>>
>>> and try again to create the project with
>>>
>>> lein new cljs-start yourlibname
>>>
>>> LTM if it works.
>>>
>>> mimmo
>>>
>>>
>>> On Nov 25, 2013, at 4:06 PM, Deniz Kurucu  wrote:
>>>
>>> Hi,
>>>
>>> When i run lein new cljs-start wonderful-lib
>>>
>>> I'm getting that error and nothing is created.
>>>
>>> Generating fresh 'lein new' cljs-start project.
>>> Template resource 'leiningen/new/cljs_start/README.MD'
>>> not found.
>>>
>>> Thanks.
>>>
>>>
>>>
>>> On Mon, Nov 25, 2013 at 4:24 PM, Mimmo Cosenza 
>>> wrote:
>>>

 On Nov 25, 2013, at 10:42 AM, Mimmo Cosenza 
 wrote:

 I'm preparing an example on how to use cljs-start with an already
 implemented cljs lib (I'll use hiccups as an example). If you have a little
 of patient tomorrow should be published.


 Hi Tom, here is the sample I was talking about. It use the already
 implemented hiccups lib to demonstrate by instrumenting it with cljs-start.

 https://github.com/magomimmo/cljs-start/blob/master/doc/sample.md

 Inside you'll also find a brepling session with the instrumented
 hiccups. I don't know why nobody documents any brepl session (even me. in
 the modern-cljs series I should say something more about this task which is
 very, very important to become productive in cljs).

 I hope to contribute a little bit in modifying for the next year the
 results of the recent survey conducted by the tireless Chas Emerick.


 HIH
 Mimmo



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

>>>
>>>
>>> --
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "ClojureScript" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojurescript+unsubscr...@googlegroups.com.
>>> To post to this group, send email to clojurescr...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>
>>>
>>>
>>> --
>>> --
>>> 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 unsubscr

Re: CloudFormation template generation with Clojure

2013-11-26 Thread Craig

Kevin,

Typical advice is to not use macros (implicitly used in the gists to build 
a CF DSL) when functions or data will suffice. Sometimes however the 
syntactic sugar is quite tasty and hard to overlook. I do not have enough 
knowledge of the domain to suggest what might be the correct approach in 
this case.

Some additional comments:
- your use of with-foo pattern is not idiomatic afaics; this pattern is 
typically used to scope run-time resource usage
- in relation to parameters: the means by which defrecord introduces record 
attributes may be instructive (if you go the DSL route)

rgds
Craig

On Tuesday, November 26, 2013 7:11:42 PM UTC+11, Kevin Bell wrote:
>
> Hey Craig,
>
> Thanks for the input. Forgive my naiveté, but I gather you're implying 
> that the DSL-ishness is desirable? That makes sense, and it seems to be 
> inline with what I'm learning about the lisp mindset. 
>
> You're suggestion is actually a lot more like an option that I was 
> considering but didn't do because it seemed to depart from things like 
> project.clj that I was emulating. But it might actually make sense to take 
> it a step further to make the scoping within CloudFormation templates more 
> explicit.
>
> I updated my gist with an even more DSL-like concept: 
> https://gist.github.com/bellkev/7653342
>
> On Monday, November 25, 2013 11:49:20 PM UTC-8, Craig wrote:
>>
>>
>> I don't know much about CF templates, but stripping some detail from your 
>> middle fragment moves further from data and to a DSL:
>>
>> (deftemplate my-template
>>   :aws-template-format-version "2010-09-09"
>>   :description "My description"
>>   
>>   (param my-parameter :type :string :description "My string parameter")
>>   
>>   (mapping my-mapping
>>:first-level-key-one {:second-level-key-one "Value"}
>>:first-level-key-two {:second-level-key-two "Another Value"})
>>   
>>   (condition my-condition (not my-parameter))
>>   (condition my-second-condition (= (-> my-mapping :first-level-key-one 
>> :second-level-key-one) my-parameter))
>>   
>>   (resource my-instance aws.ec2/instance :image-id "ami-79fd7eee")
>>   
>>   (output my-first-output (:instance-type my-instance))
>>   (output my-second-output my-parameter))
>>
>> Craig
>>
>>
>> On Tuesday, November 26, 2013 3:41:29 PM UTC+11, Kevin Bell wrote:
>>>
>>> Hey folks, I'm working on a tool to enable the generation of AWS 
>>> CloudFormation templates using a Clojure-based syntax kind of like 
>>> leiningen's project.clj. I'm working on how the syntax should look to be 
>>> most clojurey, and I wonder if anyone has some input: 
>>> https://gist.github.com/bellkev/7653342
>>>
>>> I should add that I'm very new to Clojure and using this project as an 
>>> opportunity to learn more about the language internals. So please forgive 
>>> any particularly non-idiomatic Clojure...
>>>
>>> Thanks!!
>>>
>>

-- 
-- 
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: [ClojureScript] [ANN] cljs-start 0.0.5

2013-11-26 Thread Mimmo Cosenza
Good. 
I added the version requirement in the README (sorry to have forgotten that 
before).

mimmo

On Nov 26, 2013, at 12:02 PM, Deniz Kurucu  wrote:

> Thanks, that worked !
> 
> 
> On Tue, Nov 26, 2013 at 1:15 AM, Mimmo Cosenza  
> wrote:
> you need to upgrade to leiningen >= 2.2.0
> 
> lein upgrade # from the terminal
> 
> 
> On Nov 25, 2013, at 8:18 PM, Deniz Kurucu  wrote:
> 
>> 
>> 
>> 
>> On Mon, Nov 25, 2013 at 8:59 PM, Mimmo Cosenza  
>> wrote:
>> what are:
>> 
>> - you operating system
>> 
>> Ubuntu 12.04 64 bit
>>  
>> - java virtual machine (java -version # from the terminal)
>> 
>> java version "1.7.0_45"
>> Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
>> Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
>> 
>>  
>> - leiningen version (lein version # from the terminal)
>> 
>> 
>> Leiningen 2.1.3 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
>> 
>>  
>> Have you tried to create a project with others lein-template? e.g. 
>> 
>> https://github.com/konrad-garus/cljs-kickoff
>> 
>> Yes, that one works.
>>  
>>  
>> thanks
>> 
>> mimmo
>> 
>> 
>> Thanks.
>>  
>> On Nov 25, 2013, at 6:02 PM, Deniz Kurucu  wrote:
>> 
>>> 
>>> Hi,
>>> 
>>> both didn't work. Any other ideas ?
>>> 
>>> lein new cljs-start coolappp
>>> 
>>> Generating fresh 'lein new' cljs-start project.
>>> Template resource 'leiningen/new/cljs_start/README.MD' not found.
>>> 
>>> 
>>> On Mon, Nov 25, 2013 at 5:20 PM, Mimmo Cosenza  
>>> wrote:
>>> Hi,
>>>  
>>> try the following:
>>> 
>>> rm -rf ~/.m2/repository/cljs-start
>>> 
>>> and run again
>>> 
>>> lein new cljs-start youlibname
>>> 
>>> If this does not work try the following
>>> 
>>> git clone https://github.com/magomimmo/cljs-start.git
>>> cd cljs-start
>>> lein install
>>> 
>>> 
>>> and try again to create the project with
>>> 
>>> lein new cljs-start yourlibname
>>> 
>>> LTM if it works.
>>> 
>>> mimmo
>>> 
>>> 
>>> On Nov 25, 2013, at 4:06 PM, Deniz Kurucu  wrote:
>>> 
 Hi,
 
 When i run lein new cljs-start wonderful-lib
 
 I'm getting that error and nothing is created.
 
 Generating fresh 'lein new' cljs-start project.
 Template resource 'leiningen/new/cljs_start/README.MD' not found.
 
 Thanks.
 
 
 
 On Mon, Nov 25, 2013 at 4:24 PM, Mimmo Cosenza  
 wrote:
 
 On Nov 25, 2013, at 10:42 AM, Mimmo Cosenza  
 wrote:
 
> I'm preparing an example on how to use cljs-start with an already 
> implemented cljs lib (I'll use hiccups as an example). If you have a 
> little of patient tomorrow should be published. 
> 
 
 Hi Tom, here is the sample I was talking about. It use the already 
 implemented hiccups lib to demonstrate by instrumenting it with cljs-start.
 
 https://github.com/magomimmo/cljs-start/blob/master/doc/sample.md
 
 Inside you'll also find a brepling session with the instrumented hiccups. 
 I don't know why nobody documents any brepl session (even me. in the 
 modern-cljs series I should say something more about this task which is 
 very, very important to become productive in cljs). 
 
 I hope to contribute a little bit in modifying for the next year the 
 results of the recent survey conducted by the tireless Chas Emerick.
 
 
 HIH 
 Mimmo
 
 
 
 -- 
 -- 
 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.
 
 
 -- 
 Note that posts from new members are moderated - please be patient with 
 your first post.
 --- 
 You received this message because you are subscribed to the Google Groups 
 "ClojureScript" group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.
>>> 
>>> 
>>> -- 
>>> -- 
>>> 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
>>> c

Re: Access the datastructure used to create a function?

2013-11-26 Thread henry w
Sad not to get any replies - even to tell me if it is a bad idea or not 
possible. :-(

Assuming it is not possible, am I right in saying that at the moment, in 
Clojure, 'code is data' really only applies until code is compiled? 

I realise compiled functions can still be passed around, assigned to vars 
and so on.


-- 
-- 
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: [ANN] Optimus - a Ring middleware for frontend performance optimization.

2013-11-26 Thread Stefan Kamphausen
Hi,

I'd be very interested in learning, how Twixt[1] compares to Optimus and 
the other solutions cited.

[1] https://github.com/AvisoNovate/twixt/


Regards,
stefan

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Max Penet
The best you can do is probably mess with 
https://github.com/technomancy/serializable-fn, but maybe trying to 
describe what you are trying to do at a higher level would help, most of 
the time using serializable-fn is a bad idea (symptom of one).


On Thursday, November 21, 2013 7:14:39 PM UTC+1, henry w wrote:
>
> Say you have a function created like this:
>
> (fn [x] (+ x y))
>
> and then you have a reference to an instance of this function, is there 
> some way to use the function reference to access the list '(fn [x] (+ x y)),
> including the symbol 'y' (such that you could dereference 'y' and get its 
> value)? The source function is not the right thing and so far googling 
> hasn't got me the answer.
>
> Thanks
>

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Guru Devanla
Hi,

This may not be the answer you are looking for. But, kooking at the example
you gave, you will need to execution environment of the function to
determine the binding of y. It could vary based on where it is invoked.
That is because, if the function call was wrapped inside a 'binding form
then the value of y would be different. And, isn't this something that is
determined during execution of the function?

Example:

(def ^:dynamic y 10)

(defn testfn [x]
(+ x y))

(testfn 10)

==> print 20

(binding [y 100]
 (testfn 10))

==> prints 110.


So, unless you want to assume the free variables are always lexically
scoped, that value you may want to deref would vary.

Maybe you have a very specific scenario where you need to do what you want.
More details would help.

Thanks
Guru





On Tue, Nov 26, 2013 at 4:19 AM, henry w  wrote:

> Sad not to get any replies - even to tell me if it is a bad idea or not
> possible. :-(
>
> Assuming it is not possible, am I right in saying that at the moment, in
> Clojure, 'code is data' really only applies until code is compiled?
>
> I realise compiled functions can still be passed around, assigned to vars
> and so on.
>
>
>  --
> --
> 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.
>

-- 
-- 
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: println / for unexpected behaviour

2013-11-26 Thread Alex Miller
Realizing a lazy sequence incurs overhead on every item. Chunked seqs amortize 
that cost by realizing a chunk of items at a time giving you better overall 
performance at the cost of less laziness.

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Jamie Brandon
> (def f (let [y 1] (fn [x] (+ x y

Let's have a look inside.

> (require '[no.disassemble :refer [disassemble]])
> (println (disassemble f))
// Compiled from /home/jamie/strucjure/src/strucjure.clj (version 1.5
: 49.0, super bit)
public final class strucjure$fn__5589$fn__5590 extends clojure.lang.AFunction {

  // Field descriptor #7 Lclojure/lang/Var;
  public static final clojure.lang.Var const__0;

  // Field descriptor #25 Lclojure/lang/IPersistentMap;
  final clojure.lang.IPersistentMap __meta;

  // Field descriptor #27 J
  long y;


So there is the field you want.

> (.y f)
java.lang.IllegalArgumentException: No matching field found: y for
class strucjure$eval5552$fn__5553 Reflector.java:271
clojure.lang.Reflector.getInstanceField Reflector.java:300
clojure.lang.Reflector.invokeNoArgInstanceMember
/home/jamie/strucjure/src/strucjure.clj:21 strucjure/eval5556

Humbug.

> (require '[clojure.reflect :refer [reflect]])
> (reflect f)
java.lang.ClassNotFoundException: strucjure$eval5552$fn__5553

Interesting... I would love to know why that is the case.

> (into [] (.. f getClass getDeclaredFields))

[# #
#]

> (defn get-field [instance field-name]
  (let [field (first (filter #(= field-name (.getName %)) (.. instance
getClass getDeclaredFields)))]
(.setAccessible field true)
(.get field instance)))
> (get-field f "y")
1

Success! And just for fun:

> (def f2 (strucjure$fn__5589$fn__5590 7))
> (f2 1)
8

I hope that helps. Now the more interesting question is why you would
want to do that...


On 21 November 2013 18:14, henry w  wrote:
> Say you have a function created like this:
>
> (fn [x] (+ x y))
>
> and then you have a reference to an instance of this function, is there some
> way to use the function reference to access the list '(fn [x] (+ x y)),
> including the symbol 'y' (such that you could dereference 'y' and get its
> value)? The source function is not the right thing and so far googling
> hasn't got me the answer.
>
> Thanks
>
> --
> --
> 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.

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


ClojureCLR 1.5.1 compiler problem

2013-11-26 Thread Brian Barnes
I'm not sure this is the correct place for this, but the GitHub page led me 
to this place.
 
I believe I have found a problem in the 1.5.1 ClojureCLR currently on 
GitHub. The problem is with the initialization of the static Compiler class.
 
According to section 10.4.5.1 of the MSDN documentation, the fields of a 
static class are evaluated "in textual order".
 
Unfortunately, this line:
 
public static readonly Symbol FnOnceSym = (Symbol) 
Symbol.intern("fn*").withMeta(RT.map(Keyword.intern(null, "once"), true));
 
 
comes before this line:
 
static Dictionary _duplicateTypeMap = new Dictionary();
 
The evaluation of the first causes a call to the static method 
FindDuplicateType() within the same class, and this method uses the 
_duplicateTypeMap without a null check. This causes a null exception to be 
thrown because the initializer for _duplicateTypeMap hasn't executed yet.
 
My solution is to add a section at the very top of the Compiler class for 
"dependency" intializations - consisiting only of the initialization of 
_duplicateTypeMap at this point, to give a home to all such initializations 
that get used by the other static initializers.
 
There is no "Issues" section on the GitHub page, or I would have logged an 
issue there. Please let me know the best way to get this issue evaluated 
for a future release of the compiler.
 
Brian C. Barnes
 

-- 
-- 
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: [ANN] Overtone 0.9.0 Released

2013-11-26 Thread Joseph Burnett
Sweet!

On Monday, November 25, 2013 8:46:44 AM UTC-8, Sam Aaron wrote:
>
> Hi there noise polluters! 
>
> It's that glorious time again - another version of Overtone has forced its 
> timbral wings out of its cocoon. 0.9.0 is here and is edgy. It was so edgy, 
> that it burst into flames and mutated into 0.9.1 before a blink of the 
> eye![1] 
>
> This release represents a fundamental shift in our development approach. 
> Instead of designing and implementing new abstractions that may possibly 
> prove useful, all of the features and modifications in 0.9.1 have been 
> implemented as a reaction to specific performance/composition requirements. 
>
> One of our major users is the Clojure powered band Meta-eX[2] and they 
> have been using and testing 0.9.1 in all of their recent gigs, including a 
> straight hour techno set in Club Noxx, Antwerp. Now, that's real 
> performance testing ;-) 
>
> So, what's new? Well, let me invite you to read our Changelog[3] which is 
> much more detailed than previous versions. Major improvements/contributions 
> can be summarised as follows: 
>
> * apply-by/at improvements 
> * Improved Synth Positioning Syntax 
> * MIDI API revamp 
> * New Graphviz support 
> * Bus Monitoring system 
> * Simple Persistent Store 
> * More pervasive stop fns 
> * Node event handlers 
> * Improved envelope helper fns 
> * New workshop examples 
>
> As usual, let us know your thoughts and experiences over on the Overtone 
> mailing list: 
>
> http://groups.google.com/group/overtone/ 
>
> Happy Hacking! 
>
> Sam 
>
>  
> http://sam.aaron.name
>  
>
>
> [1]: 
> https://github.com/overtone/overtone/commit/ec66e790ca14ce36fb9a7c50804e72a3d23ff2bf
>  
> [2]: 
> http://meta-ex.com
>  
> [3]: 
> https://github.com/overtone/overtone/blob/master/CHANGELOG.md

-- 
-- 
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: println / for unexpected behaviour

2013-11-26 Thread Cedric Greevey
On Tue, Nov 26, 2013 at 8:58 AM, Alex Miller  wrote:

> Realizing a lazy sequence incurs overhead on every item. Chunked seqs
> amortize that cost by realizing a chunk of items at a time giving you
> better overall performance at the cost of less laziness.
>

And in this case that resulted in all the side effects occurring before any
of the "nil"s were printed, instead of the [:empty :empty...] vectors being
interleaved with the nils in the output.

-- 
-- 
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: [ANN] Overtone 0.9.0 Released

2013-11-26 Thread Cedric Greevey
Is there a turnkey download/install/play with version of this yet, or is
that not until 1.0?


On Tue, Nov 26, 2013 at 10:24 AM, Joseph Burnett
wrote:

> Sweet!
>
>
> On Monday, November 25, 2013 8:46:44 AM UTC-8, Sam Aaron wrote:
>>
>> Hi there noise polluters!
>>
>> It's that glorious time again - another version of Overtone has forced
>> its timbral wings out of its cocoon. 0.9.0 is here and is edgy. It was so
>> edgy, that it burst into flames and mutated into 0.9.1 before a blink of
>> the eye![1]
>>
>> This release represents a fundamental shift in our development approach.
>> Instead of designing and implementing new abstractions that may possibly
>> prove useful, all of the features and modifications in 0.9.1 have been
>> implemented as a reaction to specific performance/composition requirements.
>>
>> One of our major users is the Clojure powered band Meta-eX[2] and they
>> have been using and testing 0.9.1 in all of their recent gigs, including a
>> straight hour techno set in Club Noxx, Antwerp. Now, that's real
>> performance testing ;-)
>>
>> So, what's new? Well, let me invite you to read our Changelog[3] which is
>> much more detailed than previous versions. Major improvements/contributions
>> can be summarised as follows:
>>
>> * apply-by/at improvements
>> * Improved Synth Positioning Syntax
>> * MIDI API revamp
>> * New Graphviz support
>> * Bus Monitoring system
>> * Simple Persistent Store
>> * More pervasive stop fns
>> * Node event handlers
>> * Improved envelope helper fns
>> * New workshop examples
>>
>> As usual, let us know your thoughts and experiences over on the Overtone
>> mailing list:
>>
>> http://groups.google.com/group/overtone/
>>
>> Happy Hacking!
>>
>> Sam
>>
>> 
>> http://sam.aaron.name
>>
>>
>> [1]: https://github.com/overtone/overtone/commit/
>> ec66e790ca14ce36fb9a7c50804e72a3d23ff2bf
>> [2]: 
>> http://meta-ex.com
>> [3]: 
>> https://github.com/overtone/overtone/blob/master/CHANGELOG.md
>
>  --
> --
> 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.
>

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Guru Devanla
Hi Jamie,

Thats interesting. How do I not let the compiler not optimize away the fact
that y refers to the constant. When I run your program I have two constant
fields defined rather than 'y. Am I missing something.

Thanks
Guru


On Tue, Nov 26, 2013 at 6:16 AM, Jamie Brandon  wrote:

> > (def f (let [y 1] (fn [x] (+ x y
>
> Let's have a look inside.
>
> > (require '[no.disassemble :refer [disassemble]])
> > (println (disassemble f))
> // Compiled from /home/jamie/strucjure/src/strucjure.clj (version 1.5
> : 49.0, super bit)
> public final class strucjure$fn__5589$fn__5590 extends
> clojure.lang.AFunction {
>
>   // Field descriptor #7 Lclojure/lang/Var;
>   public static final clojure.lang.Var const__0;
>
>   // Field descriptor #25 Lclojure/lang/IPersistentMap;
>   final clojure.lang.IPersistentMap __meta;
>
>   // Field descriptor #27 J
>   long y;
> 
>
> So there is the field you want.
>
> > (.y f)
> java.lang.IllegalArgumentException: No matching field found: y for
> class strucjure$eval5552$fn__5553 Reflector.java:271
> clojure.lang.Reflector.getInstanceField Reflector.java:300
> clojure.lang.Reflector.invokeNoArgInstanceMember
> /home/jamie/strucjure/src/strucjure.clj:21 strucjure/eval5556
>
> Humbug.
>
> > (require '[clojure.reflect :refer [reflect]])
> > (reflect f)
> java.lang.ClassNotFoundException: strucjure$eval5552$fn__5553
>
> Interesting... I would love to know why that is the case.
>
> > (into [] (.. f getClass getDeclaredFields))
>
> [# strucjure$fn__5589$fn__5590.const__0> # clojure.lang.IPersistentMap strucjure$fn__5589$fn__5590.__meta>
> #]
>
> > (defn get-field [instance field-name]
>   (let [field (first (filter #(= field-name (.getName %)) (.. instance
> getClass getDeclaredFields)))]
> (.setAccessible field true)
> (.get field instance)))
> > (get-field f "y")
> 1
>
> Success! And just for fun:
>
> > (def f2 (strucjure$fn__5589$fn__5590 7))
> > (f2 1)
> 8
>
> I hope that helps. Now the more interesting question is why you would
> want to do that...
>
>
> On 21 November 2013 18:14, henry w  wrote:
> > Say you have a function created like this:
> >
> > (fn [x] (+ x y))
> >
> > and then you have a reference to an instance of this function, is there
> some
> > way to use the function reference to access the list '(fn [x] (+ x y)),
> > including the symbol 'y' (such that you could dereference 'y' and get its
> > value)? The source function is not the right thing and so far googling
> > hasn't got me the answer.
> >
> > Thanks
> >
> > --
> > --
> > 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.
>
> --
> --
> 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.
>

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Jamie Brandon
Guru, I'm not sure. Are you running it exactly the same way?

If you did...

(def y 1)
(def f (fn [x] (+ x y)))

...then I think that would result in two const fields instead, because
it stores the var #'y as a static field and calls getRawRoot on it at
runtime.

Otherwise I'm not sure.

On 26 November 2013 17:11, Guru Devanla  wrote:
> Hi Jamie,
>
> Thats interesting. How do I not let the compiler not optimize away the fact
> that y refers to the constant. When I run your program I have two constant
> fields defined rather than 'y. Am I missing something.
>
> Thanks
> Guru
>
>
> On Tue, Nov 26, 2013 at 6:16 AM, Jamie Brandon
>  wrote:
>>
>> > (def f (let [y 1] (fn [x] (+ x y
>>
>> Let's have a look inside.
>>
>> > (require '[no.disassemble :refer [disassemble]])
>> > (println (disassemble f))
>> // Compiled from /home/jamie/strucjure/src/strucjure.clj (version 1.5
>> : 49.0, super bit)
>> public final class strucjure$fn__5589$fn__5590 extends
>> clojure.lang.AFunction {
>>
>>   // Field descriptor #7 Lclojure/lang/Var;
>>   public static final clojure.lang.Var const__0;
>>
>>   // Field descriptor #25 Lclojure/lang/IPersistentMap;
>>   final clojure.lang.IPersistentMap __meta;
>>
>>   // Field descriptor #27 J
>>   long y;
>> 
>>
>> So there is the field you want.
>>
>> > (.y f)
>> java.lang.IllegalArgumentException: No matching field found: y for
>> class strucjure$eval5552$fn__5553 Reflector.java:271
>> clojure.lang.Reflector.getInstanceField Reflector.java:300
>> clojure.lang.Reflector.invokeNoArgInstanceMember
>> /home/jamie/strucjure/src/strucjure.clj:21 strucjure/eval5556
>>
>> Humbug.
>>
>> > (require '[clojure.reflect :refer [reflect]])
>> > (reflect f)
>> java.lang.ClassNotFoundException: strucjure$eval5552$fn__5553
>>
>> Interesting... I would love to know why that is the case.
>>
>> > (into [] (.. f getClass getDeclaredFields))
>>
>> [#> strucjure$fn__5589$fn__5590.const__0> #> clojure.lang.IPersistentMap strucjure$fn__5589$fn__5590.__meta>
>> #]
>>
>> > (defn get-field [instance field-name]
>>   (let [field (first (filter #(= field-name (.getName %)) (.. instance
>> getClass getDeclaredFields)))]
>> (.setAccessible field true)
>> (.get field instance)))
>> > (get-field f "y")
>> 1
>>
>> Success! And just for fun:
>>
>> > (def f2 (strucjure$fn__5589$fn__5590 7))
>> > (f2 1)
>> 8
>>
>> I hope that helps. Now the more interesting question is why you would
>> want to do that...
>>
>>
>> On 21 November 2013 18:14, henry w  wrote:
>> > Say you have a function created like this:
>> >
>> > (fn [x] (+ x y))
>> >
>> > and then you have a reference to an instance of this function, is there
>> > some
>> > way to use the function reference to access the list '(fn [x] (+ x y)),
>> > including the symbol 'y' (such that you could dereference 'y' and get
>> > its
>> > value)? The source function is not the right thing and so far googling
>> > hasn't got me the answer.
>> >
>> > Thanks
>> >
>> > --
>> > --
>> > 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.
>>
>> --
>> --
>> 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.
>
>
> --
> --
> 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 subscrib

Re: ClojureCLR 1.5.1 compiler problem

2013-11-26 Thread dmiller
I guess it doesn't matter that it works fine for me if it doesn't for you. 
:)
I'll post an issue.
Along with many other Clojure projects, issues and related items are on the 
JIRA site under dev.clojure.org.
For ClojureCLR, that is at http://dev.clojure.org/jira/browse/CLJCLR

-David


On Tuesday, November 26, 2013 8:03:53 AM UTC-6, Brian Barnes wrote:
>
> I'm not sure this is the correct place for this, but the GitHub page led 
> me to this place.
>  
> I believe I have found a problem in the 1.5.1 ClojureCLR currently on 
> GitHub. The problem is with the initialization of the static Compiler class.
>  
> According to section 10.4.5.1 of the MSDN documentation, the fields of a 
> static class are evaluated "in textual order".
>  
> Unfortunately, this line:
>  
> public static readonly Symbol FnOnceSym = (Symbol) 
> Symbol.intern("fn*").withMeta(RT.map(Keyword.intern(null, "once"), true));
>  
>  
> comes before this line:
>  
> static Dictionary _duplicateTypeMap = new Dictionary Type>();
>  
> The evaluation of the first causes a call to the static method 
> FindDuplicateType() within the same class, and this method uses the 
> _duplicateTypeMap without a null check. This causes a null exception to be 
> thrown because the initializer for _duplicateTypeMap hasn't executed yet.
>  
> My solution is to add a section at the very top of the Compiler class for 
> "dependency" intializations - consisiting only of the initialization of 
> _duplicateTypeMap at this point, to give a home to all such initializations 
> that get used by the other static initializers.
>  
> There is no "Issues" section on the GitHub page, or I would have logged an 
> issue there. Please let me know the best way to get this issue evaluated 
> for a future release of the compiler.
>  
> Brian C. Barnes
>  
>

-- 
-- 
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: CloudFormation template generation with Clojure

2013-11-26 Thread Kevin Bell
Hey Craig and Jeroen,

Jeroen:

Can you elaborate on what kind of features you would like to support? Are 
you just deciding on DSL syntax or do you have already some kind of Clojure 
layer working?

-My main goals are to create as "pretty" of a format for defining CF 
templates within Clojure syntax and support compiling/decompiling to/from 
JSON templates. I would definitely like to do some amount of validation, 
taking advantage of the 
schema
 and 
perhaps some of the logic from the eclipse 
plugin,
 
though I'm not sure yet how rigorous the validation should be.

-I think some really nice additional features would be some kind of 
launcher, perhaps done as a leiningen plugin and using amazonica, and 
simplified creation of custom CF resources, which are incredibly powerful 
and I think fit well with the principles of Clojure, as they are meant to 
be small, idempotent modules of functionality that follow a certain protocol

About the DSL, in the end I decided to stick closer to the CF syntax to 
avoid confusion and documentation mismatches. So for instance, all my 
parameters for a CF resource are CamelCase. One of the most important 
features for me is the validation on missing fields and Reference checking.

-I was thinking about this too and started with camel case, but I've been 
using AngularJS a lot lately, and I actually love the fact that it converts 
to/from hyphen-case and CamelCase as convention dictates, so I think I want 
to implement that. It shouldn't be too hard to do using some autocorrection 
of case based on the schema (above)

If you are interested in collaborating in this, please let me know.
-I'd love too. Please feel free to contact me at kevin.a.bell (at) gmail 

Craig:

Typical advice is to not use macros (implicitly used in the gists to build 
a CF DSL) when functions or data will suffice. Sometimes however the 
syntactic sugar is quite tasty and hard to overlook. I do not have enough 
knowledge of the domain to suggest what might be the correct approach in 
this case.
-That makes sense, and I was thinking about using functions for things like 
the mappings, resources, etc. However, it seems nice to have variables that 
can be reused later in the template. Keywords could work for this, but I 
feel like that gets a bit awkward if you look at what I was trying to do in 
the keyword-heavy version. One thing that struck me about the version using 
macro-defined variables though is that, since the whole template syntax 
ultimately just produces a big map, defining/using variables within it is 
equivalent to doing (def mymap {:first-key (def mystring "a") :second-key 
mystring}), which works, but is that weird?

Some additional comments:
- your use of with-foo pattern is not idiomatic afaics; this pattern is 
typically used to scope run-time resource usage
-This is something I've been struggling with a bit. The thing is that while 
CF templates are just JSON files, they actually have an explicit execution 
path and various scope considerations at runtime. So on the one hand, this 
is just a tool to produce JSON data, but on the other hand there would be a 
real meaning to the scoping implied by the with-foo syntax

- in relation to parameters: the means by which defrecord introduces record 
attributes may be instructive (if you go the DSL route)
-I like that idea of having the parameters simply being defined in square 
brackets "[]" at the top as in defrecord. However, each parameter does 
require a potentially large map of properties (type and validation 
information), which may be hard to fit into that syntax

Thanks a lot for the feedback so far!

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Alex Miller
It would help to know what your real goal is, but compiled Clojure does not 
retain the original source form. 

One hook you do have though is macros which will be invoked prior to 
compilation. At macro execution time, you have access to the special &form 
var which is the original form (as a Clojure data structure). 

Thus you could write a defn-like macro which when called to define a 
function definition would define the function and decorate it with meta 
that included the definition. I am a poor enough macrologist that I will 
not attempt that here but merely suggest it should be feasible. :)  

Alex

On Thursday, November 21, 2013 12:14:39 PM UTC-6, henry w wrote:
>
> Say you have a function created like this:
>
> (fn [x] (+ x y))
>
> and then you have a reference to an instance of this function, is there 
> some way to use the function reference to access the list '(fn [x] (+ x y)),
> including the symbol 'y' (such that you could dereference 'y' and get its 
> value)? The source function is not the right thing and so far googling 
> hasn't got me the answer.
>
> Thanks
>

-- 
-- 
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: ANN: core.logic 0.8.5

2013-11-26 Thread Norman Richards
On Mon, Nov 25, 2013 at 10:51 PM, David Nolen wrote:

> This release represents a fairly significant change to the simple DB
> functionality that core.logic provides - instead of a mess of mutable atoms
> thanks to Norman Richard we now store facts in a persistent data structure.
> This is likely a breaking change for some people, but it's a long
> outstanding issue that I'm happy to see finally remedied.
>

I think we have some outdated documentation now.  I'll try and fix that up.
 In the meantime, I'm happy to assist if anyone needs help migrating to the
fact db.

-- 
-- 
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: ANN: core.logic 0.8.5

2013-11-26 Thread David Nolen
Thanks Norman, that would be extremely helpful!


On Tue, Nov 26, 2013 at 2:39 PM, Norman Richards wrote:

> On Mon, Nov 25, 2013 at 10:51 PM, David Nolen wrote:
>
>> This release represents a fairly significant change to the simple DB
>> functionality that core.logic provides - instead of a mess of mutable atoms
>> thanks to Norman Richard we now store facts in a persistent data structure.
>> This is likely a breaking change for some people, but it's a long
>> outstanding issue that I'm happy to see finally remedied.
>>
>
> I think we have some outdated documentation now.  I'll try and fix that
> up.  In the meantime, I'm happy to assist if anyone needs help migrating to
> the fact db.
>
>
>
> --
> --
> 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.
>

-- 
-- 
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: CloudFormation template generation with Clojure

2013-11-26 Thread Gary Verhaegen
Before you decide on the question of macros/dsl versus data api, I would
recommend watching the "(not= DSL macro)" talk from a few years ago. It
nicely illustrates the tradeoffs involved, and hints at the reasons why the
Clojure community, as opposed to traditional lisps, tends to gravitate more
towards data-based than macro-based.

The "one ring to bind them all" talk was also quite enlightening in this
regard.

(Please do not misunderstand me: I am not advising against a DSL, I just
want to help you choose knowingly.)

On Tuesday, 26 November 2013, Kevin Bell wrote:

> Hey Craig and Jeroen,
>
> Jeroen:
>
> Can you elaborate on what kind of features you would like to support? Are
> you just deciding on DSL syntax or do you have already some kind of Clojure
> layer working?
>
> -My main goals are to create as "pretty" of a format for defining CF
> templates within Clojure syntax and support compiling/decompiling to/from
> JSON templates. I would definitely like to do some amount of validation,
> taking advantage of the 
> schema
>  and
> perhaps some of the logic from the eclipse 
> plugin,
> though I'm not sure yet how rigorous the validation should be.
>
> -I think some really nice additional features would be some kind of
> launcher, perhaps done as a leiningen plugin and using amazonica, and
> simplified creation of custom CF resources, which are incredibly powerful
> and I think fit well with the principles of Clojure, as they are meant to
> be small, idempotent modules of functionality that follow a certain protocol
>
> About the DSL, in the end I decided to stick closer to the CF syntax to
> avoid confusion and documentation mismatches. So for instance, all my
> parameters for a CF resource are CamelCase. One of the most important
> features for me is the validation on missing fields and Reference checking.
>
> -I was thinking about this too and started with camel case, but I've been
> using AngularJS a lot lately, and I actually love the fact that it converts
> to/from hyphen-case and CamelCase as convention dictates, so I think I want
> to implement that. It shouldn't be too hard to do using some autocorrection
> of case based on the schema (above)
>
> If you are interested in collaborating in this, please let me know.
> -I'd love too. Please feel free to contact me at kevin.a.bell (at) gmail
>
> Craig:
>
> Typical advice is to not use macros (implicitly used in the gists to build
> a CF DSL) when functions or data will suffice. Sometimes however the
> syntactic sugar is quite tasty and hard to overlook. I do not have enough
> knowledge of the domain to suggest what might be the correct approach in
> this case.
> -That makes sense, and I was thinking about using functions for things
> like the mappings, resources, etc. However, it seems nice to have variables
> that can be reused later in the template. Keywords could work for this, but
> I feel like that gets a bit awkward if you look at what I was trying to do
> in the keyword-heavy version. One thing that struck me about the version
> using macro-defined variables though is that, since the whole template
> syntax ultimately just produces a big map, defining/using variables within
> it is equivalent to doing (def mymap {:first-key (def mystring "a")
> :second-key mystring}), which works, but is that weird?
>
> Some additional comments:
> - your use of with-foo pattern is not idiomatic afaics; this pattern is
> typically used to scope run-time resource usage
> -This is something I've been struggling with a bit. The thing is that
> while CF templates are just JSON files, they actually have an explicit
> execution path and various scope considerations at runtime. So on the one
> hand, this is just a tool to produce JSON data, but on the other hand there
> would be a real meaning to the scoping implied by the with-foo syntax
>
> - in relation to parameters: the means by which defrecord introduces
> record attributes may be instructive (if you go the DSL route)
> -I like that idea of having the parameters simply being defined in square
> brackets "[]" at the top as in defrecord. However, each parameter does
> require a potentially large map of properties (type and validation
> information), which may be hard to fit into that syntax
>
> Thanks a lot for the feedback so far!
>
>  --
> --
> 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 '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  'clojure%2bunsubscr...@googlegroups.com');>

Re: Access the datastructure used to create a function?

2013-11-26 Thread Gary Verhaegen
I think that is basically what serializable-fn does. Might be worth taking
a look at it:

https://github.com/technomancy/serializable-fn/blob/master/src/serializable/fn.clj

On Tuesday, 26 November 2013, Alex Miller wrote:

> It would help to know what your real goal is, but compiled Clojure does
> not retain the original source form.
>
> One hook you do have though is macros which will be invoked prior to
> compilation. At macro execution time, you have access to the special &form
> var which is the original form (as a Clojure data structure).
>
> Thus you could write a defn-like macro which when called to define a
> function definition would define the function and decorate it with meta
> that included the definition. I am a poor enough macrologist that I will
> not attempt that here but merely suggest it should be feasible. :)
>
> Alex
>
> On Thursday, November 21, 2013 12:14:39 PM UTC-6, henry w wrote:
>>
>> Say you have a function created like this:
>>
>> (fn [x] (+ x y))
>>
>> and then you have a reference to an instance of this function, is there
>> some way to use the function reference to access the list '(fn [x] (+ x y)),
>> including the symbol 'y' (such that you could dereference 'y' and get its
>> value)? The source function is not the right thing and so far googling
>> hasn't got me the answer.
>>
>> Thanks
>>
>  --
> --
> 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 '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  'clojure%2bunsubscr...@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  'clojure%2bunsubscr...@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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: Best Practice For Logging vs. Functional (and Elegant)

2013-11-26 Thread Gary Verhaegen
I haven't had time to really investigate it, but I was planning to delve
into dire for exactly that problem.

https://github.com/MichaelDrogalis/dire

On Tuesday, 26 November 2013, Stefan Kamphausen wrote:

> Hi,
>
>
> logging is a side-effect and I try to keep it out of the functional parts
> of my code.
>
> But even for the parts where I want to introduce logging I find that it
> renders code less readable.
>
>
> As an example, say you've got an 'if-let' somewhere
>
> (if-let [a (do-something-non-trivial-with-some-local-args)]
>   (make-use-of-a)
>   (return-a-reasonable-default))
>
> That piece of code is concise, readable, nicely indented, etc.  However,
> when logging comes along, it becomes ugly quickly, at least to my eye:
>
>
> (if-let [a (do-something-non-trivial-with-some-local-args)]
>   (do (log/debug "got a reasonable a:" a)
>   (make-use-of-a))
>   (do (log/warn "using a dangerous default")
>   (return-a-reasonable-default)))
>
> I wonder, how you deal with such situations.  Do you get rid of all those
> do's, e.g. with a 'logged' ('debugged', 'warned', etc) macro which takes
> some logging args and a body in any way? Do you wrap functions in
> tracing-like logging entities and log e.g. at the level of '
> do-something-non-trivial-with-some-local-args'? Or are you just happy
> with the 'do'?
>
> The only other thread I could find on this list which discussed related
> issues was
> https://groups.google.com/d/msg/clojure/B2Wo5Oe1OrI/Y_eznCx3R7YJ and I
> will think a bit about Herwig's reader tag approach.
>
>
> Regards,
> stefan
>
> --
> --
> 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 '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  'clojure%2bunsubscr...@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  'clojure%2bunsubscr...@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread Alex Miller
Seems like you lost the clojure mailing list in this response, so I
re-added it.

On Tue, Nov 26, 2013 at 2:09 PM, henry w  wrote:

> Thanks to all respondents.
>
> This was really just something I was curious about, although I can think
> of some practical uses.
>
> It's just not clear to me still if there is some really good reason code
> stops being data (or at least having an accessible data representation)
> after it is compiled. Jamie has shown it is still data, although in a very
> platform-specific way. Is it just the case that there aren't compelling
> use-cases that people have come up with perhaps?
>

Code stops being data so it can be a more efficient form to the host
platform (bytecode), which is what makes Clojure perform well. If you
always left the data in the original form, you would just need an
interpreter (and Clojure would be much slower). Clojure is always compiled
as performance is a key concern.


> Pratically, some examples of use might be related to the
> https://github.com/clojure/tools.trace library. Here vars are temporarily
> bound to functions that are wrapped versions of the functions they held
> previously in order to print input and output. A nice alternative would be
> to show the function form with the parameters interpolated. Another case
> might be to see not just the source of a function, but to 'inline' the
> source of functions called from it. Or just generally mess about with
> functions I don't own.
>

There has been a recent enhancement discussion (perhaps here, perhaps jira,
can't find it now) to have functions retain their source definition at
runtime. I'm not sure how that would be possible without significantly
affecting performance and memory footprint however.


>
>
>
> On Tuesday, November 26, 2013 7:01:57 PM UTC, Alex Miller wrote:
>>
>> It would help to know what your real goal is, but compiled Clojure does
>> not retain the original source form.
>>
>> One hook you do have though is macros which will be invoked prior to
>> compilation. At macro execution time, you have access to the special &form
>> var which is the original form (as a Clojure data structure).
>>
>> Thus you could write a defn-like macro which when called to define a
>> function definition would define the function and decorate it with meta
>> that included the definition. I am a poor enough macrologist that I will
>> not attempt that here but merely suggest it should be feasible. :)
>>
>> Alex
>>
>> On Thursday, November 21, 2013 12:14:39 PM UTC-6, henry w wrote:
>>>
>>> Say you have a function created like this:
>>>
>>> (fn [x] (+ x y))
>>>
>>> and then you have a reference to an instance of this function, is there
>>> some way to use the function reference to access the list '(fn [x] (+ x y)),
>>> including the symbol 'y' (such that you could dereference 'y' and get
>>> its value)? The source function is not the right thing and so far googling
>>> hasn't got me the answer.
>>>
>>> Thanks
>>>
>>

-- 
-- 
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: Best Practice For Logging vs. Functional (and Elegant)

2013-11-26 Thread Stefan Kamphausen


On Tuesday, November 26, 2013 8:56:11 PM UTC+1, Gary Verhaegen wrote:
>
> I haven't had time to really investigate it, but I was planning to delve 
> into dire for exactly that problem.
>
> https://github.com/MichaelDrogalis/dire
>
>
That looks interesting.  Thanks for pointing out.

Best,
stefan 

-- 
-- 
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: [ANN] fsrun : file change notifier high order lein task

2013-11-26 Thread Phil Hagelberg
Cool; this looks really handy. Could you add it to the list of plugins on 
the Leiningen wiki?

https://github.com/technomancy/leiningen/wiki/Plugins
>
>
-Phil

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


Working clojure zippers and trees

2013-11-26 Thread dabd
I am trying to work with a tree representation using vectors where the 
first element is the node value and the rest are the children as suggested 
here:
http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers

However I am having trouble using clojure.zip/edit to change a simple tree. 
I'd like to multiply the odd numbers by 2 in this case.
https://gist.github.com/dabd/7666778

It looks like after editing the first (branch) node clojure.zip/next will 
get to the end of the tree.
How can I correct this code?

Thanks.



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


Working with zippers and trees

2013-11-26 Thread dabd
I am trying to work with a tree representation using vectors where the 
first element is the node value and the rest are the children as suggested 
here:
http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers

However I am having trouble using clojure.zip/edit to change a simple tree. 
I'd like to multiply the odd numbers by 2 in this case.
https://gist.github.com/dabd/7666778

It looks like after editing the first (branch) node clojure.zip/next will 
get to the end of the tree.
How can I correct this code?

Thanks.

-- 
-- 
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: Access the datastructure used to create a function?

2013-11-26 Thread henry w
The thing is, the data contained in the source definition is all still 
there in the compiled version - but apparently it is not easily accessible. 
It feels like it must be possible to write a function that looks at a 
function object and it's class and can produce at least a decent 
approximation to the original, or at least a clojure list version of the 
compiled code. No doubt completely faithful recreation wouldn't be 
possible, not least because of macros.

Also, sometimes, such as when developing possibly, it is not always 
necessary to have optimum performance.



On Tuesday, November 26, 2013 8:30:38 PM UTC, Alex Miller wrote:
>
> Seems like you lost the clojure mailing list in this response, so I 
> re-added it.
>
> On Tue, Nov 26, 2013 at 2:09 PM, henry w  >wrote:
>
>> Thanks to all respondents. 
>>
>> This was really just something I was curious about, although I can think 
>> of some practical uses. 
>>
>> It's just not clear to me still if there is some really good reason code 
>> stops being data (or at least having an accessible data representation) 
>> after it is compiled. Jamie has shown it is still data, although in a very 
>> platform-specific way. Is it just the case that there aren't compelling 
>> use-cases that people have come up with perhaps?
>>
>
> Code stops being data so it can be a more efficient form to the host 
> platform (bytecode), which is what makes Clojure perform well. If you 
> always left the data in the original form, you would just need an 
> interpreter (and Clojure would be much slower). Clojure is always compiled 
> as performance is a key concern.
>  
>
>> Pratically, some examples of use might be related to the 
>> https://github.com/clojure/tools.trace library. Here vars are 
>> temporarily bound to functions that are wrapped versions of the functions 
>> they held previously in order to print input and output. A nice alternative 
>> would be to show the function form with the parameters interpolated. 
>> Another case might be to see not just the source of a function, but to 
>> 'inline' the source of functions called from it. Or just generally mess 
>> about with functions I don't own.
>>
>
> There has been a recent enhancement discussion (perhaps here, perhaps 
> jira, can't find it now) to have functions retain their source definition 
> at runtime. I'm not sure how that would be possible without significantly 
> affecting performance and memory footprint however.
>  
>
>>
>>
>>
>> On Tuesday, November 26, 2013 7:01:57 PM UTC, Alex Miller wrote:
>>>
>>> It would help to know what your real goal is, but compiled Clojure does 
>>> not retain the original source form. 
>>>
>>> One hook you do have though is macros which will be invoked prior to 
>>> compilation. At macro execution time, you have access to the special &form 
>>> var which is the original form (as a Clojure data structure). 
>>>
>>> Thus you could write a defn-like macro which when called to define a 
>>> function definition would define the function and decorate it with meta 
>>> that included the definition. I am a poor enough macrologist that I will 
>>> not attempt that here but merely suggest it should be feasible. :)  
>>>
>>> Alex
>>>
>>> On Thursday, November 21, 2013 12:14:39 PM UTC-6, henry w wrote:

 Say you have a function created like this:

 (fn [x] (+ x y))

 and then you have a reference to an instance of this function, is there 
 some way to use the function reference to access the list '(fn [x] (+ x 
 y)),
 including the symbol 'y' (such that you could dereference 'y' and get 
 its value)? The source function is not the right thing and so far googling 
 hasn't got me the answer.

 Thanks

>>>
>

-- 
-- 
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: [ANN] fsrun : file change notifier high order lein task

2013-11-26 Thread Mimmo Cosenza
yes, it's very cool
mimmo

On Nov 26, 2013, at 10:31 PM, Phil Hagelberg  wrote:

> Cool; this looks really handy. Could you add it to the list of plugins on the 
> Leiningen wiki?
> 
> https://github.com/technomancy/leiningen/wiki/Plugins
> 
> -Phil
> 
> -- 
> -- 
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Access the datastructure used to create a function?

2013-11-26 Thread Guru Devanla
The important caveat here is "what  do we label as data?". If we are okay
with just 'streams of bytes' that will make us understand and reason some
information about the function, then may be the bytecode itself could be
sufficient and could be considered to be data. But, I guess the original
question was regarding data that one could reason in the form on clojure
forms itself. At least, that is what I believe Henry was referring to,
isn't?

-Guru



On Tue, Nov 26, 2013 at 1:51 PM, henry w  wrote:

> The thing is, the data contained in the source definition is all still
> there in the compiled version - but apparently it is not easily accessible.
> It feels like it must be possible to write a function that looks at a
> function object and it's class and can produce at least a decent
> approximation to the original, or at least a clojure list version of the
> compiled code. No doubt completely faithful recreation wouldn't be
> possible, not least because of macros.
>
> Also, sometimes, such as when developing possibly, it is not always
> necessary to have optimum performance.
>
>
>
>
> On Tuesday, November 26, 2013 8:30:38 PM UTC, Alex Miller wrote:
>
>> Seems like you lost the clojure mailing list in this response, so I
>> re-added it.
>>
>> On Tue, Nov 26, 2013 at 2:09 PM, henry w  wrote:
>>
>>> Thanks to all respondents.
>>>
>>> This was really just something I was curious about, although I can think
>>> of some practical uses.
>>>
>>> It's just not clear to me still if there is some really good reason code
>>> stops being data (or at least having an accessible data representation)
>>> after it is compiled. Jamie has shown it is still data, although in a very
>>> platform-specific way. Is it just the case that there aren't compelling
>>> use-cases that people have come up with perhaps?
>>>
>>
>> Code stops being data so it can be a more efficient form to the host
>> platform (bytecode), which is what makes Clojure perform well. If you
>> always left the data in the original form, you would just need an
>> interpreter (and Clojure would be much slower). Clojure is always compiled
>> as performance is a key concern.
>>
>>
>>> Pratically, some examples of use might be related to the
>>> https://github.com/clojure/tools.trace library. Here vars are
>>> temporarily bound to functions that are wrapped versions of the functions
>>> they held previously in order to print input and output. A nice alternative
>>> would be to show the function form with the parameters interpolated.
>>> Another case might be to see not just the source of a function, but to
>>> 'inline' the source of functions called from it. Or just generally mess
>>> about with functions I don't own.
>>>
>>
>> There has been a recent enhancement discussion (perhaps here, perhaps
>> jira, can't find it now) to have functions retain their source definition
>> at runtime. I'm not sure how that would be possible without significantly
>> affecting performance and memory footprint however.
>>
>>
>>>
>>>
>>>
>>> On Tuesday, November 26, 2013 7:01:57 PM UTC, Alex Miller wrote:

 It would help to know what your real goal is, but compiled Clojure does
 not retain the original source form.

 One hook you do have though is macros which will be invoked prior to
 compilation. At macro execution time, you have access to the special &form
 var which is the original form (as a Clojure data structure).

 Thus you could write a defn-like macro which when called to define a
 function definition would define the function and decorate it with meta
 that included the definition. I am a poor enough macrologist that I will
 not attempt that here but merely suggest it should be feasible. :)

 Alex

 On Thursday, November 21, 2013 12:14:39 PM UTC-6, henry w wrote:
>
> Say you have a function created like this:
>
> (fn [x] (+ x y))
>
> and then you have a reference to an instance of this function, is
> there some way to use the function reference to access the list '(fn [x] 
> (+
> x y)),
> including the symbol 'y' (such that you could dereference 'y' and get
> its value)? The source function is not the right thing and so far googling
> hasn't got me the answer.
>
> Thanks
>

>>  --
> --
> 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, vi

Re: Working with zippers and trees

2013-11-26 Thread martin_clausen
With a nested vector tree you can use the built in vector-zip function to 
create your zipper.

As to the editing, the source 
code 
contains 
a very similar use-case, which can be adapted to something like the 
following:

(let [vz (vector-zip [1 2 [3 4 5]])]
(loop [loc vz]
  (if (end? loc)
(root loc)
(recur (next (if (and (integer? (node loc)) (odd? (node loc)))
   (replace loc (* 2 (node loc)))
   loc))

> [2 2 [6 4 10]]

On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote:
>
> I am trying to work with a tree representation using vectors where the 
> first element is the node value and the rest are the children as suggested 
> here:
>
> http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers
>
> However I am having trouble using clojure.zip/edit to change a simple 
> tree. I'd like to multiply the odd numbers by 2 in this case.
> https://gist.github.com/dabd/7666778
>
> It looks like after editing the first (branch) node clojure.zip/next will 
> get to the end of the tree.
> How can I correct this code?
>
> Thanks.
>
>

-- 
-- 
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: CloudFormation template generation with Clojure

2013-11-26 Thread Kevin Bell
Hey Gary,

Thanks for the references. Those videos were awesome!

I think Cristophe definitely hit the nail on the head with this 
slide about 
the challenges of binding. Though, I'm not sure I fully get what he meant 
by "binding specs" and "capturing specs". Do you happen to know of any more 
resources on that topic?

I took another attempt  at my 
"deftemplate" syntax with a gradual progression from 
data->functions->macros as discussed by Cristophe. This approach left me 
with something similar to one of my earlier samples that copied leiningen's 
"defproject" syntax very heavily.

The only issue I have with this new syntax it seems overly 
data-like/keyword-heavy. For example this section:

:my-second-condition [:cfn=
   [:cfn-inmap :my-mapping :first-level-key-one 
:second-level-key-two]
   [:cfn-ref :my-parameter]]


Could be replaced by this:

my-second-condition (cfn= (cfn-inmap my-mapping :first-level-key-one 
:second-level-key-two)
   (cfn-ref my-parameter))

Which I feel is much more readable, with the cfn-whatever functions simply 
returning specially-formatted string maps. Except, my-mapping and my-parameter 
aren't defined as vars in the data-structure-like syntax, so I would have to do 
some of that funky symbol-grabbing/walking in a macro that people seem to be 
cautioning against...

-- 
-- 
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: [ANN] fsrun : file change notifier high order lein task

2013-11-26 Thread Plinio Balduino
Excellent, Deniz

But I'm getting an error when I try to run for the first time:

Could not find artifact fsrun:fsrun:jar:0.1.0 in central 
(http://repo1.maven.org/maven2/)
Could not find artifact fsrun:fsrun:jar:0.1.0 in clojars 
(https://clojars.org/repo/)
This could be due to a typo in :dependencies or network issues.

Part of my project.clj:

(defproject blabla "0.1.0-SNAPSHOT"
  ; licenses, description, url
  :dependencies [[org.clojure/clojure "1.5.1"]]
  :plugins [[fsrun "0.1.0"]]
  ; etc etc etc
)

Am I doing something wrong? My network is OK and I'm not using any proxy.

Thank you

Plínio

On Monday, November 25, 2013 5:26:05 AM UTC-2, Deniz Kurucu wrote:
>
> fsrun is a simple high order lein task that run some other tasks when a 
> file modification occurs. Originally, i wanted to run my clojurescript 
> tests automatically and created fsrun. It is my first clojure project, so 
> please keep that in mind :)
>
> github : https://github.com/makkalot/fsrun
>
> Thanks.
>

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread dabd
The built-in vector-zip will build a tree with a different structure than 
what I need.
I want build a tree as described in the first post: the node value is the 
first element of the vector and the children the rest of the elements.


zipper.core>  (loop [loc (tree-zipper [1 2 [3 4 5]])]
(if (z/end? loc)
  (z/root loc)
  (do (println (z/node loc))
  (recur (z/next loc)
[1 2 [3 4 5]]

2

[3 4 5]

4

5

[1 2 [3 4 5]]
zipper.core>  (loop [loc (z/vector-zip [1 2 [3 4 5]])]
(if (z/end? loc)
  (z/root loc)
  (do (println (z/node loc))
  (recur (z/next loc)
[1 2 [3 4 5]]

1

2

[3 4 5]

3

4

5

[1 2 [3 4 5]]


On Tuesday, November 26, 2013 11:56:45 PM UTC, martin_clausen wrote:
>
> With a nested vector tree you can use the built in vector-zip function to 
> create your zipper.
>
> As to the editing, the source 
> code 
> contains 
> a very similar use-case, which can be adapted to something like the 
> following:
>
> (let [vz (vector-zip [1 2 [3 4 5]])]
> (loop [loc vz]
>   (if (end? loc)
> (root loc)
> (recur (next (if (and (integer? (node loc)) (odd? (node loc)))
>(replace loc (* 2 (node loc)))
>loc))
>
> > [2 2 [6 4 10]]
>
> On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote:
>>
>> I am trying to work with a tree representation using vectors where the 
>> first element is the node value and the rest are the children as suggested 
>> here:
>>
>> http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers
>>
>> However I am having trouble using clojure.zip/edit to change a simple 
>> tree. I'd like to multiply the odd numbers by 2 in this case.
>> https://gist.github.com/dabd/7666778
>>
>> It looks like after editing the first (branch) node clojure.zip/next will 
>> get to the end of the tree.
>> How can I correct this code?
>>
>> Thanks.
>>
>>

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread martin_clausen
To use the zipper library you have to be able to provide branch? children 
and make-node functions that apply to your data structure.

I don't see a way to provide a meaningful branch? or children function for 
the structure you describe. Vector? will not work as branch? as it will not 
return true if passed the first element in a vector, and next will not work 
as it will not return the children if passed the first element of a vector.

It looks to me like you don't get past the first element because the call 
to z/next fails both (and (branch? loc) (down loc)), (right loc) and (up loc) 
and therefore marks the first element as the end of the of the structure.

Is there a compelling reason for not using the vector-zip structure for 
your specific use-case?


On Wednesday, November 27, 2013 2:59:40 AM UTC+1, dabd wrote:
>
> The built-in vector-zip will build a tree with a different structure than 
> what I need.
> I want build a tree as described in the first post: the node value is the 
> first element of the vector and the children the rest of the elements.
>
>
> zipper.core>  (loop [loc (tree-zipper [1 2 [3 4 5]])]
> (if (z/end? loc)
>   (z/root loc)
>   (do (println (z/node loc))
>   (recur (z/next loc)
> [1 2 [3 4 5]]
>
> 2
>
> [3 4 5]
>
> 4
>
> 5
>
> [1 2 [3 4 5]]
> zipper.core>  (loop [loc (z/vector-zip [1 2 [3 4 5]])]
> (if (z/end? loc)
>   (z/root loc)
>   (do (println (z/node loc))
>   (recur (z/next loc)
> [1 2 [3 4 5]]
>
> 1
>
> 2
>
> [3 4 5]
>
> 3
>
> 4
>
> 5
>
> [1 2 [3 4 5]]
>
>
> On Tuesday, November 26, 2013 11:56:45 PM UTC, martin_clausen wrote:
>>
>> With a nested vector tree you can use the built in vector-zip function to 
>> create your zipper.
>>
>> As to the editing, the source 
>> code 
>> contains 
>> a very similar use-case, which can be adapted to something like the 
>> following:
>>
>> (let [vz (vector-zip [1 2 [3 4 5]])]
>> (loop [loc vz]
>>   (if (end? loc)
>> (root loc)
>> (recur (next (if (and (integer? (node loc)) (odd? (node loc)))
>>(replace loc (* 2 (node loc)))
>>loc))
>>
>> > [2 2 [6 4 10]]
>>
>> On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote:
>>>
>>> I am trying to work with a tree representation using vectors where the 
>>> first element is the node value and the rest are the children as suggested 
>>> here:
>>>
>>> http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers
>>>
>>> However I am having trouble using clojure.zip/edit to change a simple 
>>> tree. I'd like to multiply the odd numbers by 2 in this case.
>>> https://gist.github.com/dabd/7666778
>>>
>>> It looks like after editing the first (branch) node clojure.zip/next 
>>> will get to the end of the tree.
>>> How can I correct this code?
>>>
>>> Thanks.
>>>
>>>

-- 
-- 
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: Best Practice For Logging vs. Functional (and Elegant)

2013-11-26 Thread Mars0i
I'm not an experienced Clojure programmer, and not fully committed to 
functional programming, so others will probably have ... cooler, and better 
answers.  But to me it seems that there is nothing special to this 
situation that has to do with functional programming.  Adding code that 
reports on what's going on always adds clutter.  It's a necessary evil 
sometimes.  For some purposes temporary print/write statements can be 
deleted later, and for other purposes a debugger is indispensible.  For 
intermittent logging--i.e. when there are only a few places in the whole 
program where it's needed, one option is to insert functions into the call 
sequence that simply return what was passed to them, but produce a side 
effect on a file as well.  But that's extra clutter, too.  (Dire does look 
like an interesting alternative.  It's something like an ad hoc debugger.)

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread Carlo Zancanaro
On Tue, Nov 26, 2013 at 08:30:15PM -0800, martin_clausen wrote:
> To use the zipper library you have to be able to provide branch? children 
> and make-node functions that apply to your data structure.
>
> I don't see a way to provide a meaningful branch? or children function for 
> the structure you describe. Vector? will not work as branch? as it will not 
> return true if passed the first element in a vector, and next will not work 
> as it will not return the children if passed the first element of a vector.

We can write our own functions, though:

(defn children? [n]
  (and (vector? n) (next n)))

(defn make-node [n children]
  (vec (cons (first n) children)))

(defn tree-zipper [v]
  (z/zipper children? next make-node v))

Dario: I tried this with your gist, and the code in your previous email,
and as far as I could tell it worked, so I hope that helps!

Carlo

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread dabd
I'm not sure what you mean by not being able to provide a meaningful 
branch?.

I would like to represent a tree such a this:

  1

  / \
 2   3
/ \
   4   5


How can I achieve this using zippers?

On Wednesday, November 27, 2013 4:30:15 AM UTC, martin_clausen wrote:
>
> To use the zipper library you have to be able to provide branch? children 
> and make-node functions that apply to your data structure.
>
> I don't see a way to provide a meaningful branch? or children function for 
> the structure you describe. Vector? will not work as branch? as it will not 
> return true if passed the first element in a vector, and next will not work 
> as it will not return the children if passed the first element of a vector.
>
> It looks to me like you don't get past the first element because the call 
> to z/next fails both (and (branch? loc) (down loc)), (right loc) and (up 
> loc) and therefore marks the first element as the end of the of the 
> structure.
>
> Is there a compelling reason for not using the vector-zip structure for 
> your specific use-case?
>
>
> On Wednesday, November 27, 2013 2:59:40 AM UTC+1, dabd wrote:
>>
>> The built-in vector-zip will build a tree with a different structure than 
>> what I need.
>> I want build a tree as described in the first post: the node value is the 
>> first element of the vector and the children the rest of the elements.
>>
>>
>> zipper.core>  (loop [loc (tree-zipper [1 2 [3 4 5]])]
>> (if (z/end? loc)
>>   (z/root loc)
>>   (do (println (z/node loc))
>>   (recur (z/next loc)
>> [1 2 [3 4 5]]
>>
>> 2
>>
>> [3 4 5]
>>
>> 4
>>
>> 5
>>
>> [1 2 [3 4 5]]
>> zipper.core>  (loop [loc (z/vector-zip [1 2 [3 4 5]])]
>> (if (z/end? loc)
>>   (z/root loc)
>>   (do (println (z/node loc))
>>   (recur (z/next loc)
>> [1 2 [3 4 5]]
>>
>> 1
>>
>> 2
>>
>> [3 4 5]
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> [1 2 [3 4 5]]
>>
>>
>> On Tuesday, November 26, 2013 11:56:45 PM UTC, martin_clausen wrote:
>>>
>>> With a nested vector tree you can use the built in vector-zip function 
>>> to create your zipper.
>>>
>>> As to the editing, the source 
>>> code
>>>  contains 
>>> a very similar use-case, which can be adapted to something like the 
>>> following:
>>>
>>> (let [vz (vector-zip [1 2 [3 4 5]])]
>>> (loop [loc vz]
>>>   (if (end? loc)
>>> (root loc)
>>> (recur (next (if (and (integer? (node loc)) (odd? (node 
>>> loc)))
>>>(replace loc (* 2 (node loc)))
>>>loc))
>>>
>>> > [2 2 [6 4 10]]
>>>
>>> On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote:

 I am trying to work with a tree representation using vectors where the 
 first element is the node value and the rest are the children as suggested 
 here:

 http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers

 However I am having trouble using clojure.zip/edit to change a simple 
 tree. I'd like to multiply the odd numbers by 2 in this case.
 https://gist.github.com/dabd/7666778

 It looks like after editing the first (branch) node clojure.zip/next 
 will get to the end of the tree.
 How can I correct this code?

 Thanks.



-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread Carlo Zancanaro
Okay, now after actually reading the documentation I can come back with
an actually correct response!

You should only have to change one function:

> (defn make-node [n children]
>   (vec (cons (first n) children)))

Your issue was that your original `make-node` function didn't return a
vector, it returned a ConsCell (with a vector as its tail). This meant
that your new node no longer returned true for "children", that is it
identified itself as a leaf.

By making `make-node` return a vector (vec turns any sequable thing into
a vector) your `make-node` now returns a valid branch node, so z/next
behaves as you want it to.

Carlo

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread dabd
Thanks. Do you think the call to z/edit in my code could be simplified? To 
edit a branch node I have to use conj to build a node only to pass it to 
make-node which will break it apart again.

On Wednesday, November 27, 2013 5:53:31 AM UTC, Carlo wrote:
>
> Okay, now after actually reading the documentation I can come back with 
> an actually correct response! 
>
> You should only have to change one function: 
>
> > (defn make-node [n children] 
> >   (vec (cons (first n) children))) 
>
> Your issue was that your original `make-node` function didn't return a 
> vector, it returned a ConsCell (with a vector as its tail). This meant 
> that your new node no longer returned true for "children", that is it 
> identified itself as a leaf. 
>
> By making `make-node` return a vector (vec turns any sequable thing into 
> a vector) your `make-node` now returns a valid branch node, so z/next 
> behaves as you want it to. 
>
> Carlo 
>

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread Martin Clausen
Yes, for instance like this:

(let [vz (z/vector-zip [1 [2] [3 [4 5]]])]
(loop [loc vz]
  (if (z/end? loc)
(z/root loc)
(recur (z/next (if (and (integer? (z/node loc)) (odd? (z/node loc)))
   (z/replace loc (* 2 (z/node loc)))
   loc))

Which lets you avoid writing half the infrastructure yourself.

On Wed, Nov 27, 2013 at 6:19 AM, dabd  wrote:
> I'm not sure what you mean by not being able to provide a meaningful
> branch?.
>
> I would like to represent a tree such a this:
>
>   1
>
>   / \
>  2   3
> / \
>4   5
>
>
> How can I achieve this using zippers?
>
> On Wednesday, November 27, 2013 4:30:15 AM UTC, martin_clausen wrote:
>>
>> To use the zipper library you have to be able to provide branch? children
>> and make-node functions that apply to your data structure.
>>
>> I don't see a way to provide a meaningful branch? or children function for
>> the structure you describe. Vector? will not work as branch? as it will not
>> return true if passed the first element in a vector, and next will not work
>> as it will not return the children if passed the first element of a vector.
>>
>> It looks to me like you don't get past the first element because the call
>> to z/next fails both (and (branch? loc) (down loc)), (right loc) and (up
>> loc) and therefore marks the first element as the end of the of the
>> structure.
>>
>> Is there a compelling reason for not using the vector-zip structure for
>> your specific use-case?
>>
>>
>> On Wednesday, November 27, 2013 2:59:40 AM UTC+1, dabd wrote:
>>>
>>> The built-in vector-zip will build a tree with a different structure than
>>> what I need.
>>> I want build a tree as described in the first post: the node value is the
>>> first element of the vector and the children the rest of the elements.
>>>
>>>
>>> zipper.core>  (loop [loc (tree-zipper [1 2 [3 4 5]])]
>>> (if (z/end? loc)
>>>  (z/root loc)
>>>  (do (println (z/node loc))
>>>  (recur (z/next loc)
>>> [1 2 [3 4 5]]
>>>
>>> 2
>>>
>>> [3 4 5]
>>>
>>> 4
>>>
>>> 5
>>>
>>> [1 2 [3 4 5]]
>>> zipper.core>  (loop [loc (z/vector-zip [1 2 [3 4 5]])]
>>> (if (z/end? loc)
>>>  (z/root loc)
>>>  (do (println (z/node loc))
>>>  (recur (z/next loc)
>>> [1 2 [3 4 5]]
>>>
>>> 1
>>>
>>> 2
>>>
>>> [3 4 5]
>>>
>>> 3
>>>
>>> 4
>>>
>>> 5
>>>
>>> [1 2 [3 4 5]]
>>>
>>>
>>> On Tuesday, November 26, 2013 11:56:45 PM UTC, martin_clausen wrote:

 With a nested vector tree you can use the built in vector-zip function
 to create your zipper.

 As to the editing, the source code contains a very similar use-case,
 which can be adapted to something like the following:

 (let [vz (vector-zip [1 2 [3 4 5]])]
 (loop [loc vz]
   (if (end? loc)
 (root loc)
 (recur (next (if (and (integer? (node loc)) (odd? (node
 loc)))
(replace loc (* 2 (node loc)))
loc))

 > [2 2 [6 4 10]]

 On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote:
>
> I am trying to work with a tree representation using vectors where the
> first element is the node value and the rest are the children as suggested
> here:
>
> http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers
>
> However I am having trouble using clojure.zip/edit to change a simple
> tree. I'd like to multiply the odd numbers by 2 in this case.
> https://gist.github.com/dabd/7666778
>
> It looks like after editing the first (branch) node clojure.zip/next
> will get to the end of the tree.
> How can I correct this code?
>
> Thanks.
>
> --
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/ZTWo5gzOx08/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
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+unsu

Re: [ANN] fsrun : file change notifier high order lein task

2013-11-26 Thread Deniz Kurucu
Ah yes, sorry it is not on clojars yet. Wanted some feedback before pushing
it there :)


On Wed, Nov 27, 2013 at 2:26 AM, Plinio Balduino wrote:

> Excellent, Deniz
>
> But I'm getting an error when I try to run for the first time:
>
> Could not find artifact fsrun:fsrun:jar:0.1.0 in central (
> http://repo1.maven.org/maven2/)
> Could not find artifact fsrun:fsrun:jar:0.1.0 in clojars (
> https://clojars.org/repo/)
> This could be due to a typo in :dependencies or network issues.
>
> Part of my project.clj:
>
> (defproject blabla "0.1.0-SNAPSHOT"
>   ; licenses, description, url
>   :dependencies [[org.clojure/clojure "1.5.1"]]
>   :plugins [[fsrun "0.1.0"]]
>   ; etc etc etc
> )
>
> Am I doing something wrong? My network is OK and I'm not using any proxy.
>
> Thank you
>
> Plínio
>
> On Monday, November 25, 2013 5:26:05 AM UTC-2, Deniz Kurucu wrote:
>>
>> fsrun is a simple high order lein task that run some other tasks when a
>> file modification occurs. Originally, i wanted to run my clojurescript
>> tests automatically and created fsrun. It is my first clojure project, so
>> please keep that in mind :)
>>
>> github : https://github.com/makkalot/fsrun
>>
>> Thanks.
>>
>  --
> --
> 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.
>

-- 
-- 
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: [ANN] Overtone 0.9.0 Released

2013-11-26 Thread Samuel Aaron
Hi Cedric,

On 26 Nov 2013, at 16:45, Cedric Greevey  wrote:

> Is there a turnkey download/install/play with version of this yet, or is that 
> not until 1.0?

For a Clojure developer, Overtone is already as 'turnkey' as it gets. Simply 
add "overtone 0.9.1" to your dependencies in project.clj, start a REPL with 
Leiningen and then (use 'overtone.live) - your powerful music REPL awaits!

Sam

---
http://sam.aaron.name

-- 
-- 
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: Working with zippers and trees

2013-11-26 Thread dabd
The problem is that your vector-zip is not representing the tree I pictured.

On Wednesday, November 27, 2013 6:26:12 AM UTC, martin_clausen wrote:
>
> Yes, for instance like this: 
>
> (let [vz (z/vector-zip [1 [2] [3 [4 5]]])] 
> (loop [loc vz] 
>   (if (z/end? loc) 
> (z/root loc) 
> (recur (z/next (if (and (integer? (z/node loc)) (odd? (z/node 
> loc))) 
>(z/replace loc (* 2 (z/node loc))) 
>loc)) 
>
> Which lets you avoid writing half the infrastructure yourself. 
>
> On Wed, Nov 27, 2013 at 6:19 AM, dabd > 
> wrote: 
> > I'm not sure what you mean by not being able to provide a meaningful 
> > branch?. 
> > 
> > I would like to represent a tree such a this: 
> > 
> >   1 
> > 
> >   / \ 
> >  2   3 
> > / \ 
> >4   5 
> > 
> > 
> > How can I achieve this using zippers? 
> > 
> > On Wednesday, November 27, 2013 4:30:15 AM UTC, martin_clausen wrote: 
> >> 
> >> To use the zipper library you have to be able to provide branch? 
> children 
> >> and make-node functions that apply to your data structure. 
> >> 
> >> I don't see a way to provide a meaningful branch? or children function 
> for 
> >> the structure you describe. Vector? will not work as branch? as it will 
> not 
> >> return true if passed the first element in a vector, and next will not 
> work 
> >> as it will not return the children if passed the first element of a 
> vector. 
> >> 
> >> It looks to me like you don't get past the first element because the 
> call 
> >> to z/next fails both (and (branch? loc) (down loc)), (right loc) and 
> (up 
> >> loc) and therefore marks the first element as the end of the of the 
> >> structure. 
> >> 
> >> Is there a compelling reason for not using the vector-zip structure for 
> >> your specific use-case? 
> >> 
> >> 
> >> On Wednesday, November 27, 2013 2:59:40 AM UTC+1, dabd wrote: 
> >>> 
> >>> The built-in vector-zip will build a tree with a different structure 
> than 
> >>> what I need. 
> >>> I want build a tree as described in the first post: the node value is 
> the 
> >>> first element of the vector and the children the rest of the elements. 
> >>> 
> >>> 
> >>> zipper.core>  (loop [loc (tree-zipper [1 2 [3 4 5]])] 
> >>> (if (z/end? loc) 
> >>>  (z/root loc) 
> >>>  (do (println (z/node loc)) 
> >>>  (recur (z/next loc) 
> >>> [1 2 [3 4 5]] 
> >>> 
> >>> 2 
> >>> 
> >>> [3 4 5] 
> >>> 
> >>> 4 
> >>> 
> >>> 5 
> >>> 
> >>> [1 2 [3 4 5]] 
> >>> zipper.core>  (loop [loc (z/vector-zip [1 2 [3 4 5]])] 
> >>> (if (z/end? loc) 
> >>>  (z/root loc) 
> >>>  (do (println (z/node loc)) 
> >>>  (recur (z/next loc) 
> >>> [1 2 [3 4 5]] 
> >>> 
> >>> 1 
> >>> 
> >>> 2 
> >>> 
> >>> [3 4 5] 
> >>> 
> >>> 3 
> >>> 
> >>> 4 
> >>> 
> >>> 5 
> >>> 
> >>> [1 2 [3 4 5]] 
> >>> 
> >>> 
> >>> On Tuesday, November 26, 2013 11:56:45 PM UTC, martin_clausen wrote: 
>  
>  With a nested vector tree you can use the built in vector-zip 
> function 
>  to create your zipper. 
>  
>  As to the editing, the source code contains a very similar use-case, 
>  which can be adapted to something like the following: 
>  
>  (let [vz (vector-zip [1 2 [3 4 5]])] 
>  (loop [loc vz] 
>    (if (end? loc) 
>  (root loc) 
>  (recur (next (if (and (integer? (node loc)) (odd? (node 
>  loc))) 
> (replace loc (* 2 (node loc))) 
> loc)) 
>  
>  > [2 2 [6 4 10]] 
>  
>  On Tuesday, November 26, 2013 10:50:34 PM UTC+1, dabd wrote: 
> > 
> > I am trying to work with a tree representation using vectors where 
> the 
> > first element is the node value and the rest are the children as 
> suggested 
> > here: 
> > 
> > 
> http://grokbase.com/t/gg/clojure/12afy2cz9p/how-to-represent-trees-for-use-with-zippers
>  
> > 
> > However I am having trouble using clojure.zip/edit to change a 
> simple 
> > tree. I'd like to multiply the odd numbers by 2 in this case. 
> > https://gist.github.com/dabd/7666778 
> > 
> > It looks like after editing the first (branch) node clojure.zip/next 
> > will get to the end of the tree. 
> > How can I correct this code? 
> > 
> > Thanks. 
> > 
> > -- 
> > -- 
> > 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 a topic in the 
> > Googl