Re: Local bindings w/o let

2011-07-11 Thread Michael Wood
On 11 July 2011 03:42, Luc Prefontaine  wrote:
> Lets try to clear the confusion a bit here:
>
> (def max1 [x] x)
> (def max2 [x y] (if (> x y) x y))
> (def max3 ([x y & more] (reduce max (max x y) more)))
>
> The above a three different fns.

To be even more clear, the above should be:

(defn max1 [x] x)
(defn max2 [x y] (if (> x y) x y))
(defn max3 ([x y & more] (reduce max (max x y) more)))

:)

> max1 has only the arg x.
> max2 has only x and y
> and max3 has x and y and maybe other arguments to select the maximum from.
> The first "[]" in each fn are bindings for function arguments.
>
> Now you are allowed to define a fn with different forms based on the
> number of arguments:
>
> (defn max
>  "Returns the greatest of the nums."
>   {:added "1.0"}
>   ([x] x)                                      ;; <- max1
>   ([x y] (if (> x y) x y))                     ;; <- max2
>   ([x y & more] (reduce max (max x y) more)))  ;; <- max3
>
> is the equivalent of max1, max2 and max3 but using a single name.
> Clojure will select the form to execute based on the # of arguments.
> "x" is a different binding in each of the forms, not the same "x"
> across forms.
>
> Luc P.

-- 
Michael Wood 

-- 
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: Native compiler on Clojure

2011-07-11 Thread Philipp Meier
On 11 Jul., 00:26, cran1988  wrote:
> Did anyone started creating native compiler for Clojure language ?

Do you mean a compiler which emits native code or do you mean a
compiler
written in clojure emitting java byte code?

-billy.

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


Too many arguments to if

2011-07-11 Thread Antonio Recio
I get the error "Too many arguments to if" with this. Do you have any 
suggestion?

