Re: How to convert a python list to clojure?

2012-06-25 Thread hyPiRion


On Sunday, June 24, 2012 12:30:48 PM UTC+2, Vinzent wrote:
>
> I think versions with `for` is a hell more readable. 
> I vote for this:
>
> (def cc
>   (for [i (range 256)]
> (.GetColor ctf (/ i 255.0
>

Yeah, that's about as succinct as it gets. Just be aware that the list is 
immutable, so e.g. (cons cc (.GetColor ctf 0.9)) will not change cc.

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

Re: [ANN] clojure.java.jdbc 0.2.3 available on Maven Central

2012-06-25 Thread mnicky


On Saturday, June 23, 2012 1:20:30 AM UTC+2, Niels van Klaveren wrote:
>
>  
> I was thinking if an SQL generation DSL / library could be based on 
> core.logic ? 
>  
>
Something like revival of clojure.contrib.datalog would be great.

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

verify that a fn throws an exception via testing?

2012-06-25 Thread Jim - FooBar();

Hey guys,

the only thing I can think of in order to test whether a fn does indeed 
throw an exception when certain circumstances are met is something like 
this:


(fact (try (fn-that-throws-exc bad-arg)
 (catch Exception e :works)) => :works)

I thought I can also return the actual Exception object (e) but on 
second thought I don't see any advantages...


Any ideas?

Jim

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


Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Ambrose Bonnaire-Sergeant
This comment outlines everything clojure.test can do. It's a quick read,
see "thrown?" and "thrown-with-msg?".

https://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj#L22

Thanks,
Ambrose

On Mon, Jun 25, 2012 at 7:21 PM, Jim - FooBar(); wrote:

> Hey guys,
>
> the only thing I can think of in order to test whether a fn does indeed
> throw an exception when certain circumstances are met is something like
> this:
>
> (fact (try (fn-that-throws-exc bad-arg)
> (catch Exception e :works)) => :works)
>
> I thought I can also return the actual Exception object (e) but on second
> thought I don't see any advantages...
>
> Any ideas?
>
> Jim
>
> --
> 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+unsubscribe@**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 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

Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Tassilo Horn
"Jim - FooBar();"  writes:

Hi Jim,

> the only thing I can think of in order to test whether a fn does
> indeed throw an exception when certain circumstances are met is
> something like this:
>
> (fact (try (fn-that-throws-exc bad-arg)
>  (catch Exception e :works)) => :works)
>
> I thought I can also return the actual Exception object (e) but on second
> thought I don't see any advantages...
>
> Any ideas?

I don't know what you are using for testing (what's `fact`?), but with
clojure.test you can check for thrown exceptions.  Search for thrown?
and thrown-with-msg? at

  http://clojure.github.com/clojure/clojure.test-api.html

Bye,
Tassilo

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


Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Jim - FooBar();

On 25/06/12 12:31, Tassilo Horn wrote:

"Jim - FooBar();"  writes:

Hi Jim,


the only thing I can think of in order to test whether a fn does
indeed throw an exception when certain circumstances are met is
something like this:

(fact (try (fn-that-throws-exc bad-arg)
  (catch Exception e :works)) => :works)

I thought I can also return the actual Exception object (e) but on second
thought I don't see any advantages...

Any ideas?

I don't know what you are using for testing (what's `fact`?), but with
clojure.test you can check for thrown exceptions.  Search for thrown?
and thrown-with-msg? at

   http://clojure.github.com/clojure/clojure.test-api.html

Bye,
Tassilo



I'm using midje... thanks both of you I'll check the links

Jim

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


Re: [ANN] clojure.java.jdbc 0.2.3 available on Maven Central

2012-06-25 Thread Niels van Klaveren
You can use the Datomic datalog implementation to query Clojure 
collections. 
I think this is the same use clojure.contrib.datalog had.

On Monday, June 25, 2012 12:47:29 PM UTC+2, mnicky wrote:
>
>
>
> On Saturday, June 23, 2012 1:20:30 AM UTC+2, Niels van Klaveren wrote:
>>
>>  
>> I was thinking if an SQL generation DSL / library could be based on 
>> core.logic ? 
>>  
>>
> Something like revival of clojure.contrib.datalog would be great.
>

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

Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Tassilo Horn
"Jim - FooBar();"  writes:

Hi Jim,

> I'm using midje...

Ah, ok.  Midje seems to support that, too.  See

  https://github.com/marick/Midje/wiki/Prerequisites-that-throw-exceptions

Bye,
Tassilo

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


Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Jim - FooBar();

On 25/06/12 13:03, Tassilo Horn wrote:

"Jim - FooBar();"  writes:

Hi Jim,


I'm using midje...

Ah, ok.  Midje seems to support that, too.  See

   https://github.com/marick/Midje/wiki/Prerequisites-that-throw-exceptions

Bye,
Tassilo



excellent! Thanks Tassilo :-)

Jim

ps:I can't believe I had missed that!

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


Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?

2012-06-25 Thread Jacobo Polavieja

>
> Unfortunately, I'm not sure what else to suggest as far as 
> SublimeREPL. But since you're new to Sublime, I'll assume you're not 
> that heavily invested in it yet? If you simply can't get SublimeREPL 
> up and running, there are other choices to look at. 
>
> Counterclockwise (http://code.google.com/p/counterclockwise/) is a 
> Clojure plugin for Eclipse. If you're at all familiar with the Eclipse 
> world, that might well be the easiest route to go in order to have a 
> REPL running within your IDE. There's also La Clojure 
> (http://plugins.intellij.net/plugin/?id=4050) for JetBrains. And of 
> course... vi or Emacs :) 
>
> There are lots of options available. While you may be inclined to ask 
> people to chime in with their favorites, I'd strongly urge you to not 
> go that route. That particular debate/discussion can get pretty heated 
> :) Plus, if you search the group archives, you'll see that the 
> conversation has been had. A couple of times. 
>
> I do personally like Sublime Text, but I'm starting to look at Emacs, 
> as it seems to be what a lot of (most of?) Clojurians use. Suggesting 
> the other options isn't meant to be a slight against Sublime... but 
> the fact of the matter is that if you simply can't get the REPL 
> running within the editor, it might be worth taking the time to look 
> at some of the other options and seeing if any of them click for you. 
>
> -- 
> Charlie Griefer 
> http://charlie.griefer.com/ 
>
> I have failed as much as I have succeeded. But I love my life. I love 
> my wife. And I wish you my kind of success. 
>


Hi again!

On the debate side, I'm pretty aware of the flames that usually develop and 
I've read lots of them: I'm not willing to initiate another one, hehe!

The thing about sublime is that it's light enough and not so hard as emac 
or Vim. I've read several Chas Emerick opinions on the topic of editors and 
I think they're spot on. Besides, I think I have enough learning Clojure to 
get used to and learn emacs at the same time.

It's just this damn REPL keybinding thing to the REPL. One thing I've 
realized, though... The F2 key is bound to the "Next bookmark" action (same 
as going through the menu Goto -> Bookmarks -> Next Bookmark.

Would you mind checking if that's the case for you also? And if you don't 
mind sharing which Sublime version you're using it'd be great also.


Thanks a lot for helping, I really appreciate it. 

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

Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?

2012-06-25 Thread Jacobo Polavieja

>
> Hi again!
>>
>
> On the debate side, I'm pretty aware of the flames that usually develop 
> and I've read lots of them: I'm not willing to initiate another one, hehe!
>
> The thing about sublime is that it's light enough and not so hard as emac 
> or Vim. I've read several Chas Emerick opinions on the topic of editors and 
> I think they're spot on. Besides, I think I have enough learning Clojure to 
> get used to and learn emacs at the same time.
>
> It's just this damn REPL keybinding thing to the REPL. One thing I've 
> realized, though... The F2 key is bound to the "Next bookmark" action (same 
> as going through the menu Goto -> Bookmarks -> Next Bookmark.
>
> Would you mind checking if that's the case for you also? And if you don't 
> mind sharing which Sublime version you're using it'd be great also.
>
>
> Thanks a lot for helping, I really appreciate it. 
>

Oh God, finally!

As it usually happens... the dumbest thing on Earth is what slows you down. 
The trick was in the "Default (Windows).sublime-keymap" file under the 
SublimeREPL package directory. It now looks like this: 
http://pastebin.com/BQAeSj5L

Before now, it had the lines at the bottom commented, as the last two. Once 
I uncommented them and added the pertinent commas, everything has started 
working well. Curiously, I realized this through a page on the 
ClojureScript Wiki: 
https://github.com/clojure/clojurescript/wiki/Sublime-Text-2
Hope this can be of use to anyone in the future!

Thanks a lot for helping me out Charlie. Now I just need another little 
tweak with Sublime to have my perfect environment.. but that I'll post in 
another thread to not mix things up.

Many many thanks. Cheers!

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

Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?

2012-06-25 Thread Jacobo Polavieja
Well, I thought I had specified in the title my problem with sending 
commands to SublimeREPL, but as I did it badly and wasn't so specific, I 
guess I can put my las "problem" in this very thread.

As we know, Sublime saves the session you're in and restores it everytime 
you open Sublime again. The thing is that when I have a ClojureREPL in the 
session and close Sublime, the Clojure REPL tab appears again but it really 
doesn't spawn a process to call to the REPL again. So, in short, I have to 
close that and open a new REPL for each session.

Do you know of any way to force to open a new REPL everytime we fire up 
Sublime?

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

Re: {ANN} Project Docs and Examples ... at the Alcove

2012-06-25 Thread John Gabriele
On Jun 25, 2:36 am, Vinzent  wrote:
>
> Honestly, what I'd really appreciate is a full-blown community site, kind
> of mix between clojure-toolbox, clojuredocs and emacswiki.

I like clojure-toolbox. It's categorization of projects is quite
useful, IMO.

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


Re: How I can convert this python line to clojure?

2012-06-25 Thread Robert Levy
I haven't tried VTK, but you might find my clojure-python lib useful.  It's
something I spent a little bit of time on a couple years ago, and have been
meaning to get back to it to improve it and turn it into a robust and
respectable library ;), but I haven't had a need for Jython interop in
anything I have been working on lately, so it's hard to prioritize it.
 That said, you may find this lib useful, or get some ideas from looking at
the source:  https://github.com/rplevy/clojure-python

On Sun, Jun 24, 2012 at 4:07 PM, Antonio Recio  wrote:

> The python line that I have rote before is not the one that I want to
> convert. The correct python line is this, and the result is "0". How I can
> convert it to clojure?
> print vtkDataSetAttributes.SCALARS
> ;=> 0
>
>
>  --
> 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 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

Re: How I can convert this python line to clojure?

2012-06-25 Thread Lars Nilsson
On Sun, Jun 24, 2012 at 4:07 PM, Antonio Recio  wrote:
> The python line that I have rote before is not the one that I want to
> convert. The correct python line is this, and the result is "0". How I can
> convert it to clojure?
> print vtkDataSetAttributes.SCALARS
> ;=> 0

Not sure if you can get the equivalent of 0 as output, but perhaps
referring to vtkDataSetAttributes$AttributeTypes/SCALARS will work?

Lars Nilsson

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


Re: How I can convert this python line to clojure?

2012-06-25 Thread Antonio Recio
@Lars Nilsson: I doesn't work. 

user=> (println vtkDataSetAttributes$AttributeTypes/SCALARS)
#

user=> (println vtk.vtkDataSetAttributes$AttributeTypes/SCALARS)
#

user=> (println vtk.vtkDataSetAttributes/SCALARS)
#

Not sure if you can get the equivalent of 0 as output, but perhaps 
> referring to vtkDataSetAttributes$AttributeTypes/SCALARS will work? 
>
> Lars Nilsson 
>

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

Re: [ANN] milieu - the environmentally friendly configuration tool (version 0.5.0)

2012-06-25 Thread Softaddicts
I think of Clojure configuration expressions as being human
editable/readable, testable in a few seconds (cut&paste in the REPL) and 
concise,
However, I do agree that anything is better than XML :)

Bad choice of words maybe ?

Luc
It's a holiday here I have some time to tease you a bit :)


> Hi Jay,
> > Thanks!  As far as JSON vs YAML, I think of these as generally human-edited
> configuration files, and I don't think it is controversial to claim that
> YAML is much better suited to human editing than JSON or XML.  As far as
> using the Clojure/Clojurescript reader instead of YAML, the way I see it is
> that it's just a choice between whether "everything is in Clojure" matters
> more, or whether making config files more readily manipulable by
> non-Clojure devs and non-devs is more the goal (say for example for an
> operations team working with a polyglot deployment).
> > That said, if there is interest in also supporting config files using
> native reader syntax it would be an easy addition to make, and wouldn't
> affect any other functionality.  You would simply expose the internal
> representation, which is just nested hash-maps e.g. {:dev {:some-config
> {:something "foo"} :other "bar"} :test {...}} and have a function to load
> clj files in in that format directly.  When loading in files with the
> reader, it would probably be a good idea to bind the dynamic var that
> disables the #=() reader macro.
> > Actually, a better idea might be to enable passing the config data as
> Clojure data as an optional alternative to specifying a YAML file.  The
> motivation would be to make it possible to load from any file format you
> choose in your own code and pass it in the data (so long as it can be made
> into a nested hash-map).
> > However I do think it makes sense for YAML file to remain the default way
> of loading data in any scenario, for reasons stated above.
> > On Sun, Jun 24, 2012 at 10:12 AM, Jay Fields  wrote:
> > > Hi Robert,
> >
> > Everything looks good, thanks for sharing the library. A philosophical
> > question, why YAML and not JSON or raw clj?
> >
> > Cheers, Jay
> >
> > On Jun 22, 2012, at 7:30 PM, Robert Levy wrote:
> >
> > It is my pleasure to announce the 0.5.0 release of milieu, a library for
> > environment-based application configuration that I have developed and
> > actively maintain at Draker  in Burlington,
> > Vermont.  Having made use of it in our day-to-day work for several months
> > now, we have found this library to be very useful for managing
> > configuration in our proprietary time-series data acquisition back-end
> > systems (also all written in Clojure of course).  I think this library will
> > add value to applications in any domain.
> >
> > The source can be found at https://github.com/drakerlabs/milieu and the
> > leiningen / maven dependency information is at http://clojars.org/milieu.
> > Issues/feedback and pull requests are of course welcome!
> >
> > milieu
> >
> > The environmentally friendly configuration tool.
> > --
> >
> > *Build status:* [image: Build 
> > Status]
> >  Features:
> >
> >-
> >
> >Set up environment-specific configuration for your Clojure
> >application, using the popular YAML file format.
> >-
> >
> >Access config values:
> >
> >Specifying config values:
> >
> >(config/value :my :config :value)
> >
> >This will access the value in
> >
> >dev|test|...:my:
> >  config:
> >value:
> >
> >Specifying config values as optional:
> >
> >(config/value| :my :config :value) ; same as config/value except doesn’t 
> > warn if it’s not found(config/value| [:my :config :value] "alternate 
> > value") ; provide alternate value
> >
> >-
> >
> >Optionally auto-load config file.
> >- using the default filename of "configure.yml" enables autoload
> >   - any other config file name can be specified by calling load-config
> >-
> >
> >Bind the environment within a calling context using with-env.
> >
> >(config/with-env env
> >  (when (config/value :some :setting) ... ))
> >
> >-
> >
> >Specify the default environment using the MILIEU_ENV system variable.
> >-
> >
> >Override environment-specific settings using arguments to your
> >command-line application.
> >
> >(config/commandline-overrides! args)
> >  (config/with-env env
> >... )
> >
> >-
> >
> >In cases where the environment can be variable, code evaluation can by
> >restricted in with-env or only-env, or more generally conditional using
> >if-env and when-env.
> >
> >;; If env is prod, the code in the body will not be exercised,;; an 
> > exception is thrown instead:(defn -main [env & args]
> >  (config/with-env [env :only [:test :dev]] ,,,))
> >
> >Alternatively (for example if you aren't in the context of a
> >   

ANN: lein-guzheng 0.3.1

2012-06-25 Thread David Greenberg
In this release, I've fixed the bugs related to midje, so that lein-guzheng
should be usable with lazytest. It now works by hooking
clojure.core/require, and providing an alternative loading mechanism for
instrumented namespaces. It is compatible with lein1 & lein2, and has a
test suite on travis-ci that tests against lein1 and lein2.

Get it with: [lein-guzheng "0.3.1"]

Use it with: lein guzheng my.first.ns other.ns -- midje

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

Re: verify that a fn throws an exception via testing?

2012-06-25 Thread Brian Marick

On Jun 25, 2012, at 6:21 AM, Jim - FooBar(); wrote:
> (fact (try (fn-that-throws-exc bad-arg)
> (catch Exception e :works)) => :works)

(fact
  (fn-that-throws-exc bad-arg) => (throws Exception))

You can also check the message, run a predicate over the exception, etc. 

https://github.com/marick/Midje/wiki/Checkers

> 
> Ah, ok.  Midje seems to support that, too.  See
> 
>  https://github.com/marick/Midje/wiki/Prerequisites-that-throw-exceptions

This is actually for sort of the opposite purpose. You're writing a function 
that needs to be able to handle an exception. That exception is hard to 
generate. So this is a way to artificially create and throw one.


-
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


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


Re: [ANN] milieu - the environmentally friendly configuration tool (version 0.5.0)

2012-06-25 Thread Robert Levy
Yes, I think we can all agree on that. My point about
editability/readability was specifically w/rt YAML vs JSON, but my argument
for YAML vs reader is all about the decoupling of config from language
specifics to make it so that not everyone who edits config needs to know
what a REPL is. ;)


On Mon, Jun 25, 2012 at 12:22 PM, Softaddicts
wrote:

> I think of Clojure configuration expressions as being human
> editable/readable, testable in a few seconds (cut&paste in the REPL) and
> concise,
> However, I do agree that anything is better than XML :)
>
> Bad choice of words maybe ?
>
> Luc
> It's a holiday here I have some time to tease you a bit :)
>
>
> > Hi Jay,
> > > Thanks!  As far as JSON vs YAML, I think of these as generally
> human-edited
> > configuration files, and I don't think it is controversial to claim that
> > YAML is much better suited to human editing than JSON or XML.  As far as
> > using the Clojure/Clojurescript reader instead of YAML, the way I see it
> is
> > that it's just a choice between whether "everything is in Clojure"
> matters
> > more, or whether making config files more readily manipulable by
> > non-Clojure devs and non-devs is more the goal (say for example for an
> > operations team working with a polyglot deployment).
> > > That said, if there is interest in also supporting config files using
> > native reader syntax it would be an easy addition to make, and wouldn't
> > affect any other functionality.  You would simply expose the internal
> > representation, which is just nested hash-maps e.g. {:dev {:some-config
> > {:something "foo"} :other "bar"} :test {...}} and have a function to load
> > clj files in in that format directly.  When loading in files with the
> > reader, it would probably be a good idea to bind the dynamic var that
> > disables the #=() reader macro.
> > > Actually, a better idea might be to enable passing the config data as
> > Clojure data as an optional alternative to specifying a YAML file.  The
> > motivation would be to make it possible to load from any file format you
> > choose in your own code and pass it in the data (so long as it can be
> made
> > into a nested hash-map).
> > > However I do think it makes sense for YAML file to remain the default
> way
> > of loading data in any scenario, for reasons stated above.
> > > On Sun, Jun 24, 2012 at 10:12 AM, Jay Fields 
> wrote:
> > > > Hi Robert,
> > >
> > > Everything looks good, thanks for sharing the library. A philosophical
> > > question, why YAML and not JSON or raw clj?
> > >
> > > Cheers, Jay
> > >
> > > On Jun 22, 2012, at 7:30 PM, Robert Levy wrote:
> > >
> > > It is my pleasure to announce the 0.5.0 release of milieu, a library
> for
> > > environment-based application configuration that I have developed and
> > > actively maintain at Draker  in
> Burlington,
> > > Vermont.  Having made use of it in our day-to-day work for several
> months
> > > now, we have found this library to be very useful for managing
> > > configuration in our proprietary time-series data acquisition back-end
> > > systems (also all written in Clojure of course).  I think this library
> will
> > > add value to applications in any domain.
> > >
> > > The source can be found at https://github.com/drakerlabs/milieu and
> the
> > > leiningen / maven dependency information is at
> http://clojars.org/milieu.
> > > Issues/feedback and pull requests are of course welcome!
> > >
> > > milieu
> > >
> > > The environmentally friendly configuration tool.
> > > --
> > >
> > > *Build status:* [image: Build Status]<
> http://travis-ci.org/drakerlabs/milieu>
> > >  Features:
> > >
> > >-
> > >
> > >Set up environment-specific configuration for your Clojure
> > >application, using the popular YAML file format.
> > >-
> > >
> > >Access config values:
> > >
> > >Specifying config values:
> > >
> > >(config/value :my :config :value)
> > >
> > >This will access the value in
> > >
> > >dev|test|...:my:
> > >  config:
> > >value:
> > >
> > >Specifying config values as optional:
> > >
> > >(config/value| :my :config :value) ; same as config/value except
> doesn’t warn if it’s not found(config/value| [:my :config :value]
> "alternate value") ; provide alternate value
> > >
> > >-
> > >
> > >Optionally auto-load config file.
> > >- using the default filename of "configure.yml" enables autoload
> > >   - any other config file name can be specified by calling
> load-config
> > >-
> > >
> > >Bind the environment within a calling context using with-env.
> > >
> > >(config/with-env env
> > >  (when (config/value :some :setting) ... ))
> > >
> > >-
> > >
> > >Specify the default environment using the MILIEU_ENV system
> variable.
> > >-
> > >
> > >Override environment-specific settings using arguments to your
> > >command-line appl

What are people using for distributed workers?

2012-06-25 Thread mstump
I'm curious as to what people are using for workers/queues. We're currently 
using storm, but im interested in evaluating alternatives.

Things I like about storm:
* Upload a jar and it automatically distributes the code to all worker 
nodes.
* Easy to write/reuse topologies without horribly distorting my code.
* Easy to visualize data as it flows through multiple queues.
* Easy to do fail/retry.

Things I don't like about storm:
* Can be somewhat flaky when performing tests, things fail/succeed in 
unpredictable ways but work in production or vice versa.
* Can't distinguish between failure (exception) and timeout.
* Must dedicate resources full time from a limited worker pool even through 
that queue is only used sporadicly.
* Can't link storm directly which means I need to 
maintain separate projects.

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

Re: How I can convert this python line to clojure?

2012-06-25 Thread Lars Nilsson
I didn't have Java vtk available so I just based it on

EnumTest.java:

public class EnumTest
{
  public enum Attr { Foo, Bar, Baz }
}

> javac EnumTest.java

Clojure:

=> (import 'EnumTest)
EnumTest
=> EnumTest$Attr/Foo
#

After having compiled VTK and extracted the content in vtk.jar, I see
no reference to SCALARS anywhere, including
vtkDataSetAttributes.java/class.

Lars Nilsson

On Mon, Jun 25, 2012 at 12:22 PM, Antonio Recio  wrote:
> @Lars Nilsson: I doesn't work.
>
> user=> (println vtkDataSetAttributes$AttributeTypes/SCALARS)
> # vtkDataSetAttributes$AttributeTypes, compiling:(REPL:4)>
>
> user=> (println vtk.vtkDataSetAttributes$AttributeTypes/SCALARS)
> # vtk.vtkDataSetAttributes$AttributeTypes, compiling:(REPL:4)>
>
> user=> (println vtk.vtkDataSetAttributes/SCALARS)
> # SCALARS in class vtk.vtkDataSetAttributes, compiling:(REPL:4)>
>
>
>> Not sure if you can get the equivalent of 0 as output, but perhaps
>> referring to vtkDataSetAttributes$AttributeTypes/SCALARS will work?
>>
>> Lars Nilsson
>
> --
> 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 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


Re: What are people using for distributed workers?

2012-06-25 Thread Phil Hagelberg
mstump  writes:

> I'm curious as to what people are using for workers/queues. We're
> currently using storm, but im interested in evaluating alternatives.

If you can make your workflow fit, it's hard to beat the simplicity of
sending expressions over a message queue like RabbitMQ. This is the
approach Die Roboter uses:

https://github.com/technomancy/die-roboter/

While this particular implementation hasn't seen a lot of real world
use, it's based upon 2 years of experience managing a huge data pipeline
over AMQP. Since Clojure forms are trivial to send over the wire it
turns out you can implement it in under 200 lines:

https://github.com/technomancy/die-roboter/blob/master/src/die/roboter.clj

Here's an example program that uses it to distribute log parsing:

https://github.com/technomancy/logan/blob/master/src/logan/core.clj

IMO asynchronous messaging over queues is often overlooked but has some
pretty compelling advantages to offer, not the least of which is the
simplicity of the execution model. With Rabbit you also get the ability
to retry failed jobs by having workers claim a message but hold off on
acking it until the form has returned a value.

The main gotcha is that long-running tasks need to regularly report
progress in order to avoid timing out, but Die Roboter comes with a
variant of clojure.java.io/copy that periodically resets timeouts.

-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


Re: What are people using for distributed workers?

2012-06-25 Thread Softaddicts
Hi,

our first release used ActiveMQ and a plethora of frameworks.

We soon realize that it is was killing us.
Our product runs on small clusters or should I say on clusters of small
footprint nodes.
For intra cluster stuff, external messaging softwares are to us an overkill so 
far.
They come with an impressive set of functions but we need a few only.

New release goes out by end of summer and uses zookeeper to implement
shared queues, shared locking and configuration management.
We use zookeeper-clj to interface with the servers.

We now send Clojure expressions (units of work)
instead of YAML messages. For now this layer is "alien" framework free.
No more hippo traps until we can see if we will benefit from an external 
frameworks.

Performance is now very good, previously we had several AMQ redundant monkey
chains committing to disk the same message streams several times, now it's 
faster and 
much more straightforward to test/debug.

It's also part of an effort to get rid of that diplodocus Java, the remaining 
Java 
components in the nearly ready release are using Clojure to connect to 
everything else.

We got Spring out, Terracotta, AMQ, Hibernate is to get out in late fall, ... 
The whole
elephant herd .

In the next planned future release we will use Avout to implement shared logic
between nodes. This logic is to increase parallelism. We have specific
requirements hardly met by mammoths like AMQ or at the expense of
more complexity.

By next November, Java is out and a few other rhinos.
The remaining software will be around 30k loc. Some of that is data.

Then we start to work on innovative stuff...

Luc


> I'm curious as to what people are using for workers/queues. We're currently 
> using storm, but im interested in evaluating alternatives.
> 
> Things I like about storm:
> * Upload a jar and it automatically distributes the code to all worker 
> nodes.
> * Easy to write/reuse topologies without horribly distorting my code.
> * Easy to visualize data as it flows through multiple queues.
> * Easy to do fail/retry.
> 
> Things I don't like about storm:
> * Can be somewhat flaky when performing tests, things fail/succeed in 
> unpredictable ways but work in production or vice versa.
> * Can't distinguish between failure (exception) and timeout.
> * Must dedicate resources full time from a limited worker pool even through 
> that queue is only used sporadicly.
> * Can't link storm directly which means I need to 
> maintain separate projects.
> 
> -- 
> 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
--
Softaddicts sent by ibisMail from my ipad!

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


Re: What are people using for distributed workers?

2012-06-25 Thread thenwithexpandedwingshesteershisflight
how about Lamina  ?

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

Re: [ANN] milieu - the environmentally friendly configuration tool (version 0.5.0)

2012-06-25 Thread Robert Levy
I actually hadn't thought of this use case, but I was asked if this was
possible. In version 0.6.0 which I just pushed (clj-yaml emits seqs when it
gets yaml vectors, which the change corrects for), you can access values in
config like this:

dev:
  fou:
- barre:
- mary: "8-)"
  fred: ":-|"
- mary: "*_*"
  fred: "-__-"
- barre:
   ...

using the same idiomatic "*-in" convention already being used, e.g.:

(config/value :fou 0 :barre 1 :mary)

Here is how it is expressed using the command-line-override feature:

myprogram dev --fou.0.barre.1.mary ":D"



>> > choose in your own code and pass it in the data (so long as it can be
>> made
>> > into a nested hash-map).
>>
>

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

Re: lein-daemon 0.3

2012-06-25 Thread Joao_Salcedo


On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>
> I've released a new version of lein-daemon. daemon is like 'lein run', 
> only it runs the process in the background rather than blocking. 
>
> 0.3 and up is a complete re-write, that no longer depends on apache 
> commons daemon. The new version has no dependencies on any external 
> programs. 
>
> For more, see https://github.com/arohner/lein-daemon 
>
>
On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>
> I've released a new version of lein-daemon. daemon is like 'lein run', 
> only it runs the process in the background rather than blocking. 
>
> 0.3 and up is a complete re-write, that no longer depends on apache 
> commons daemon. The new version has no dependencies on any external 
> programs. 
>
> For more, see https://github.com/arohner/lein-daemon 
>
>
On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>
> I've released a new version of lein-daemon. daemon is like 'lein run', 
> only it runs the process in the background rather than blocking. 
>
> 0.3 and up is a complete re-write, that no longer depends on apache 
> commons daemon. The new version has no dependencies on any external 
> programs. 
>
> For more, see https://github.com/arohner/lein-daemon 
>
>
On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>
> I've released a new version of lein-daemon. daemon is like 'lein run', 
> only it runs the process in the background rather than blocking. 
>
> 0.3 and up is a complete re-write, that no longer depends on apache 
> commons daemon. The new version has no dependencies on any external 
> programs. 
>
> For more, see https://github.com/arohner/lein-daemon 
>

Hi All I am using lein-daemon so it is a really great tool.
I have a question it might be silly , but when I run " lein daemon start 
:project-name" it is great but how can I get the propmt back
it is running compojure and the last line is 
2012-06-26 12:51:16.234:INFO:oejs.AbstractConnector:Started 
SelectChannelConnector@0.0.0.0:3000
but I need the prompt back to start other scripts.
Any ideas about how can I achieve this.

Cheers,

JS 

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

Re: {ANN} Project Docs and Examples ... at the Alcove

2012-06-25 Thread John Gabriele
On Jun 24, 11:32 pm, John Gabriele  wrote:
>
> Opinions? Concerns? Wild praise? Searing complaints? General disinterest?
>

Hi all,

Thanks to feeback --- both here and elsewhere. A handful of points are
now clear:

  * It probably *is* too much trouble to ask folks to fork & send a
pull-request just to add code examples

  * Users who want to add example code can just as well add it to the
project's github wiki. If there's no wiki, they can ask the maintainer
to please enable the wiki.

  * If a github project changes maintainer, it's easy enough to clone
the github wiki repo for use by the new maintainer.

  * Using github's Markdown for docs is often sufficient. If a user
wants the extra features of Pandoc's enhanced-Markdown, nothing's
stopping them from using that and generating html themselves.

  * The categorized listing of modules at clojure-toolbox is nicer
than a flat listing like at the alcove, and I'm not interested in
trying to duplicate effort there.

  * The community seems (to me) to be headed toward standardizing on
doc/*.md files for docs regardless, since github automatically renders
them nicely and everyone already knows markdown and writes README.md
files.

  * The community seems pretty happy with Clojars + Github. The only
issue I have is that some projects there don't have their :url and/
or :description keys properly set (thus they're not displayed (or
don't contain anything useful) at Clojars). But we can add the
relevant info over time.

  * If clojuredocs.org is rewritten in Clojure, I'm guessing a 3rd-
party project examples feature could be added pretty easily if it
turns out users really want it.

So, it now seems that the alcove --- in its current incarnation --- is
not as useful as I'd originally thought. I'm going to remove it, and
instead focus on helping make sure projects on Clojars have their :url
and :description in order.

Thanks!
---John

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


Re: {ANN} Project Docs and Examples ... at the Alcove

2012-06-25 Thread Michael Klishin
John Gabriele:

> So, it now seems that the alcove --- in its current incarnation --- is
> not as useful as I'd originally thought. I'm going to remove it, and
> instead focus on helping make sure projects on Clojars have their :url
> and :description in order.

John,

Please don't get discouraged. There are similar services (readthedocs.org, 
rubydoc.info) and they took a while (years) to
get all the tooling, workflows and community awareness to the levels when these 
services are really useful and adopted.

I personally believe that there is no other thing Clojure needs right now as 
badly as well written, maintained, good looking documentation for the language 
itself, clojure.core and most popular open source libraries.

Your attempt is a good start and clojuredocs.org one day will be Clojure end to 
end (I believe the analyzer part has always been in Clojure).

MK

mich...@defprotocol.org



signature.asc
Description: Message signed with OpenPGP using GPGMail


Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Cedric Greevey
user=> 1e308
1.0E308

user=> (* 10.0 1e308)
Infinity

user=> 1e309
Infinity

Whuh? Double precision exponents should go up to 1023 and single
precision shouldn't go above 127. There's no floating point format in
commonplace use that maxes out its exponent at 308.

What is going on here?

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


Re: {ANN} Project Docs and Examples ... at the Alcove

2012-06-25 Thread John Gabriele
On Jun 25, 11:58 pm, Michael Klishin 
wrote:
>
> Please don't get discouraged.

Thanks for the kind words, Michael! :) Not discouraged, but rather, I
want to make best use of existing resources.

> There are similar services (readthedocs.org, rubydoc.info) and they took a 
> while (years) to
> get all the tooling, workflows and community awareness to the levels when 
> these services are really useful and adopted.
>
> I personally believe that there is no other thing Clojure needs right now as 
> badly as well written, maintained, good looking documentation for the 
> language itself, clojure.core and most popular open source libraries.

I agree that great docs are a top priority, however, the way they're
currently being provided for external Clojure projects seems to be
pretty good for the time being. I mean, most Clojure projects are
using github, and github happily renders the docs as html. The
ingredients are there. The crucial piece (as I (now) see it) is being
able to find the project you want at Clojars so you can follow the
link to the docs (at github). After doing some reading, if this
project is not your cup of tea, go back to clojure-toolbox or #clojure
(irc), get help choosing something else, and go back to Clojars to
find it.

So, rather than try to duplicate what github is already doing for us
right now, I think it probably makes more sense to spend that time
writing docs and also making sure users can find the relevant github
repo from clojars.

---John

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


Re: {ANN} Project Docs and Examples ... at the Alcove

2012-06-25 Thread Phil Hagelberg
On Mon, Jun 25, 2012 at 9:52 PM, John Gabriele  wrote:
> I agree that great docs are a top priority, however, the way they're
> currently being provided for external Clojure projects seems to be
> pretty good for the time being. I mean, most Clojure projects are
> using github, and github happily renders the docs as html. The
> ingredients are there.

Right; the way I see it the two missing pieces are 0) encouraging
library authors to write better documentation and 1) ensuring that
documentation is discoverable.

For 0 one change I've made is to have the default `lein new` skeleton
include a doc/ directory with a pointer to explain what kind of things
to write. There's a temptation to documentation that's autogenerated
from the source code a la Marginalia, but that's really only suited
for reference material, and most libraries need introductory long-form
guides to help people out.
(http://jacobian.org/writing/great-documentation/what-to-write/
addresses this topic well.) The problem here is that it's hard work,
and most maintainers don't prioritize it.

For 1 I think John is right that simply getting projects to declare a
:url that Clojars can link to will make a big difference. If you
maintain a project that doesn't link to its home page from Clojars,
all it takes is the addition of a :url in project.clj. If you use
`lein deploy clojars` it will nag you if you're missing that, so that
should help too. But I think getting maintainers to care about docs is
the big one. It's good to see the ClojureWerkz libraries setting a
good example; I hope others will follow.

-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


Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Sean Corfield
On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey  wrote:
> user=> 1e309
> Infinity

FWIW, on 1.4.0 I get:

user=> 1e309
CompilerException java.lang.RuntimeException: Unable to resolve
symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread dennis zhuang
user=> Double/MAX_VALUE
1.7976931348623157E308


2012/6/26 Sean Corfield 

> On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey 
> wrote:
> > user=> 1e309
> > Infinity
>
> FWIW, on 1.4.0 I get:
>
> user=> 1e309
> CompilerException java.lang.RuntimeException: Unable to resolve
> symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> 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
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: ANN: lambic v. 0.1.0

2012-06-25 Thread Tom Faulhaber
+1

I've always thought that this sort of thing should be more decorative and 
transparent with the tools we have in Clojure, core.match, and core.logic. 
This is a neat way to proceed.

I'll be keeping my eyes on your progress!

Tom

On Thursday, June 14, 2012 4:44:10 PM UTC-7, rob wrote:
>
> This announcement is more of a call for suggestions (even pull requests if 
> you are moved to do so) as there's not much to it yet, just enough to to 
> demonstrate the concept for simpler transformations.  I'm thinking of how 
> best to go about supporting a wider range of sequence transformations.
>
> https://github.com/rplevy/lambic
> https://clojars.org/lambic
>
> The basic idea is that languages like Prolog are very good at manipulating 
> sequences "by example" based on pattern matching, and that using core.match 
> this can become the norm for Clojure too (either using this library or some 
> other I don't yet know about.)
>
> In Clojure, when you encounter data that matches pattern X and you want to 
> systematically turn into data of the form Y, depending on how complex the 
> structures are, you tend to start with some solution, change it around, and 
> ultimately end up with a very elegant solution that is clearly the "best 
> way".
>
> My present take on how to implement lambic is essentially to catalog these 
> "best ways" for a number of different classes of sequence transformations, 
> so that lambic knows what to do with them.  What do you think of this idea? 
>  Is there a way to use logical magic (magical logic?) to do something 
> better? ;)
>

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

Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Cedric Greevey
On Tue, Jun 26, 2012 at 1:11 AM, Sean Corfield  wrote:
> On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey  wrote:
>> user=> 1e309
>> Infinity
>
> FWIW, on 1.4.0 I get:
>
> user=> 1e309
> CompilerException java.lang.RuntimeException: Unable to resolve
> symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)

That's *really* broken.

Unfortunately, digging deeper I found that the 1023 exponent limit is
2^1023, not 10^1023, which means it really is around 309. I've had to
reimplement some stuff using BigDecimals and to write these, since
there seem to be no corresponding methods built into Java anywhere:

(defn log [x]
  (if (instance? BigDecimal x)
(let [s (.scale x)]
  (+ (Math/log (.scaleByPowerOfTen x s)) (* (- s) (Math/log 10.0
(Math/log x)))

(defn log10 [x]
  (/ (log x) (Math/log 10.0)))

(defn exp [x]
  (let [r (Math/exp x)]
(if (.isInfinite r)
  (let [p10 (int (/ x (Math/log 10.0)))]
  (.scaleByPowerOfTen (bigdec (Math/exp (- x (* p10 (Math/log
10.0) p10))
  r)))

These seem to work fine, where extended precision isn't really needed,
only large exponents. However, I've run into another problem, which is
that when doubles and BigDecimals mix 1.3 seems to convert to doubles.
This appears to contradict part of

http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics

specifically "When different types of numbers are used in a math
operation, the result will be the larger or more general of the two
types."

That doesn't seem to hold when the types are double and BigDecimal,
for some reason. Is there any setting I can change (analogous to
with-precision) to force BigDecimal contagion? I considered using
those icky primed operators, but for some reason /' seems to be
missing from the set and I need division...

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


Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Leif
user> Double/MAX_VALUE
1.7976931348623157E308

>From http://docs.oracle.com/javase/6/docs/api/java/lang/Double.html :
"A constant holding the largest positive finite value of type double, (2-2^
-52)·2^1023. It is equal to the hexadecimal floating-point literal 
0x1.fP+1023 and also equal to 
Double.longBitsToDouble(0x7fefL). "

To explain the decimal exponent,
user> (/ (Math/log 10) (Math/log 2))
3.3219280948873626 
user> (/ 1024 3.3219280948873626)
308.2547155599167

--Leif

On Tuesday, June 26, 2012 12:19:49 AM UTC-4, Cedric Greevey wrote:
>
> user=> 1e308 
> 1.0E308 
>
> user=> (* 10.0 1e308) 
> Infinity 
>
> user=> 1e309 
> Infinity 
>
> Whuh? Double precision exponents should go up to 1023 and single 
> precision shouldn't go above 127. There's no floating point format in 
> commonplace use that maxes out its exponent at 308. 
>
> What is going on here? 
>

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

Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread dennis zhuang
Added a postfix "M" to make the number as BigDecimal or "N" as a BigInteger:

user=> 1e308M
1E+308M
user=> (class 1e308M)
java.math.BigDecimal
user=> (* 10.0 1e108M)
1.0E109

2012/6/26 Cedric Greevey 

> On Tue, Jun 26, 2012 at 1:11 AM, Sean Corfield 
> wrote:
> > On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey 
> wrote:
> >> user=> 1e309
> >> Infinity
> >
> > FWIW, on 1.4.0 I get:
> >
> > user=> 1e309
> > CompilerException java.lang.RuntimeException: Unable to resolve
> > symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)
>
> That's *really* broken.
>
> Unfortunately, digging deeper I found that the 1023 exponent limit is
> 2^1023, not 10^1023, which means it really is around 309. I've had to
> reimplement some stuff using BigDecimals and to write these, since
> there seem to be no corresponding methods built into Java anywhere:
>
> (defn log [x]
>   (if (instance? BigDecimal x)
> (let [s (.scale x)]
>   (+ (Math/log (.scaleByPowerOfTen x s)) (* (- s) (Math/log 10.0
> (Math/log x)))
>
> (defn log10 [x]
>   (/ (log x) (Math/log 10.0)))
>
> (defn exp [x]
>   (let [r (Math/exp x)]
> (if (.isInfinite r)
>   (let [p10 (int (/ x (Math/log 10.0)))]
>   (.scaleByPowerOfTen (bigdec (Math/exp (- x (* p10 (Math/log
> 10.0) p10))
>   r)))
>
> These seem to work fine, where extended precision isn't really needed,
> only large exponents. However, I've run into another problem, which is
> that when doubles and BigDecimals mix 1.3 seems to convert to doubles.
> This appears to contradict part of
>
> http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
>
> specifically "When different types of numbers are used in a math
> operation, the result will be the larger or more general of the two
> types."
>
> That doesn't seem to hold when the types are double and BigDecimal,
> for some reason. Is there any setting I can change (analogous to
> with-precision) to force BigDecimal contagion? I considered using
> those icky primed operators, but for some reason /' seems to be
> missing from the set and I need division...
>
> --
> 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
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: lein-daemon 0.3

2012-06-25 Thread Murtaza Husain

Hi,

This is a very useful tool, and I will be giving it a spin.

I would like to specify a file where it should log all the command line 
output, can I do that? 

Thanks,
Murtaza

On Tuesday, June 26, 2012 8:31:45 AM UTC+5:30, Joao_Salcedo wrote:
>
>
>
> On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>>
>> I've released a new version of lein-daemon. daemon is like 'lein run', 
>> only it runs the process in the background rather than blocking. 
>>
>> 0.3 and up is a complete re-write, that no longer depends on apache 
>> commons daemon. The new version has no dependencies on any external 
>> programs. 
>>
>> For more, see https://github.com/arohner/lein-daemon 
>>
>>
> On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>>
>> I've released a new version of lein-daemon. daemon is like 'lein run', 
>> only it runs the process in the background rather than blocking. 
>>
>> 0.3 and up is a complete re-write, that no longer depends on apache 
>> commons daemon. The new version has no dependencies on any external 
>> programs. 
>>
>> For more, see https://github.com/arohner/lein-daemon 
>>
>>
> On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>>
>> I've released a new version of lein-daemon. daemon is like 'lein run', 
>> only it runs the process in the background rather than blocking. 
>>
>> 0.3 and up is a complete re-write, that no longer depends on apache 
>> commons daemon. The new version has no dependencies on any external 
>> programs. 
>>
>> For more, see https://github.com/arohner/lein-daemon 
>>
>>
> On Thursday, May 12, 2011 2:18:57 PM UTC+10, Allen Rohner wrote:
>>
>> I've released a new version of lein-daemon. daemon is like 'lein run', 
>> only it runs the process in the background rather than blocking. 
>>
>> 0.3 and up is a complete re-write, that no longer depends on apache 
>> commons daemon. The new version has no dependencies on any external 
>> programs. 
>>
>> For more, see https://github.com/arohner/lein-daemon 
>>
>
> Hi All I am using lein-daemon so it is a really great tool.
> I have a question it might be silly , but when I run " lein daemon start 
> :project-name" it is great but how can I get the propmt back
> it is running compojure and the last line is 
> 2012-06-26 12:51:16.234:INFO:oejs.AbstractConnector:Started 
> SelectChannelConnector@0.0.0.0:3000
> but I need the prompt back to start other scripts.
> Any ideas about how can I achieve this.
>
> Cheers,
>
> JS 
>

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

Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Cedric Greevey
On Tue, Jun 26, 2012 at 1:30 AM, dennis zhuang  wrote:
> Added a postfix "M" to make the number as BigDecimal or "N" as a BigInteger:

That doesn't work here. It's not double literals that are the problem,
but computed values that are coming out as doubles. Furthermore, I'd
like the code to use BigDecimals when it must, but use doubles when it
can, so coercing everything with bigdec is not ideal.

With int/BigInt it would be easy enough, as one BigInt would spread to
everything it touched. But for some reason doubles and BigDecimals
don't behave the same way. Perhaps because they figured any double
clobbers any reliability to the extra precision in a BigDecimal
calculation. But that didn't consider that someone might be doing
calculations where they don't need a wider mantissa but do need
exponents bigger than 10^308. In that situation, BigDecimal contagion
is desirable. So I'd like to know of some way to switch it on for a
particular chunk of code, or operators analogous to the primed
operators that favor BigDecimal over double. (It's worse than just the
lack of /', by the way. +' and friends favor double over BigDecimal
the same as + and friends. Arrrgh!)

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


Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread Sean Corfield
On Mon, Jun 25, 2012 at 10:30 PM, dennis zhuang  wrote:
> Added a postfix "M" to make the number as BigDecimal or "N" as a BigInteger:

Yes...

user=> 1e309M
1E+309M

The "Infinity" exception seems wrong but clearly using BigDecimal makes it work.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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


How does one make BigDecimals contagious over doubles, instead of the other way around, in a particular computation?

2012-06-25 Thread Cedric Greevey
How does one make BigDecimals contagious over doubles, instead of the
other way around, in a particular computation? I can see the reasoning
for making doubles preferred by default: once an operation combines a
double with a BigDecimal, the additional BigDecimal precision is
consumed by the magnitude of the possible error.

However, in some instances one does not need a wide mantissa but does
need more than 10 bits of exponent magnitude, and so needs
BigDecimals, and needs them to "win" when mixed with doubles. So, how
is this done? I've already checked that +' and friends aren't the
solution, and I'd prefer not to force everything to BigDecimals even
when doubles will do fine by slapping Ms and bigdecs everywhere...

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