(defn make-tree [tree [n1 n2 n3 n4]]
  (.addItem tree n1)
  (if (empty? n2)
(.setChildrenAllowed tree n1 false)
(doto tree
  (.addItem n2)
  (.setParent n2 n1)
  (.expandItemsRecursively n1))
(if (empty? n3)
  (.setChildrenAllowed tree n2 false)
  (doto tree
(.addItem n3)
(.setParent n3 n2)
(.expandItemsRecursively n2))
  (if (empty? n4)
(.setChildrenAllowed tree n3 false)
(doto tree
  (.addItem n4)
  (.setParent n4 n3)
  (.expandItemsRecursively n3)
  (.setChildrenAllowed n4 false)
  tree)

-- 
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: Too many arguments to if

2011-07-11 Thread Tassilo Horn
Antonio Recio  writes:

Hi Antonio,

> I get the error "Too many arguments to if" with this. Do you have any
> suggestion?

`if' expects exacly one test, one then-form, and one else-form.  Your
first and second `if' contain two forms in else.  You have to wrap them
in a `do'.

--8<---cut here---start->8---
(defn make-tree [tree [n1 n2 n3 n4]]
  (.addItem tree n1)
  (if (empty? n2)
(.setChildrenAllowed tree n1 false)
(do
  (doto tree
(.addItem n2)
(.setParent n2 n1)
(.expandItemsRecursively n1))
  (if (empty? n3)
(.setChildrenAllowed tree n2 false)
(do
  (doto tree
(.addItem n3)
(.setParent n3 n2)
(.expandItemsRecursively n2))
  (if (empty? n4)
(.setChildrenAllowed tree n3 false)
(do
  (doto tree
(.addItem n4)
(.setParent n4 n3)
(.expandItemsRecursively n3)
(.setChildrenAllowed n4 false)
tree
--8<---cut here---end--->8---

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


a lazy version of shuffle.

2011-07-11 Thread Sunil S Nandihalli
Hello everybody,
 I think a lazy version of shuffle would be a good addtion to the core. I
tried googling for one and found
http://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.html which was
infact slower than original shuffle and was unable to reproduce the
performance claims made there in. In fact the experiment showed that the
lazy-shuffle was about 10 times slower (of course depends on the size of the
collection to be shuffled).. Can somebody help me ?

Thanks,
Sunil.

-- 
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: a lazy version of shuffle.

2011-07-11 Thread Tassilo Horn
Sunil S Nandihalli  writes:

Hi Sunil,

>  I think a lazy version of shuffle would be a good addtion to the
> core. I tried googling for one and found
> http://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.html which
> was infact slower than original shuffle and was unable to reproduce
> the performance claims made there in.

I think there is no way to implement a "good" lazy version of shuffle.
Correct shuffling, i.e., the result should be a real pseudo-random
permutation of all elements, can only be defined on finite seqs anyway.
And there, one has to realize the given seq.  In the code you cite,
there's

  (defn lazy-shuffle [lst fetch-len]
(let [len (count lst)
  ^^^

which does exactly that.  So here only the cheap creation of the
shuffled seq is lazy, but the possibly expensive calculation of the
given seq is (and has to be done) directly.

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: a lazy version of shuffle.

2011-07-11 Thread Sunil S Nandihalli
yea true, the full sequence has to be realized before it is shuffled .. but
however the thing is that I am only interested in the first couple of
elements of the shuffled sequence. That is the lazy part I am talking about.
But I guess I won't be winning much there.. And again, I think I would have
got better performance if I had passed in a "Counted" collection which was
not true in my case..
Sunil.

On Mon, Jul 11, 2011 at 4:27 PM, Tassilo Horn wrote:

> Sunil S Nandihalli  writes:
>
> Hi Sunil,
>
> >  I think a lazy version of shuffle would be a good addtion to the
> > core. I tried googling for one and found
> > http://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.html which
> > was infact slower than original shuffle and was unable to reproduce
> > the performance claims made there in.
>
> I think there is no way to implement a "good" lazy version of shuffle.
> Correct shuffling, i.e., the result should be a real pseudo-random
> permutation of all elements, can only be defined on finite seqs anyway.
> And there, one has to realize the given seq.  In the code you cite,
> there's
>
>  (defn lazy-shuffle [lst fetch-len]
>(let [len (count lst)
>  ^^^
>
> which does exactly that.  So here only the cheap creation of the
> shuffled seq is lazy, but the possibly expensive calculation of the
> given seq is (and has to be done) directly.
>
> 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

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread mike.w.me...@gmail.com
Ken Wesson  wrote:

>On Wed, Jul 6, 2011 at 4:30 AM, Michael Wood 
>wrote:
>> On 6 July 2011 10:14, Ken Wesson  wrote:
>>> Sorry, but I think version control and, particularly, dealing with
>>> edit collisions is not something you can solve as easily as just
>>> slapping a lock onto each file access, or else version control
>servers
>>> could just be FTP servers that locked their shared files during each
>>> access.
>>
>> Maybe so, but that is all beside the point. The point was that
>> "repository" needn't mean "networked".
>
>Maybe just "repository that isn't fragile or outright broken" then. ;)

In that case, pretty much all unix-based source control systems are "fragile or 
outright broken", as they all have a "files on disk" mode that doesn't require 
a server: cvs, svn, git, hg, etc. Even fossil - which uses an ACID SQL database 
to store things - does this. Perforce is the only exception I can think of. 

>> If the CVS clients are the only ones doing the locking, then why not?
>
>ARE they the only ones doing the locking OR otherwise accessing the
>files, though?

Once you allow arbitrary commands to access the data on disk, you have 
problems. How you do file locking doesn't matter.

>>> *minimum* it would seem that a real database with ACID and
>>> transactions would be needed -- A to avoid race conditions (no
>>> advisory locks here!), C to keep the internal state invariants
>valid,

As I mentioned, fossil does this. However, the database is embedded, meaning it 
uses those advisory locks to deal with inter-process coordination.

>> This is why various people moved away from CVS. To get atomic
>commits etc.
>>
>>> I to be able to deal with edit collisions in a sane manner, and D
>for
>>> the obvious reasons. And a suitable software front-end. And now
>we're
>>> back to having at least one server in the mix, namely the DBMS at
>the
>>> backend. :)

The only source control system I know that uses an ACID database doesn't need a 
back end server.

>> Right, I agree it's best to have a server controlling access to the
>> repository, but that does not mean that the concept of a repository
>is
>> linked to having a server or a network.
>
>No, just the concept of a reliable repository. ;)

Only if it's really badly designed. Like early versions of subversion. Of 
course, they broke even worse if you put them on a server instead of using 
direct file access.

>>> If you don't have a satisfactory answer there, then you probably
>need
>>> a real database. Of course perhaps you are clever and can design
>your
>>> own on-disk data structures that will fail-soft in some manner under
>>> such circumstances and convince yourself beyond a reasonable doubt
>>> that it'll work, but if not ...
>>
>> CVS is an old version control system that was far better than the
>> other things around at the time it was invented, but most people seem
>> to agree that other, more modern, version control systems are better
>> and/or more reliable.

And all the popular ones have clients that can directly access the repository 
without a server.

-- 
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.

-- 
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: Native compiler on Clojure

2011-07-11 Thread Bronsa
i think he means clojure in clojure
Il giorno 11/lug/2011 12.12, "Philipp Meier"  ha scritto:
> On 11 Jul., 00:26, cran1988  wrote:
>> Did anyone started creating native compiler for Clojure language ?
>
> Do you mean a compiler which emits native code or do you mean a
> compiler
> written in clojure emitting java byte code?
>
> -billy.
>
> --
> 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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Ken Wesson
On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com  wrote:
[snip most of post whose sole purpose seems to be to gainsay anything I write]

> The only source control system I know that uses an ACID database doesn't
> need a back end server.

How exactly is this possible? Databases *are* servers. "Database" and
"DBMS" are used more-or-less synonymously (when "database" isn't used
more broadly than ACID/SQL/etc.) and the "S" in "DBMS" stands for
"server". SQL is to databases/clients as HTTP GET/POST syntax is to
web servers/browsers. Etc.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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: a lazy version of shuffle.

2011-07-11 Thread Tassilo Horn
Sunil S Nandihalli  writes:

Hi Sunil,

> yea true, the full sequence has to be realized before it is shuffled
> .. but however the thing is that I am only interested in the first
> couple of elements of the shuffled sequence.

Well, in that case, you can use the standard shuffle, right?  For
example, to get a random permutation of the first 10 natural numbers,
you can do:

  (shuffle (take 10 (iterate inc 0)))
  ==> [1 6 9 8 4 5 3 7 0 2]

However, you cannot get a seq of 10 randomly chosen natural numbers,
because that would mean to realize the seq of natural numbers.

  (take 10 (shuffle (iterate inc 0)))
  ==> Runs till hell freezes over

But if you specify an upper limit, then it'll work again.

  (take 10 (shuffle (take 1000 (iterate inc 0
  ==> (748 460 353 349 586 743 994 404 468 306)

Of course, that will realize the first 1000 natural numbers, although
you only take 10 out of it.

Well, in that use-case, you'd probably want to go with rand-int anyway.

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


Odp: Re: a lazy version of shuffle.

2011-07-11 Thread Daniel Janus
One thing to keep in mind when shuffling is that, by default,
if the input sequence is large enough then most permutations
can never be generated by shuffle. This follows naturally from
the Dirichlet's pigeonhole principle: there are only 2^64 possible
seeds (states of the RNG), but (factorial (count s)) distinct
permutations.

Daniel

-- 
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: jdbc and postgresql type problem

2011-07-11 Thread Aaron Bedra
Silly question, but which version of java.jdbc are you using?  Up until 
0.0.3 I had no end of troubles with psql because of the batchExecute issue.


Cheers,

Aaron Bedra
--
Clojure/core
http://clojure.com

On 07/11/2011 02:48 AM, Brian Carper wrote:

On Jul 10, 4:52 pm, Wilfred  wrote:

I'm at a bit of a loss. "UPDATE comments SET approved='1' WHERE id =
'1'" works fine in psql. approved is a boolean field, so is this an
issue with the SQL library producing incorrect SQL?

I think this is an oddity with the JDBC driver for PostgreSQL.  The
driver doesn't seem to like doing automatic typecasting.  Try this:

(sql/update-values :comments
["id = cast(? as integer)" id]
;; alternatively "id = ?::integer"
{:approved true})

Or you could (Integer/parseInt id) to do the cast before you pass it
as parameter, though in either case you should validate your id before
casting, if you want to avoid dying on poorly-formed input.


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


Clojure Wiki for general public

2011-07-11 Thread Sergey Didenko
It seems we don't have a *centralized* wiki not just for the Clojure Core
developers, but for everybody in our community.

Application developers have to look for *broad* info all over different
resources. I have just tried Clojure 1.3 and realized I have to google a lot
to find answers.


   - ClojureDocs.org is for 1.2. clojure.org.
   - http://dev.clojure.org/display/doc/1.3 seems to be in a transitional
   state.
   - Library catalogs are on a few other sites and have no wiki
   functionality.
   - Advises on moving away from clojure.contrib are spread in the mail
   list.
   - Stackoverflow's "clojure" tag is of "question-answers" nature and seems
   not to attract a lot of us.
   - GitHub has a lot of libraries but sometimes it's hard to compare them.
   - A lot of useful blog posts are reachable mainly from Google.


May be we need a Clojure Wiki for "regular" users? Promoted from official
resources to be the main attraction point.

Do I miss anything?

Regards, Sergey.

-- 
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 to add jar files to leiningen projects?

2011-07-11 Thread finbeu
Hello,

I have some external jar libaries that I need to import in my clojure 
namespace. As I just started to use leinigen, I don't understand how to add 
them to my project. Let's say the library resides in c:\temp\jars\mylib.jar

How do I add this properly to mein leinigen project?

(defproject myproject "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
 [org.clojure/clojure-contrib "1.2.0"]
 [WHAT TO PUT IN HERE?]])

I assume I have to put that to .m2 repository but how? 

Thanks.

- Finn

-- 
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 to add jar files to leiningen projects?

2011-07-11 Thread Mark Rathwell
To install the jars to your local maven repository (~/.m2):

mvn install:install-file
  -Dfile=
  -DgroupId=
  -DartifactId=
  -Dversion=
  -Dpackaging=
  -DgeneratePom=true

Where:   the path to the file to load
 the group that the file should be registered under
  the artifact name for the file
  the version of the file
the packaging of the file e.g. jar



Then, in your project.clj, specify the groupid/artifact-id and version:

(defproject myproject "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
 [org.clojure/clojure-contrib "1.2.0"]
 *[finbeau/special-jar "1.0.0"]*])  ;; or whatever
group-id/artifact-id and version you specified above



On Mon, Jul 11, 2011 at 11:23 AM, finbeu  wrote:

> Hello,
>
> I have some external jar libaries that I need to import in my clojure
> namespace. As I just started to use leinigen, I don't understand how to add
> them to my project. Let's say the library resides in c:\temp\jars\mylib.jar
>
> How do I add this properly to mein leinigen project?
>
> (defproject myproject "1.0.0-SNAPSHOT"
>   :description "FIXME: write description"
>   :dependencies [[org.clojure/clojure "1.2.1"]
>  [org.clojure/clojure-contrib "1.2.0"]
>  [WHAT TO PUT IN HERE?]])
>
> I assume I have to put that to .m2 repository but how?
>
> Thanks.
>
> - Finn
>
> --
> 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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Alessio Stalla
On 11 Lug, 13:51, Ken Wesson  wrote:
> On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com  
> wrote:
>
> [snip most of post whose sole purpose seems to be to gainsay anything I write]
>
> > The only source control system I know that uses an ACID database doesn't
> > need a back end server.
>
> How exactly is this possible? Databases *are* servers.

No, many of them offer access through a server, but the server is
usually one component among many other ones. For example, you are not
required to start the network listener in order to use Oracle. Not
speaking of all the embedded databases such as Neo4j, Derby, etc.

> "Database" and
> "DBMS" are used more-or-less synonymously (when "database" isn't used
> more broadly than ACID/SQL/etc.) and the "S" in "DBMS" stands for
> "server".

No, it stands for "system": 
http://en.wikipedia.org/wiki/Database_management_system

> SQL is to databases/clients as HTTP GET/POST syntax is to
> web servers/browsers. Etc.

HTTP is defined in terms of network communication, though you could in
principle make process-local HTTP requests. SQL instead doesn't need
to know anything at all about networking.

To return to the source code repository topic - most if not all source
code versioning systems do not need a server in order to host a
repository. That is especially true for distributed VCS's such as
Mercurial or Git, where there's no distinction between repository and
working copy: the project you checked out (or rather cloned) on your
local machine is a full-fledged repository just like the one where you
cloned it from, and you don't need a server to use it. Moreover, non-
distributed VCS's such as CVS and SVN are often based on filesystem
access as well, and access through a networked server is provided as a
layer on top of it. So, "repository" does not imply "server" at all,
at least when we're speaking about source code versioning
repositories.

Alessio

-- 
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: Clojure Wiki for general public

2011-07-11 Thread Jonathan Cardoso
I feel the same, although Wikibooks is kind of what you need: 
http://en.wikibooks.org/wiki/Clojure_Programming

-- 
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 to add jar files to leiningen projects?

2011-07-11 Thread Vincent
can lein do 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: How to add jar files to leiningen projects?

2011-07-11 Thread Mark Rathwell
I haven't seen that it can (doesn't mean it can't though ;).  It would seem
to be a natural option for the 'lein install' task, to add a three argument
option: [path-to-jar project-name version], where project-name is the same
as in the two argument version (group-id/artifact-id).

 - Mark

On Mon, Jul 11, 2011 at 1:00 PM, Vincent  wrote:

> can lein do 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
>

-- 
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: jdbc and postgresql type problem

2011-07-11 Thread Brian Carper
On Jul 11, 6:41 am, Aaron Bedra  wrote:
> Silly question, but which version of java.jdbc are you using?  Up until
> 0.0.3 I had no end of troubles with psql because of the batchExecute issue.

I tested Wilfred's code with 0.0.3-SNAPSHOT.

--Brian

-- 
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: a lazy version of shuffle.

2011-07-11 Thread Alan Malloy
If the sequence is already realized, or is cheap, and you want only a
very small random subset of it, you can do better than shuffling the
whole thing. Fliebel and I played around with several solutions to
this, some time ago. I can't find the whole thing, but some
interesting examples and benchmarking data are at https://gist.github.com/805747
if you want to try it out.

On Jul 11, 3:57 am, Tassilo Horn  wrote:
> Sunil S Nandihalli  writes:
>
> Hi Sunil,
>
> >  I think a lazy version of shuffle would be a good addtion to the
> > core. I tried googling for one and found
> >http://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.htmlwhich
> > was infact slower than original shuffle and was unable to reproduce
> > the performance claims made there in.
>
> I think there is no way to implement a "good" lazy version of shuffle.
> Correct shuffling, i.e., the result should be a real pseudo-random
> permutation of all elements, can only be defined on finite seqs anyway.
> And there, one has to realize the given seq.  In the code you cite,
> there's
>
>   (defn lazy-shuffle [lst fetch-len]
>     (let [len (count lst)
>               ^^^
>
> which does exactly that.  So here only the cheap creation of the
> shuffled seq is lazy, but the possibly expensive calculation of the
> given seq is (and has to be done) directly.
>
> 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: How to add jar files to leiningen projects?

2011-07-11 Thread Alan Malloy
Maven will give you this list of instructions if you just add a
dependency to project.clj, and it can't find the required artifact. So
write your project.clj as though your external jars were available to
maven, and then maven will tell you how to make it available. It's the
same as Mark's suggestion, but imo easier to reproduce yourself than
saving a bookmark to Mark's answer.

On Jul 11, 8:29 am, Mark Rathwell  wrote:
> To install the jars to your local maven repository (~/.m2):
>
> mvn install:install-file
>   -Dfile=
>   -DgroupId=
>   -DartifactId=
>   -Dversion=
>   -Dpackaging=
>   -DgeneratePom=true
>
> Where:   the path to the file to load
>              the group that the file should be registered under
>           the artifact name for the file
>               the version of the file
>             the packaging of the file e.g. jar
>
> Then, in your project.clj, specify the groupid/artifact-id and version:
>
> (defproject myproject "1.0.0-SNAPSHOT"
>   :description "FIXME: write description"
>   :dependencies [[org.clojure/clojure "1.2.1"]
>                  [org.clojure/clojure-contrib "1.2.0"]
>                  *[finbeau/special-jar "1.0.0"]*])  ;; or whatever
> group-id/artifact-id and version you specified above
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 11:23 AM, finbeu  wrote:
> > Hello,
>
> > I have some external jar libaries that I need to import in my clojure
> > namespace. As I just started to use leinigen, I don't understand how to add
> > them to my project. Let's say the library resides in c:\temp\jars\mylib.jar
>
> > How do I add this properly to mein leinigen project?
>
> > (defproject myproject "1.0.0-SNAPSHOT"
> >   :description "FIXME: write description"
> >   :dependencies [[org.clojure/clojure "1.2.1"]
> >                  [org.clojure/clojure-contrib "1.2.0"]
> >                  [WHAT TO PUT IN HERE?]])
>
> > I assume I have to put that to .m2 repository but how?
>
> > Thanks.
>
> > - Finn
>
> > --
> > 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 to add jar files to leiningen projects?

2011-07-11 Thread Phil Hagelberg
Mark Rathwell  writes:

> I haven't seen that it can (doesn't mean it can't though ;).  It would
> seem to be a natural option for the 'lein install' task, to add a
> three argument option: [path-to-jar project-name version], where
> project-name is the same as in the two argument version
> (group-id/artifact-id).

I'd be happy to take such a patch, though as Alan has said it's easy
enough to get the equivalent mvn invocation from Leiningen itself.

-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


Reworking :pre condition to add an error message

2011-07-11 Thread Timothy Washington
Note: This message was originally posted by ' Shantanu' on the "*Re: Clojure
for large programs*" thread.

I took a look at  Shantanu's macros, and I like the concept a lot. But I
would prefer something baked into the :pre condition itself. The reason is
that it just removes a layer of indirection. If you dig into '*
clj/clojure/core.clj*', you can see that the 'fn' macro is using 'assert' to
test these conditions. Assert allows error messages to be applied, ie:

   *user => (assert false) *

*user => (assert false "fubar") *



However, (defmacro fn ...) assumes that just the boolean condition is being
passed in, A). But I'd like to have the option to pass in a message B).


*A) *

**

*(def fubar *

*  (fn []*

*{:pre [ (true? false) ] }*

*(println "Hello World")))*

*(fubar)*

*
*

*B) *

   *(def thing *

*  (fn []*

*{:pre [ [(true? false) "A false message"] ] }*

*(println "Hello World")))*

*(thing)*



I reworked the 'fn' macro, only for the :pre condition, as a demonstration (see
here ). The calling semantics don't change
that much. Is there any interest in putting this into core? I'd
use Shantanu's workaround otherwise, or in the interim.

Thanks

Tim Washington
twash...@gmail.com
416.843.9060



On Sun, Jul 3, 2011 at 11:42 AM, Shantanu Kumar wrote:

>
>
> On Jul 3, 7:39 pm, Timothy Washington  wrote:
> > I'm using pre / post assertions quite a bit in a project I'm building.
> And I
> > too would love to see better or custom error messages for each assertion.
>
> That should be possible with a macro. For example, I use this:
>
> https://bitbucket.org/kumarshantanu/clj-miscutil/src/acfb97c662d9/src/main/clj/org/bituf/clj_miscutil.clj#cl-1009
>
> Maybe you need something like this(?):
>
> (defmacro verify-my-arg
>  "Like assert, except for the following differences:
>  1. does not check for *assert* flag
>  2. throws IllegalArgumentException"
>  [err-msg arg]
>  `(if ~arg true
> (throw (IllegalArgumentException. ~err-msg
>
> Then use it thus:
>
> (defn foo [m]
>  {:pre [(verify-my-arg "m must be a map" (map? m))]}
>  (println m))
>
> Regards,
> Shantanu
>
> --
> 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: Reworking :pre condition to add an error message

2011-07-11 Thread Ben Mabey

On 7/11/11 11:40 AM, Timothy Washington wrote:
Note: This message was originally posted by '  Shantanu' on the "*/Re: 
Clojure for large programs/*" thread.


I took a look at  Shantanu's macros, and I like the concept a lot. But 
I would prefer something baked into the :pre condition itself. The 
reason is that it just removes a layer of indirection. If you dig into 
'*clj/clojure/core.clj*', you can see that the 'fn' macro is using 
'assert' to test these conditions. Assert allows error messages to be 
applied, ie:


/user => (assert false) /

/user => (assert false "fubar") /



However, (defmacro fn ...) assumes that just the boolean condition is 
being passed in, A). But I'd like to have the option to pass in a 
message B).



/A) /

/(def fubar /

/  (fn []/

/{:pre [ *(true? false)* ] }/

/(println "Hello World")))/

/(fubar)/

/
/

/B) /

/(def thing /

/  (fn []/

/{:pre [ *[(true? false) "A false message"]* ] }/

/(println "Hello World")))/

/(thing)/



I reworked the 'fn' macro, only for the :pre condition, as a 
demonstration (see here ). The calling 
semantics don't change that much. Is there any interest in putting 
this into core? I'd use Shantanu's workaround otherwise, or in the 
interim.


Thanks

Tim Washington
twash...@gmail.com 
416.843.9060



I'd like to see something like this added as well since I sometimes 
write a comment by conditions to help remind myself of why they are 
present. One comment on the patch that is probably obvious, but if we 
change the API for :pre we would want to update the :post API as well to 
keep them consistent.


-Ben

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

Aw: How to add jar files to leiningen projects?

2011-07-11 Thread finbeu
That was fast. Makes sense. Thanks!

- Finn

-- 
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: Reworking :pre condition to add an error message

2011-07-11 Thread Timothy Washington
Yes, the :post is easily done as well. I just wanted to throw up a quick
proof-of-concept.

Tim


On Mon, Jul 11, 2011 at 1:52 PM, Ben Mabey  wrote:

> **
> On 7/11/11 11:40 AM, Timothy Washington wrote:
>
> Note: This message was originally posted by '  Shantanu' on the "*Re:
> Clojure for large programs*" thread.
>
>  I took a look at   Shantanu's macros, and I like the concept a lot. But I
> would prefer something baked into the :pre condition itself. The reason is
> that it just removes a layer of indirection. If you dig into '*
> clj/clojure/core.clj*', you can see that the 'fn' macro is using 'assert'
> to test these conditions. Assert allows error messages to be applied, ie:
>
>  *user => (assert false) *
>
> *user => (assert false "fubar") *
>
>
>
>  However, (defmacro fn ...) assumes that just the boolean condition is
> being passed in, A). But I'd like to have the option to pass in a message
> B).
>
>
>  *A) *
>
>  *(def fubar *
>
> *  (fn []*
>
> *{:pre [ (true? false) ] }*
>
> *(println "Hello World")))*
>
> *(fubar)*
>
> *
> *
>
> *B) *
>
> *(def thing *
>
> *  (fn []*
>
> *{:pre [ [(true? false) "A false message"] ] }*
>
> *(println "Hello World")))*
>
> *(thing)*
>
>
>
>  I reworked the 'fn' macro, only for the :pre condition, as a
> demonstration (see here ). The calling
> semantics don't change that much. Is there any interest in putting this into
> core? I'd use Shantanu's workaround otherwise, or in the interim.
>
>  Thanks
>
> Tim Washington
> twash...@gmail.com
> 416.843.9060
>
>
> I'd like to see something like this added as well since I sometimes write a
> comment by conditions to help remind myself of why they are present. One
> comment on the patch that is probably obvious, but if we change the API for
> :pre we would want to update the :post API as well to keep them consistent.
>
> -Ben
>
> --
> 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

BDD - Given When Then

2011-07-11 Thread Max Weber
Hi,

I like to write some integration/acceptance tests in Clojure. At the moment
I'm using cuke4duke (cucumber), but I'm not satisfied with it. For my unit
tests I'm already using lazytest. In the acceptance tests I like to apply
the typical Given When Then template (like cucumber do). So are there any
nice alternatives to cucumber/cuke4duke?

I know circumspec , but the
project makes no progress anymore? What is the relationship between
circumspec and lazytest ? How can
acceptance tests be written with lazytest, which follow the Given When Then
template (like 
thiscircumspec
example)?

Best regards

Max

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

Aw: Re: How to add jar files to leiningen projects?

2011-07-11 Thread finbeu
Hi Phil,

leiningen is really great. I haven't used maven before so I was really 
scratching my head. Would be great to have  an option like this so I don't 
have to run mvn on the command line.

Thanks!

- Finn

-- 
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: Reworking :pre condition to add an error message

2011-07-11 Thread Laurent PETIT
If this could integrate with existing efforts put on validation libraries,
plus (optionnally) a way to customize the "rendering" of pre-condition
errors, this could be great :-)

Maybe just inverting things : if the precondition returns falsy, this could
mean that there is no violated precondition. If the precondition returns
truethy, this could be printed.

2011/7/11 Timothy Washington 

> Note: This message was originally posted by ' Shantanu' on the "*Re:
> Clojure for large programs*" thread.
>
> I took a look at  Shantanu's macros, and I like the concept a lot. But I
> would prefer something baked into the :pre condition itself. The reason is
> that it just removes a layer of indirection. If you dig into '*
> clj/clojure/core.clj*', you can see that the 'fn' macro is using 'assert'
> to test these conditions. Assert allows error messages to be applied, ie:
>
> *user => (assert false) *
>
> *user => (assert false "fubar") *
>
>
>
> However, (defmacro fn ...) assumes that just the boolean condition is being
> passed in, A). But I'd like to have the option to pass in a message B).
>
>
> *A) *
>
> **
>
> *(def fubar *
>
> *  (fn []*
>
> *{:pre [ (true? false) ] }*
>
> *(println "Hello World")))*
>
> *(fubar)*
>
> *
> *
>
> *B) *
>
> *(def thing *
>
> *  (fn []*
>
> *{:pre [ [(true? false) "A false message"] ] }*
>
> *(println "Hello World")))*
>
> *(thing)*
>
>
>
> I reworked the 'fn' macro, only for the :pre condition, as a demonstration
> (see here ). The calling semantics don't
> change that much. Is there any interest in putting this into core? I'd
> use Shantanu's workaround otherwise, or in the interim.
>
> Thanks
>
> Tim Washington
> twash...@gmail.com
> 416.843.9060
>
>
>
> On Sun, Jul 3, 2011 at 11:42 AM, Shantanu Kumar 
> wrote:
>
>>
>>
>> On Jul 3, 7:39 pm, Timothy Washington  wrote:
>> > I'm using pre / post assertions quite a bit in a project I'm building.
>> And I
>> > too would love to see better or custom error messages for each
>> assertion.
>>
>> That should be possible with a macro. For example, I use this:
>>
>> https://bitbucket.org/kumarshantanu/clj-miscutil/src/acfb97c662d9/src/main/clj/org/bituf/clj_miscutil.clj#cl-1009
>>
>> Maybe you need something like this(?):
>>
>> (defmacro verify-my-arg
>>  "Like assert, except for the following differences:
>>  1. does not check for *assert* flag
>>  2. throws IllegalArgumentException"
>>  [err-msg arg]
>>  `(if ~arg true
>> (throw (IllegalArgumentException. ~err-msg
>>
>> Then use it thus:
>>
>> (defn foo [m]
>>  {:pre [(verify-my-arg "m must be a map" (map? m))]}
>>  (println m))
>>
>> Regards,
>> Shantanu
>>
>> --
>> 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

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

What's your workflow in IntelliJ IDEA

2011-07-11 Thread finbeu
Hi,

I'm using Jetbrains IntelliJ IDEA Community Edition with La Clojure and 
Leiningen Plug In. I think it is really great, but I have the feeling my 
workflow is not very efficient, it is a mix of invoking command lines (lein 
new myproject), then switching to IDEA, running lein commands from the plug 
in, compile, the running scripts from IDEA directly (Menu -> and  Run), 
sometime I use lein run -m myproject.core to run it. I looks like that I'm 
not sure what to actually use.

So how do you use IDEA with clojure? I think the way I use it is not very 
efficient ...

- Finn

-- 
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: Tree vaadin?

2011-07-11 Thread Antonio Recio
Harsha Sanjeewa has translated the vaadin example of the tree in clojure. 
The source is here . It is very 
useful to begin working with clojure and vaadin. 

This tree example has 2 levels and I would like to have 4 levels. With the 
following code it shows still the 2 levels, although the levels 3 and 4 are 
parented. Why is there no level 3 and 4?

(defn level1 [tree [n1 n2 n3 n4]]
  (.addItem tree n1)
  (if (empty? n2)
(.setChildrenAllowed tree n1 false)
(do
  (reduce
(fn [tree n2]
  (doto tree
(.addItem n2)
(.setParent n2 n1)))
tree n2)
  (.expandItemsRecursively tree n1)
  (if (empty? n3)
(.setChildrenAllowed tree n2 false)
(do
  (reduce
(fn [tree n3]
  (doto tree
(.addItem n3)
(.setParent n3 n2)))
tree n3)
  (.expandItemsRecursively tree n2)
  (if (empty? n4)
(.setChildrenAllowed tree n3 false)
(do (doto tree
  (.addItem n4)
  (.setParent n4 n3)
  (.expandItemsRecursively n3)
  (.setChildrenAllowed n4 false)
  )))
  tree) 

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Ken Wesson
On Mon, Jul 11, 2011 at 11:29 AM, Alessio Stalla
 wrote:
[snip most of another post whose sole purpose seems to be to gainsay
anything I write]
>> "Database" and
>> "DBMS" are used more-or-less synonymously (when "database" isn't used
>> more broadly than ACID/SQL/etc.) and the "S" in "DBMS" stands for
>> "server".
>
> No, it stands for "system"

I've seen it spelled out as "database management server" innumerable times.

>> SQL is to databases/clients as HTTP GET/POST syntax is to
>> web servers/browsers. Etc.
>
> HTTP is defined in terms of network communication, though you could in
> principle make process-local HTTP requests. SQL instead doesn't need
> to know anything at all about networking.

I didn't say "HTTP", I said "HTTP GET/POST syntax". That's carried
over HTTP the way SQL is carried over a DBMS wire protocol.

> So, "repository" does not imply "server" at all,

This is getting silly. "Repository" is a word that brings immediately
to mind typing checkin and checkout commands at a command prompt in
order to work on source code that is stored remotely. And remotely
implies "server".

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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: a lazy version of shuffle.

2011-07-11 Thread Ken Wesson
On Mon, Jul 11, 2011 at 1:13 PM, Alan Malloy  wrote:
> If the sequence is already realized, or is cheap, and you want only a
> very small random subset of it, you can do better than shuffling the
> whole thing. Fliebel and I played around with several solutions to
> this, some time ago. I can't find the whole thing, but some
> interesting examples and benchmarking data are at 
> https://gist.github.com/805747
> if you want to try it out.

Also if the sequence is not "realized" but there's a cheap way to
calculate (nth the-hypothetical-sequence n) just knowing n and not
previous members, there are ways to lazily generate part of a random
permutation:

(take k (distinct (f (rand-int limit

where n ranges from 0 to limit-1, f changes n to (nth
the-hypothetical-sequence n) without realizing (or even creating as a
seq object) the-hypothetical-sequence, and k < limit is the number of
items desired from the head of the shuffled sequence. (take limit
(distinct (f (rand-int limit represents a full random permutation
whose elements can be taken lazily.

The downside is that the (distinct ...) implements a rejection
algorithm, so that we get a uniform random element, then a uniform
random from what's left, then ... and so a uniformly-chosen random
permutation, but at the cost that if you realize most or all of the
permutation and not just the first few elements of a big one it will
slow down tremendously. For instance if limit is 10,000 and you
realize the whole thing it will need 10,000 tries on average before
generating the final element. The (distinct ...) also amounts to
holding onto the head.

So this works well if you want the first few elements of the
permutation, f exists, and you don't want to realize all of
the-hypothetical-sequence. It works terribly if you want the whole
permutation or much of it or f does not exist.

There are obvious ways to speed up distinct in this case and make it
more compact, though, for the special case of sets of nonnegative
integers from a range starting at 0: create a BitSet representing
"have we already generated this?" and keep a running count of
generated elements. This allows creating permutations of (range limit)
more efficiently and without realizing all of the Integer objects at
once, at the cost of having mutable state under the hood. Each
iteration we generate k = (rand-int (- limit cnt)) and then walk the
bitset, incrementing a counter n and decrementing k every time we see
a zero in the bitset at position n. When k hits zero, we flip that bit
of the bitset to 1 and output k; that is the next item in the lazy
sequence. Memory complexity is limit/8 bytes instead of limit*12 bytes
(Integer objects consume 12 bytes of memory each) for a space savings
factor of 72, nearly two whole orders of magnitude, over using
(distinct ...).

However, this seems to work only for shuffling (range limit) ... or,
we can use (map f (bitset-perm-of-range limit)) to get an arbitrary
lazy permutation of the-hypothetical-sequence the same way!

Time complexity is quadratic: we have to walk further and further
along the bitset to generate each element. It still beats the
(distinct ...) rejection algorithm when you (eventually) want most or
all of the permutation, and especially when you want that
two-order-of-magnitude memory savings.

Both algorithms avoid the core shuffle's gamut problem when (factorial
limit) exceeds Integer/MAX_VALUE; as long as limit itself doesn't
exceed that there is no problem.

First stab at an implementation:

(defn bitset-perm-of-range [limit]
  (let [bs (java.util.BitSet. limit)
rem (atom limit)
step (fn step []
   (lazy-seq
 (locking bs
   (if-not (zero? @rem)
 (let [k (rand-int @rem)]
   (loop [i 0 k k]
 (if (.get bs i)
   (recur (inc i) k)
   (if (> k 0)
 (recur (inc i) (dec k))
 (do
   (.set bs i)
   (swap! rem dec)
   (cons i (step)))]
(step)))

It *seems* to work after very minimal testing on short ranges and one
small chunk of a big range:

=> (bitset-perm-of-range 10)
(0 7 4 1 8 6 5 3 2 9)
=> (bitset-perm-of-range 10)
(2 8 1 5 0 3 9 4 7 6)
=> (bitset-perm-of-range 10)
(5 9 2 1 4 3 7 6 8 0)
=> (take 10 (bitset-perm-of-range 100))
(113738 532538 423561 100835 157218 710244 339727 507963 199228 842555)

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

Re: jdbc and postgresql type problem

2011-07-11 Thread Wilfred
On Jul 11, 7:48 am, Brian Carper  wrote:
> On Jul 10, 4:52 pm, Wilfred  wrote:
>
> > I'm at a bit of a loss. "UPDATE comments SET approved='1' WHERE id =
> > '1'" works fine in psql. approved is a boolean field, so is this an
> > issue with the SQL library producing incorrect SQL?
>
> I think this is an oddity with the JDBC driver for PostgreSQL.  The
> driver doesn't seem to like doing automatic typecasting.  Try this:
>
> (sql/update-values :comments
>                    ["id = cast(? as integer)" id]
>                    ;; alternatively "id = ?::integer"
>                    {:approved true})
>
> Or you could (Integer/parseInt id) to do the cast before you pass it
> as parameter, though in either case you should validate your id before
> casting, if you want to avoid dying on poorly-formed input.
>
> --Brian

Perfect, many 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


Results from 2011 State of Clojure survey

2011-07-11 Thread Chas Emerick
"A few weeks ago, I opened the 2011 State of Clojure survey.  As with last 
year’s survey, my aim was to take a snapshot of the Clojure community — our 
origins in aggregate, how and where we are using Clojure, and what needs to 
improve to help the community grow and prosper."

The results are in:

http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/

Cheers,

- Chas

-- 
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: Results from 2011 State of Clojure survey

2011-07-11 Thread Timothy Washington
Great work Chas. Although I didn't take the survey, I'm one of those
programmers coming from Java. Now I'm trying to transition to full-time
Clojure work, usually telling everyone I know to take a look at it.

Tim


On Mon, Jul 11, 2011 at 5:22 PM, Chas Emerick  wrote:

> "A few weeks ago, I opened the 2011 State of Clojure survey.  As with last
> year’s survey, my aim was to take a snapshot of the Clojure community — our
> origins in aggregate, how and where we are using Clojure, and what needs to
> improve to help the community grow and prosper."
>
> The results are in:
>
> http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
>
> Cheers,
>
> - Chas
>
> --
> 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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Asim Jalis
On Tue, Jul 5, 2011 at 6:35 AM, Stephen C. Gilardi  wrote:
> I would argue that the ~/.m2 repository is nearly as easy to work with as any 
> other local, on-disk scheme one might envision and has the benefit of working 
> with any maven-compatible tool.
>
> It also works for arbitrary jars one may have on disk (acquired from any 
> source) via:
>
>  http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Thanks. I had the same issue using some generated jar files and this
worked. Here are the concrete commands I used to install the jars into
m2. Posting it here in case someone else finds it useful.

mvn install:install-file \
-DgroupId=com.sforce.soap \
-DartifactId=partner \
-Dversion=22 \
-Dfile=partner.jar \
-Dpackaging=jar \
-DgeneratePom=true

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


Using Clojure To Debug Java Apps

2011-07-11 Thread Asim Jalis
I have been using the Clojure REPL to debug a large Java server app.
It's great for exploratory testing and for validating assumptions
about how the system works. I wanted to post the code here in case
someone else finds this useful.

1. Stick this in a class that is loaded early in the server/app.

public static class Repl {
public static final String PORT = "18081";
public static final String NS = "user";

private final String initResult; public String getInitResult() {
return initResult; }

public Object invoke(String fn) { try { return
clojure.lang.RT.var(NS, fn).invoke(); } catch (Exception e) { return
null; } }
public Object invoke(String fn, Object arg1) { try { return
clojure.lang.RT.var(NS, fn).invoke(arg1); } catch (Exception e) {
return null; } }
public Object invoke(String fn, Object arg1, Object arg2) { try {
return clojure.lang.RT.var(NS, fn).invoke(arg1, arg2); } catch
(Exception e) { return null; } }
public Object invoke(String fn, Object arg1, Object arg2, Object
arg3) { try { return clojure.lang.RT.var(NS, fn).invoke(arg1, arg2,
arg3); } catch (Exception e) { return null; } }

public Repl() {
String result;
try {
clojure.lang.Var eval = clojure.lang.RT.var("clojure.core", "eval");
clojure.lang.Var read =
clojure.lang.RT.var("clojure.core", "read-string");
String create_repl_server =
  "(do " +
"(use '[clojure.contrib.server-socket :only
[create-repl-server]])" +
"(create-repl-server " + PORT + ")" + ")";
result = eval.invoke(read.invoke(create_repl_server)).toString();
} catch (Exception e) {
result = e.toString();
}
initResult = result;
}
}
public static final Repl REPL = new Repl();

2. Use this on the command line to start the REPL:

rlwrap --logfile $HOME/tmp/clj.log telnet localhost 18081

Now from the REPL you can create Java objects and call methods at will.

3. To call a Clojure function called some-function in "user" namespace
from Java, use something like this:

REPL.invoke("some-function", "arg1"));

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Mike Meyer
On Mon, 11 Jul 2011 07:51:33 -0400
Ken Wesson  wrote:

> On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com  
> wrote:
> [snip most of post whose sole purpose seems to be to gainsay anything I write]

Because in that article, you were (unusual for you) way off base.

> > The only source control system I know that uses an ACID database doesn't
> > need a back end server.
> 
> How exactly is this possible? Databases *are* servers. "Database" and
> "DBMS" are used more-or-less synonymously (when "database" isn't used
> more broadly than ACID/SQL/etc.) and the "S" in "DBMS" stands for
> "server". SQL is to databases/clients as HTTP GET/POST syntax is to
> web servers/browsers. Etc.

I explained it in the part you snipped, but I'll repeat it for you: it
uses an embedded database. A database is *not* a server, it's an
API. The API may well talk to a server - and most do - but there's no
requirement that it do so. This particular embedded database is almost
certainly the most popular SQL database in the world, with hundreds of
millions of installations running worldwide.

SQL doesn't have a position anything like HTTP GET/POST syntax. HTTP's
GET/POST syntax is a wire protocol. Once you it, you can write code to
talk to a server, and get a response. If you know SQL, you can't use a
database *at all*. You have to know an API for the database in
question - and if it's a server, have an implementation that talks
it's wire protocol. ODBC provides a standard API, but not a wire
protocol. Last time I looked, there wasn't a standard wire protocol
for SQL servers.

  http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 to add jar files to leiningen projects?

2011-07-11 Thread Shantanu Kumar
I have seen this local JAR thing coming up far too often, so I sat
down and wrote this:

https://github.com/kumarshantanu/lein-localrepo

Can somebody try this and let me know if it works?

Regards,
Shantanu

On Jul 11, 11:35 pm, finbeu  wrote:
> Hi Phil,
>
> leiningen is really great. I haven't used maven before so I was really
> scratching my head. Would be great to have  an option like this so I don't
> have to run mvn on the command line.
>
> Thanks!
>
> - Finn

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Mike Meyer
On Mon, 11 Jul 2011 16:21:45 -0400
Ken Wesson  wrote:
> > So, "repository" does not imply "server" at all,
> This is getting silly. "Repository" is a word that brings immediately
> to mind typing checkin and checkout commands at a command prompt in
> order to work on source code that is stored remotely. And remotely
> implies "server".

I was with you until you said "stored remotely". These days, I almost
*never* do checkins or checkouts to a remote server - and I use four
different source control systems on a regular basis: (hg, git, fossil
& perforce). The first three *cannot* do remote checkins or checkouts
- they require the repository be stored on the local disk. The last
one is the only one that behaves the way you describe - and it's a
legacy system I'm trying to get rid of.

 http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Shantanu Kumar


On Jul 12, 4:24 am, Asim Jalis  wrote:
> On Tue, Jul 5, 2011 at 6:35 AM, Stephen C. Gilardi  wrote:
>
> > I would argue that the ~/.m2 repository is nearly as easy to work with as 
> > any other local, on-disk scheme one might envision and has the benefit of 
> > working with any maven-compatible tool.
>
> > It also works for arbitrary jars one may have on disk (acquired from any 
> > source) via:
>
> >  http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
>
> Thanks. I had the same issue using some generated jar files and this
> worked. Here are the concrete commands I used to install the jars into
> m2. Posting it here in case someone else finds it useful.
>
> mvn install:install-file \
>     -DgroupId=com.sforce.soap \
>     -DartifactId=partner \
>     -Dversion=22 \
>     -Dfile=partner.jar \
>     -Dpackaging=jar \
>     -DgeneratePom=true

I have posted about it on another thread too. Maybe you can give this
a try (with Leiningen):

https://github.com/kumarshantanu/lein-localrepo

Regards,
Shantanu

-- 
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: Results from 2011 State of Clojure survey

2011-07-11 Thread Ken Wesson
Nice analysis. A few remarks:

* The results seem to confirm the arguments here that there's a
problem with documentation and with the lack of a good "starter kit".
Making the command line REPL better might help in that regard too (tab
completion would not even be too difficult, given Clojure's
introspective capabilities; just prefix-matching against (map name
(keys (ns-map *ns*))) should do a decent job.

* Lisp is “oatmeal with fingernail clippings mixed in”? Who said that?
WHAT?! LARRY $*@! WALL said it?! Well HE's hardly one to complain
about Lisp's alleged readability deficits! :)

* It would be nice to be able to see superpositions of last year's and
this year's graphs somewhere, so the changes are made directly
apprehensible to the eye, where applicable (same questions asked in
both years).

* How would you characterize your use of Clojure *today* -- you do
know that HTML supports true italics, right? :)

* What is the status of Clojure in your workplace -- the numbers sum
to exactly 100, suggesting you made the options mutually exclusive.
But the middle item potentially could have overlap with the ones
directly above and directly below it and there are no "I don't know"
or "N/A" type options showing in the output data.

* Public relations -- Project status and activity. This area seems to
suggest the main Clojure page should be covered in tickers and feeds
of various kinds, but I'm not so sure about that. A lot of that stuff
would be just so much clutter to a lot of users -- and others might
find it *intimidating*: "What the heck *is* all of this stuff? Am I
expected to understand *all* of it before I can do anything useful
with this thing?". Google gets by with a very spare main page -- no,
in fact it's one of Google's major plus points. So there's certainly
no rule that says "success requires a cluttered main web page". My own
ISP's main web page is a huge mess of stuff mostly irrelevant to why a
customer would go to it -- random news tickers and other "portally"
stuff that has nothing to do with Internet service status, checking
your billing/usage/account setup, forwarding email while away, and the
like, and finding the latter is a pain. There's also what's been said
here about too many different possible "starter kit" configurations
mentioned, like emacs+SLIME, Enclojure+NetBeans, Eclipse+CCW... --
wouldn't that apply more generally to any large globs of stuff on the
front page? I'd suggest showing signs of activity in two main ways:
one, list the five most recent posts of some developer blog that gets
a new article every so often and two, possibly list the most recent
few threads to get new posts in this mailing list and link to them at
Google. And of course update the boilerplate cruft like the date on
the page regularly -- but a script can do that automatically, or even
dynamically generate the page with today's date. It's phony but it is
probably effective and doesn't add clutter, and adding the two feeds I
suggested doesn't add much and points people at this list and at
current developer activity. A few more things maybe wouldn't hurt
either, e.g. a Featured Library or Tip of the Week or some such,
changed weekly. The developer blog, if adopted, should include at
least two categories of items: development milestones achieved
(particularly, decisions made, things implemented, and releases) and
significant uptake events (this company/product/web service disclosed
using Clojure, Heroku started supporting Clojure, etc.).

"... so that people who wander into clojure.org can immediately have a
positive impression, rather than requiring of them an analytical
comprehension of Clojure’s minutiae?"

An argument could be made that Clojure is aimed more at those who do
that sort of "analytical comprehension" than those looking for the
latest jazzy fad, but an argument could also be made that attracting a
broader base is good and "jazzy fad" is a straw-man argument. :)


-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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: Results from 2011 State of Clojure survey

2011-07-11 Thread Phil Hagelberg
Ken Wesson  writes:

> * How would you characterize your use of Clojure *today* -- you do
> know that HTML supports true italics, right? :)

Obviously *today* is meant to be rebound to a new value in the future.

-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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Ken Wesson
On Mon, Jul 11, 2011 at 7:39 PM, Mike Meyer  wrote:
> On Mon, 11 Jul 2011 07:51:33 -0400
> Ken Wesson  wrote:
>
>> On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com  
>> wrote:
>> [snip most of post whose sole purpose seems to be to gainsay anything I 
>> write]
>
> Because in that article, you were (unusual for you) way off base.

As you say, it would be unusual for me if that were the case -- good
reason to suspect that perhaps I wasn't, but rather was
misinterpreted, or something.

> SQL doesn't have a position anything like HTTP GET/POST syntax.

Sure it does. Queries are bundled into a wire protocol and sent over
the network in pretty much every system I've seen that used a
database. You have the web server over *here*, and it is visible to
the internet because the gateway forwards port 80 to it *here*; it
talks over the LAN to the DBMS over *here* to run various queries and
build a page to serve ...

> HTTP's GET/POST syntax is a wire protocol.

HTTP is a wire protocol. The syntax of GET/POST requests is carried on
that protocol (as are HTML files and other files sent back to the
client) but is not the protocol itself.

> Once you it, you can write code to talk to a server, and get a
> response.

Not if all you know is "GET /index.html". You need to speak HTTP and
then send that.

> If you know SQL, you can't use a database *at all*. You have
> to know an API for the database in question

Just as you need to know HTTP and not just "GET /index.html". The
difference here is that the databases haven't all settled on one
embedding, analogous to HTTP, for the SQL requests, but all the
vendors use their own different one.

> Last time I looked, there wasn't a standard wire protocol
> for SQL servers.

Which doesn't change much of anything. There's HTTP 1.0 and HTTP 1.1
for web servers for that matter, though mostly you can ignore the
differences and, indeed, these days HTTP 1.0 as a whole. It's not hard
to imagine a world where a non-HTTP protocol became a rival to HTTP,
either -- for instance, one with built-in support for mirroring of
static content instead of having to fudge around with things like
Akamai for that, perhaps even one where individual browsers made parts
of their caches (not https stuff, though, obviously, or form contents)
available automatically as alternative sources to take some of the
load off central servers and possibly even maintain some availability
when they were down. If that were to happen, would the things that
interpret GET requests suddenly stop qualifying for being considered
to be "servers"?

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Ken Wesson
On Mon, Jul 11, 2011 at 7:51 PM, Mike Meyer  wrote:
> On Mon, 11 Jul 2011 16:21:45 -0400
> Ken Wesson  wrote:
>> > So, "repository" does not imply "server" at all,
>> This is getting silly. "Repository" is a word that brings immediately
>> to mind typing checkin and checkout commands at a command prompt in
>> order to work on source code that is stored remotely. And remotely
>> implies "server".
>
> I was with you until you said "stored remotely".

Well, the source code is being worked on collaboratively by
geographically separated people in many cases, and from multiple
office cubicle computers in the most geographically-concentrated case.
The canonical master version of the source code must reside in some
single place, which can be at most one of those developers' computers;
so for the rest of them, it's stored remotely.

What's stored locally may range from a single file being worked on at
a time to a copy of the whole code base, but there is still generally
a master copy and there is still therefore some mechanism for updating
the master copy and resolving edit conflicts that collide there.

That mechanism requires the computer holding the non-master copy or
single file to push its diffs to the computer holding the master copy
(and then the latter is a server) or the computer holding the master
copy to pull diffs from the others (and then all the REST are
servers!).

So not only is there a "stored remotely" in there out of necessity for
anything but a single-developer-on-a-single-machine project, but
there's also a "server" in there, or even multiple servers. The
alternatives I can think of are:

1. One developer, one computer. Version control may be overkill in
such a case anyway and it's not how big, major projects are developed.

2. Many developers, one computer. No "remote storage" and if the
developers are co-located no server; otherwise a terminal server. The
former is obviously not parallelizable (though edit conflicts are thus
a non-issue -- single global lock FTW!!!1!1) and the latter is a
throwback to the 1980s or earlier. :)

3. Many computers, one developer manually synching files or just
carrying the codebase around on a thumbdrive. No servers, no remote
storage that isn't simply overwritten when returned-to. The extra
copies, if any, merely amount to backups. Most likely with a
one-developer project with a tower and a laptop, or developing a phone
app on a computer and on their phone.

4. An ad hoc, peer-to-peer system with many evolving versions of the
codebase and patches swapped back and forth but no canonical "master"
copy. This *might* be workable on a small project (a handful of
developers, not too many LOC) but surely cannot scale much above that
without becoming total chaos. There might be no "server" beyond email
in such a case, used for exchanging diff files or whatever. But I
expect any project organized that way to melt down above a fairly
small size of codebase and/or developer headcount. Versions will
become too divergent, the bigger and more numerous they are, until
patches that worked on the sender's copy often won't work, or won't
work without extensive modification, on the recipient's, and then the
ability to share improvements begins to break down rapidly when that
point is reached. In effect, the codebases begin to evolve into
separate species that can no longer interbreed. Perhaps this is how
bacteria, despite being able to share genes in horizontal transfer and
acquire them after birth, nonetheless have distinct species -- they
become incompatible for all but certain broad classes of "plugin
interface implementation" patches such as, unfortunately,
antibiotic-resistance genes.

This could be made slightly more scalable by modularizing, specifying
module interfaces, and letting the modules evolve separately,
versioning each one by patch level, so the version of a module is
bumped every time it's patched. Patches expected to be acquired and
applied in order to keep each module up to date with everyone else's
work. Obvious problem with patch-numbering collisions, where two
developers hack on module Y and both produce distinct patch 1337s
unaware of what the other is doing -- in other words, edit conflicts.
Repositories that number every commit sort-of implement this, but with
a master copy and a database of some sort tracking the changes and the
commit numbers and some mechanism for resolving edit collisions.
Collisions are also detected right away, since both developers will
submit their changes to the central repository. In the peer-to-peer
model each might deliver their own "patch 1337" to a bunch of others
and both could spread for a while among different subsets of the
developers before eventually colliding in one developer's copy of
module Y who receives one of the patches and then, later, the other.
Before that, problems could arise if developer X talks to developer Z
and gets patch 1338 for module Y, tries to apply it, and despite
having patch 1337 it doesn't wo

Re: Results from 2011 State of Clojure survey

2011-07-11 Thread Ken Wesson
On Mon, Jul 11, 2011 at 8:40 PM, Phil Hagelberg  wrote:
> Ken Wesson  writes:
>
>> * How would you characterize your use of Clojure *today* -- you do
>> know that HTML supports true italics, right? :)
>
> Obviously *today* is meant to be rebound to a new value in the future.

ROFL...

(doto
  (Thread.
#(loop []
   (Thread/sleep 8640)
   (set! *today* (Date.))
   (recur)))
  (.start))?

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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 to add jar files to leiningen projects?

2011-07-11 Thread Phil Hagelberg
Shantanu Kumar  writes:

> I have seen this local JAR thing coming up far too often, so I sat
> down and wrote this:
>
> https://github.com/kumarshantanu/lein-localrepo
>
> Can somebody try this and let me know if it works?

Did some simple tests on it and it looks like it works fine.

Thanks for putting this together! Very nicely done.

-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: How to add jar files to leiningen projects?

2011-07-11 Thread Mark Rathwell
It works for me on OS X (at least install does), however, it requires you to
be in a project directory to use.  Not really an inconvenience, but it may
not be completely obvious to a user installing with the intention of using
the dependency in multiple projects that they won't need to repeat this in
each project directory.

It would be ideal if it could be run outside of the project structure, as
would be the case if an additional arity was added to the install function
in leiningen.install.

 - Mark

On Mon, Jul 11, 2011 at 7:41 PM, Shantanu Kumar wrote:

> I have seen this local JAR thing coming up far too often, so I sat
> down and wrote this:
>
> https://github.com/kumarshantanu/lein-localrepo
>
> Can somebody try this and let me know if it works?
>
> Regards,
> Shantanu
>
> On Jul 11, 11:35 pm, finbeu  wrote:
> > Hi Phil,
> >
> > leiningen is really great. I haven't used maven before so I was really
> > scratching my head. Would be great to have  an option like this so I
> don't
> > have to run mvn on the command line.
> >
> > Thanks!
> >
> > - Finn
>
> --
> 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 to add jar files to leiningen projects?

2011-07-11 Thread Tarantoga
You can copy your jars in the /lib directory and add the
":disable-implicit-clean true" option to your project.clj file.
Leiningen will not delete your jars while building the project.

On Jul 11, 6:23 pm, finbeu  wrote:
> Hello,
>
> I have some external jar libaries that I need to import in my clojure
> namespace. As I just started to use leinigen, I don't understand how to add
> them to my project. Let's say the library resides in c:\temp\jars\mylib.jar
>
> How do I add this properly to mein leinigen project?
>
> (defproject myproject "1.0.0-SNAPSHOT"
>   :description "FIXME: write description"
>   :dependencies [[org.clojure/clojure "1.2.1"]
>                  [org.clojure/clojure-contrib "1.2.0"]
>                  [WHAT TO PUT IN HERE?]])
>
> I assume I have to put that to .m2 repository but how?
>
> Thanks.
>
> - Finn

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


Ring+Swank

2011-07-11 Thread Tarantoga
Hi all,
I'd like to make a web-app to which I could connect using slime and
make some changes there while the application is still running. How to
start Swank-server from the working Ring-application?

-- 
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: Results from 2011 State of Clojure survey

2011-07-11 Thread Meikel Brandmeyer
Hi,

Am Dienstag, 12. Juli 2011 02:36:34 UTC+2 schrieb Ken Wesson:

> An argument could be made that Clojure is aimed more at those who do
> that sort of "analytical comprehension" than those looking for the
> latest jazzy fad, but an argument could also be made that attracting a
> broader base is good and "jazzy fad" is a straw-man argument. :)
>

Maybe clojure is not directly aimed at those "analytical guys", but simply 
made by one. So Rich maybe just doesn't see a problem?

Sincerely
Meikel
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new 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