Re: ANN: VimClojure v2.1.2 released

2009-08-16 Thread ogcraft

Thanks. It looks very impressive.
I'm using the VIM for all my development.
But could you point me to a clear/understandable explanation how to
use VimClojure. I found how to install and configure it but have no
idea how to start using.

On Jul 26, 12:09 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Dear vimming Clojurians,

 I'd like to announce a bugfix release for VimClojure.
 This release is compatible with Clojure 1.0 and
 Clojure-Contrib 919 (in old SVN terms). Other
 pre-GTIC contrib versions from Github should also
 work. For Clojure(-Contrib) head consider using the
 bleeding-edge branch from the repository.

 The Ivy configuration will fetch an known-to-work
 Clojure(-Contrib) version. For manual compilation,
 you have to care for that yourself. A compiled jar
 is already included in the distribution in the build
 subdirectory.

 Changes since v2.1.1:

 * Fixed a regression of qualified keywords highlighting
 * Fixed a infinite loop if there is no prompt in the Repl buffer
 * Made compilation of ng client a bit more comfortable
 * Added library configuration for OpenSolaris (thanks to Richard Newman)
 * Changed normal invokations to ignore keymappings (reported by James  
 Reeves)
 * Fixed typo in lispwords: defmethod - defmulti
 * Added letfn to lispwords
 * Added c.c.def/defnk to lispwords
 * Added #_ and #! as comment indicators to syntax highlighting
    (currently only the #_ is marked as comment, the following form
    is still highlighted normally.)
 * Fixed annoying o/O delay bug
 * Simplified plugin installation

 The release can be found at the usual places:
    http://kotka.de/projects/clojure/vimclojure.html
    http://bitbucket.org/kotarak/vimclojure
    http://www.vim.org/scripts/script.php?script_id=2501

 Sincerely
 Meikel

  smime.p7s
 2KViewDownload
--~--~-~--~~~---~--~~
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-maven-plugin example project now available

2009-08-16 Thread Mark Derricutt
Hey all,

I just pushed out a very simple example project showing up to use my
maven-clojure-plugin:

  http://github.com/talios/clojure-maven-example/tree/master

In the repository there's 3 tags:

step1 has a very simple pom.xml and a single clojure test script. Simply run
mvn test to see it run.

step2 pulls in the compojure repository and has a simple web app. run
git-submodules init to pull in the submodule, then mvn clojure:run to
launch the server (using the run.clj script mentioned in the pom.xml).

step3 has an automated test for compojure, pulling in the
clojure-http-client framework, rerun git-submodules init then mvn test
and you should see the server start up, a test run, then the server stop.

The example project also shows off some new features of the plugin, namely:

  * automated discovery of namespaces to compile
  * namespace exclusion

Now to sort out a repository to publish a released version of the plugin
(maybe not under the org.clojure groupId as it currently sits thou, unless
no one takes issue with that (and I sign a contribution form I guess).

Mark

-- 
Discouragement is a dissatisfaction with the past, a distaste for the
present, and a distrust of the future
- Maree De Jong, Life NZ.

blog: http://www.talios.com
podcast: http://www.illegalargument.com
skype / twitter: talios
Sent from Auckland, Auk, New Zealand

--~--~-~--~~~---~--~~
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 the appropriate way to process inner nested list (or vector) in clojure?

2009-08-16 Thread botgerry

Hello,all

new to functional programming, I have one nested dynamic vecter just
like this:

(def a [[1 2 3 4] [ok 89 22] [25 78 99] ...]]

it has to support ops:
1*   add new item,it's easy: eg. (conj   a  [metoo oops] )
2*  insert one element  into inner vector based that vector's
content,eg  i have to append 50 in inner vectors which includes 99.
the result  is [[1 2 3 4] [ok 89 22] [25 78 99 50]...]
3*  merge inner vectors in a , eg. if there are same elements in
inner vectors , they should be merged and delete same elements.
 [[1 2 3 4] [ ok 89 22] [ 5 6 7 2 ]...] - [[1 2 3 4 5 6 7] [ok 89
22]]


to 2,  i use zipper :
(defn append-to-blocks [x y] ;lookup x in blocks,if found then add y
to that inner block
   (loop [loc dz];dz is zip/vector-zip blocks
 (if (zip/end? loc)
   (zip/root loc)
   (recur
(zip/next
 (if (and (vector? (zip/node loc)) (includes? (zip/node loc) x))
   (let [new-coll (conj (zip/node loc) y)]
   (zip/replace loc new-coll))
   loc))
though work, but it should have better solution.

to 3, i have not figure out one good way  to do it.

any libs could help me, or any ideas?

--~--~-~--~~~---~--~~
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 the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread botgerry

Hello,all

I'm new to functional programming,want to know how to address nested
inner seqs in clojure

(def a [[1 2 3 4] [ ok metoo] [ 5 8 9 ]])

1:  searching in a, if find one inner vector includes number 9 then
append it a number 13
 [[1 2 3 4] [ ok metoo] [ 5 8 9 ]]  = [[1 2 3 4] [ ok metoo]
[ 5 8 9 13]]

2: searching in a, if found two or many inner vectors include same
element the merge them as one inner vector
others not touch

(def b ( conj  a  [ 5  10 oops]))  = [[1 2 3 4] [ok metoo] [5 8
9] [5 10 oops]]
in b, [5 8 9] and [5 10 oops] both include 5, it should be merge to
[5 8 9 10 oops] :
[[1 2 3 4] [ok metoo] [5 8 9] [5 10 oops]]  = [[1 2 3 4] [ok
metoo] [5 8 9 10 oops]]


I only found one solution to question 1 using zipper :
(def dz (zip/vector-zip a))
(defn append-to-blocks [x y] ;lookup x in blocks,if found then add y
to inner block
   (loop [loc dz];dz is blocks
 (if (zip/end? loc)
   (zip/root loc)
   (recur
(zip/next
 (if (and (vector? (zip/node loc)) (includes? (zip/node loc) x))
   (let [new-coll (conj (zip/node loc) y)]
   (zip/replace loc new-coll))
   loc))

user= (append-to-blocks 9 13)
[[1 2 3 4] [ok metoo] [5 8 9 13]]

but still not figure out one way to question 2, i have tried:
(defn merge-inner-blocks [x blocks] ;x is element maybe in many inner
blocks
  (let [with-out-x (for [b blocks :when (not (includes? b x))] b)
with-x (for [b blocks :when (includes? b x)] b)]
(def blocks (concat with-out-x (vector (flatten with-x))   ;
just merge them, not remove the same element

(merge-inner-blocks 5 b)
#'user/blocks
user= blocks
([1 2 3 4] [ok metoo] (5 8 9 5 10 oops))  ; here how to remove
one of the 5?  vector has changed to list?

3, I also found my solutions to this alike problems are not
concise,and a bit ugly, any libs or appropriate way to process inner
nested seqs in clojure? i thought those ops maybe frequently
encountered in practical programming

any ideas?

best regards
 bot

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: what's the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread Jarkko Oranen

On Aug 16, 12:02 pm, botgerry botge...@gmail.com wrote:
 Hello,all

 I'm new to functional programming,want to know how to address nested
 inner seqs in clojure

 (def a [[1 2 3 4] [ ok metoo] [ 5 8 9 ]])

 1:  searching in a, if find one inner vector includes number 9 then
 append it a number 13
  [[1 2 3 4] [ ok metoo] [ 5 8 9 ]]  = [[1 2 3 4] [ ok metoo]
 [ 5 8 9 13]]

 2: searching in a, if found two or many inner vectors include same
 element the merge them as one inner vector
 others not touch

 (def b ( conj  a  [ 5  10 oops]))  = [[1 2 3 4] [ok metoo] [5 8
 9] [5 10 oops]]
 in b, [5 8 9] and [5 10 oops] both include 5, it should be merge to
 [5 8 9 10 oops] :
 [[1 2 3 4] [ok metoo] [5 8 9] [5 10 oops]]  = [[1 2 3 4] [ok
 metoo] [5 8 9 10 oops]]

 I only found one solution to question 1 using zipper :
 (def dz (zip/vector-zip a))
 (defn append-to-blocks [x y] ;lookup x in blocks,if found then add y
 to inner block
    (loop [loc dz]            ;dz is blocks
      (if (zip/end? loc)
        (zip/root loc)
        (recur
         (zip/next
          (if (and (vector? (zip/node loc)) (includes? (zip/node loc) x))
            (let [new-coll (conj (zip/node loc) y)]
            (zip/replace loc new-coll))
            loc))

 user= (append-to-blocks 9 13)
 [[1 2 3 4] [ok metoo] [5 8 9 13]]

I think using a zipper is a good solution

 but still not figure out one way to question 2, i have tried:
 (defn merge-inner-blocks [x blocks] ;x is element maybe in many inner
 blocks
   (let [with-out-x (for [b blocks :when (not (includes? b x))] b)
         with-x (for [b blocks :when (includes? b x)] b)]
     (def blocks (concat with-out-x (vector (flatten with-x))   ;
 just merge them, not remove the same element

You should never use def inside a function. It's a certain sign that
you're doing something wrong. Why don't you just return the result
normally?

That said, I can't think of a fast solution for this either; but you
can wrap the (concat ...) in (vec (set ...)) to get a vector of
uniques.

 (merge-inner-blocks 5 b)
 #'user/blocks
 user= blocks
 ([1 2 3 4] [ok metoo] (5 8 9 5 10 oops))  ; here how to remove
 one of the 5?  vector has changed to list?

 3, I also found my solutions to this alike problems are not
 concise,and a bit ugly, any libs or appropriate way to process inner
 nested seqs in clojure? i thought those ops maybe frequently
 encountered in practical programming

I have to say I haven't had the need to do much with nested seqs, but
I suppose for that purpose clojure.zip would be worth learning more in
depth. It is designed for traversing and editing data structures,
after all.

--
Jarkko
--~--~-~--~~~---~--~~
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: Pure-functional N-body benchmark implementation

2009-08-16 Thread Nicolas Oury

Dear all,


The good news: I have a version of the N-body benchmark that goes as
fast as java.

The bad news: I am cheating a little bit...

As I suspected that a lot of time was spend in the array bound check
arithmetic, I replaced #^doubles in the implementation of body by an
object implemented in Java. (That's where I cheated).
I just created a Body struct with 7 public double fields.

This resulted in a x 2.3 speed-up from the last version.

Then replacing persistent vectors for bodies by Java array gives another
15% speed increase.

Then using my own Java written function to have a more specific
signature to array access gave another 15%. (This means that type cast
seems to have a cost in a very tight loop)

Starting with a program running in 66 sec, I have now a program running
in 17 sec (for 5. 10^7 iterations)
I have not ran the java program but as the 66 sec one was 3.2 times
slower than the Java one, I think the goal is reached.

But we had to cheat.
I think the most crucial point is that there is no way in Clojure to
implement structures with the same performance characteristics than
native java structures. (In this kind of loop, it speed up by 2-2.5
times the program to use such a java object.)

I think I read an article about an array bound check elimination for
jre7 that would get read of a big part of the cost. But having to encode
structures as arrays to have primitive fields is not very idiomatic
anyway.

So to sum up how to have micro-benchmarks as fast as java:
- manual inlining. There seems to have a cost to calling a function.
Maybe the new code generator will improve that. 
- possibility to have native structures. As for now that means writing
small java files. Maybe the new new will improve that. I also read
someone has a gen-struct macro. (biggest factor)
- the right set of options for the JVM. (Escape analysis, biased
locking, AggressiveOpts)
- possibility of having array access similar to those for primitives for
any type. (Less important than the other.)

I think it may be reassuring for people starting a project using Clojure
to know that once they find a bottleneck in a program they can rewrite
it to go at the same speed as the java program doing the same thing.

That's not a programming style I would advocate for a whole project
though. 

Best regards,

Nicolas.
 

On Wed, 2009-08-12 at 00:26 -0400, Aaron Cohen wrote: 
 On Tue, Aug 11, 2009 at 8:13 PM, Andy
 Fingerhutandy_finger...@alum.wustl.edu wrote:
 
  On Aug 11, 2:36 pm, Aaron Cohen remled...@gmail.com wrote:
  At that point is it possible you're just paying the price of
  PersistentVector for the bodies vector?  Does it improve much if you
  change bodies to an array?
 
  About 7% faster changing bodies to a Java array of java.lang.Object's,
  each of which happens to be a Java array of primitive doubles, as
  before.  Now about 3.0 x Java run time.
 
  http://github.com/jafingerhut/clojure-benchmarks/blob/43ed2f42e6c1485541532e51eacc66488949c658/RESULTS
 
 
 I'm actually glad that the difference is that small there.
 
  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: what's the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread botgerry



On 8月16日, 下午6时29分, Jarkko Oranen chous...@gmail.com wrote:

 I think using a zipper is a good solution
but clojure.zip seems only support limit operates,i want it support 
mark and merge  functions

You should never use def inside a function. It's a certain sign that
you're doing something wrong. Why don't you just return the result
 normally?
 i want to update global var without using ref stuff :)

 That said, I can't think of a fast solution for this either; but you
 can wrap the (concat ...) in (vec (set ...)) to get a vector of
 uniques.

it works, but specially ugly :)

 I have to say I haven't had the need to do much with nested seqs, but
 I suppose for that purpose clojure.zip would be worth learning more in
 depth. It is designed for traversing and editing data structures,
 after all.

 --
sure,clojure.zip is great tool .


bot
--~--~-~--~~~---~--~~
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: Is there something special about haskell, or could verifiability announcements happen for purely functional Clojure programs too?

2009-08-16 Thread Daniel

On Sun, Aug 16, 2009 at 6:51 AM, Niels Mayernielsma...@gmail.com wrote:
 Executive summary: seems like big announcements of provably correct
 software would be easier to achieve in Java+Clojure than for C/Haskell used
 in the current big news regarding a provably secure kernel. However, given
 the bugs I enountered in a java-based DVR contract-from-hell that was a
 deadlocking side-effecting nightmare, I think this kind of provability
 work would be very useful for real world java and clojure running in
 embedded java whether it be a DVR glitching-out due to an improbable
 concurrence, or hospital life-support equipment, or aircraft control,
 military control, etc.
 Seems like this could also be a good potential marketing opportunity for
 Clojure, were it to be used as the basis for building provably-correct apps
 that run in a JVM. I think that market is much bigger than the provable
 microkernel in C market. E.g.  toolkit for building probably secure and
 reliable cell-phone/multimedia java apps, or toolkit for building embedded
 controller software on which people's lives depend, literally

I'm pretty sure others will answer and elaborate with more background
than I have, but here we go:

What they are talking about is (semi) automated theorem proving [1]
(subfield of automated reasoning). To do that you need to have a
modeling language with very strict semantics, because you can only
prove if you can 'reason' (make a guarantee based on certain
assumptions) in an way about what a 'sentence' of your model language
says. Very strict semantics with possibility to reason about it
without actually running the program translates in the field of
computer programming languages to static type systems. And here be
sure to notice that the Haskell (static) type system is a couple of
orders of magnitude more capable than the (static) type system of
Java.

I don't know where you would want to use Java and/or Clojure, but I
doubt that you can get very far, because Java's static type system is
too limited, and Clojure is dynamically typed. I think a functional
language is easier to reason about compared to an object oriented one
(please someone comment on this), but it's not enough for theorem
proving.

The documentation available in HTML on the site is a bit thin as to
how they actually used Haskell and C together, check the paper: seL4:
Formal verification of an OS kernel [2]. The actual implementation
and what they prove (and not prove) can be found in section 2 -
Overview.

Cheers,
Daniel

[1] http://en.wikipedia.org/wiki/Automated_theorem_proving
[2] http://ertos.nicta.com.au/publications/papers/Klein_EHACDEEKNSTW_09.pdf

 http://ertos.nicta.com.au/research/l4.verified/ and http://ertos.nicta.com.au/research/l4.verified/approach.pml

 The L4.verified project

   A Formally Correct Operating System Kernel

 In current software practice it is widely accepted that software will always
 have problems and that we will just have to live with the fact that it may
 crash at the worst possible moment: You might be on a deadline. Or, much
 scarier, you might be on a plane and there's a problem with the board
 computer.

 Now think what we constantly want from software: more features, better
 performance, cheaper prices. And we want it everywhere: in mobile phones,
 cars, planes, critical infrastructure, defense systems.

 What do we get? Mobile phones that can be hacked by SMS. Cars that have more
 software problems than mechanical ones. Planes where computer problems have
 lead to serious incidents. Computer viruses spreading through critical
 infrastructure control systems and defense systems. And we think See, it
 happens to everybody.

 It does not have to be that way. Imagine your company is commissioning a new
 vending software. Imagine you write down in a contract precisely what the
 software is supposed to do. And then — it does. Always. And the developers
 can prove it to you — with an actual mathematical machine-checked proof.

 Of course, the issue of software security and reliability is bigger than
 just the software itself and involves more than developers making
 implementation mistakes. In the contract, you might have said something you
 didn't mean (if you are in a relationship, you might have come across that
 problem). Or you might have meant something you didn't say and the proof is
 therefore based on assumptions that don't apply to your situation. Or you
 haven't thought of everything you need (ever went shopping?). In these
 cases, there will still be problems, but at least you know where the problem
 is not: with the developers. Eliminating the whole issue of implementation
 mistakes would be a huge step towards more reliable and more secure systems.

 Sounds like science fiction?

 The L4.verified project demonstrates that such contracts and proofs can be
 done for real-world software. Software of limited size, but real and
 critical.

 We chose an operating system kernel to demonstrate this: 

Alternative implementation of structures.

2009-08-16 Thread Nicolas Oury

Dear all,

after having spend a bit of time optimizing the n-body benchmark, I had
an idea for another implementation of structures.

- Create a java object Structure, that contains a pointer to a
persistent hash map and a private abstract class Field, containing a
method set and a method get, both takes a Structure object as well as
the usual arguments). 

- When the user want to define a new structure type foo with fields a b
and c,
 * create an object Foo inheriting Structure with fields a, b and c.
 * create a static initial persistent hash-map whose entries
corresponding to a b and c contain an object of type Field referencing
to the field a, b and c.
 

- accessors for this foo structures are generated as a macro:
access foo a x - (let [#^Foo foo# x] (. x a))
accessor ... = fn [x] (access ... x) 
- updaters clones and sets the right field of the Foo object.
- Fields might have types, primitive or not.


You still keep the interface as a persistent hash-map, by using the
hash-map inside the structure object. On each get, a get is performed in
the table, if it returns:
   * a Field object, then a get is performed on that object. Returning
the content of the field.
   * else the result is directly forwarded,
Setting is similar.

- Transient version are made in O(1) by copying the structure and
putting the hash map in transient mode. Transient set! is made by direct
setting.

This implementation presents, I think, the same observational behavior
than the current one.
It might be slightly slower than the current one for access of non
static fields, but is probably very very close from using 
directly java objects when using with accessors, especially in a
transient way. (There is only one field more - the one  used to hold the
hash-map in the structures - compared to the java encoding, get is the
same as the java access to the object and transient set is the same
too).
Moreover, this implementation makes a nice use of having very fast
access to Java objects in Clojure. 

Does it seems like a good idea? 
Has it already been thought of and considered as a bad thing to do for a
reason I didn't see?
I don't think it should replace the current implementation but having
another one with different performance characteristics could be a good
thing.

If it seems helpful I would be happy to help to implement it, as it may
be very useful to the kind of programs I am writing, as well as allowing
Clojure to shine in micro-benchmarks.

Best regards,

Nicolas.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: what's the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread James Reeves

On Aug 16, 10:02 am, botgerry botge...@gmail.com wrote:
 1:  searching in a, if find one inner vector includes number 9 then
 append it a number 13
  [[1 2 3 4] [ ok metoo] [ 5 8 9 ]]  = [[1 2 3 4] [ ok metoo]
 [ 5 8 9 13]]

(into []
  (for [x a]
(if (contains? x 9)
  (conj x 13)
  x)))

 2: searching in a, if found two or many inner vectors include same
 element the merge them as one inner vector
 others not touch

 (def b ( conj  a  [ 5  10 oops]))  = [[1 2 3 4] [ok metoo] [5 8
 9] [5 10 oops]]
 in b, [5 8 9] and [5 10 oops] both include 5, it should be merge to
 [5 8 9 10 oops] :
 [[1 2 3 4] [ok metoo] [5 8 9] [5 10 oops]]  = [[1 2 3 4] [ok
 metoo] [5 8 9 10 oops]]

Does the order matter? If it doesn't, this could probably be most
easily done with sets and maps.

- James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: what's the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread botgerry



On 8月16日, 下午8时49分, James Reeves weavejes...@googlemail.com wrote:
 On Aug 16, 10:02 am, botgerry botge...@gmail.com wrote:

  1:  searching in a, if find one inner vector includes number 9 then
  append it a number 13
   [[1 2 3 4] [ ok metoo] [ 5 8 9 ]]  = [[1 2 3 4] [ ok metoo]
  [ 5 8 9 13]]

 (into []
   (for [x a]
 (if (contains? x 9)
   (conj x 13)
   x)))

this much better ,but should s/contains/includes

  2: searching in a, if found two or many inner vectors include same
  element the merge them as one inner vector
  others not touch

  (def b ( conj  a  [ 5  10 oops]))  = [[1 2 3 4] [ok metoo] [5 8
  9] [5 10 oops]]
  in b, [5 8 9] and [5 10 oops] both include 5, it should be merge to
  [5 8 9 10 oops] :
  [[1 2 3 4] [ok metoo] [5 8 9] [5 10 oops]]  = [[1 2 3 4] [ok
  metoo] [5 8 9 10 oops]]

 Does the order matter? If it doesn't, this could probably be most
 easily done with sets and maps.
order don't matter.
--~--~-~--~~~---~--~~
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 funny thing happened on the way to running Clojure

2009-08-16 Thread botgerry



On 8月16日, 上午8时13分, Waysys wshaf...@waysysweb.com wrote:
 Today I downloaded Clojure version 1.0.0 as a new Clojure user.  I
 prepared a .cmd file to run the program.  I copied and pasted in the
 instructions from the readme file into the .cmd file:

 java -cp clojure.jar clojure.lang.Repl

 (This is also the instruction on the Getting Started documentation
 on the Web site.

 I received this error:

 Exception in thread main java.lang.NoClassDefFoundError: clojure/
 lang/Repl

 While preparing a blistering message on software that does not even
 start up, I noticed that the .jar file was actually named
 clojure-1.0.0.jar.  When the correct .jar file name is used, things
 work much better.

 However, accurate documentation is nice too.

Sure , a minor doc problem maybe big troube to newcomers
Welcome to clojure world, have fun!

best regards

bot
--~--~-~--~~~---~--~~
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: Keyword not serializable

2009-08-16 Thread Chas Emerick
Indeed -- well, the patch file is there in assembla if you need  
keyword serializability right now.  Otherwise, I can't imagine it'll  
be long before it's brought into the github HEAD (though I'm certain  
Rich has more pressing things to handle).

- Chas

On Aug 14, 2009, at 3:18 PM, bradford cross wrote:

 the serializeability issues also come up with cascading/hadoop.

 On Thu, Aug 13, 2009 at 7:58 PM, Chas Emerick  
 cemer...@snowtide.com wrote:

 On Jul 31, 1:47 pm, Chris Kent cjk...@gmail.com wrote:
  Great.  As far as my (possibly flawed) understanding goes it  
 should be
  pretty simple.  Make it implementSerializableand add a readResolve
  method that returns intern(sym).  sym will have already been  
 interned
  by its own readResolve method.

 No, you're exactly right.  I've opened a ticket for this enhancement/
 fix, including a patch:

 http://www.assembla.com/spaces/clojure/tickets/174

 You can use the patch on your own right away if you're building
 clojure from source.

 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: Is there something special about haskell, or could verifiability announcements happen for purely functional Clojure programs too?

2009-08-16 Thread Nicolas Oury

Hello,

I am a specialist of a neighbour field so I can try to precise a few
things. 
It's not automated theorem proving they are talking about but more
interactive proof or assisted proof. The goal is to write a proof that a
computer can check and not to have a computer generating a proof. 
Most of the time, automatic proofs are just used for small proof steps
that would be written as trivial in a pen and paper proof.


This is indeed very important to have a clear semantic, else you can't
even write the properties you want to prove. What I don't agree with is
that a very precise semantic translate into static type system. 

A lot of non statically typed languages have a clear semantic too. For
example, lambda-calculus have no type at all but a very precise
semantic.
Having a precise semantic mainly means that the language has been
carefully designed and that it is easy to tell, and mathematically
formalize, what a program is going to do.
Being purely functional is a big help. Having clean concurrent construct
with a precise semantic is interesting too. 
From this point of view, Clojure has a quite precise semantic.

It is probably easier to prove programs in Clojure than programs in C or
Java. Even if some people makes a great job in proving Java programs: 

http://krakatoa.lri.fr/

But proving java programs is harder than proving functional programs
whether they are statically typed or not. 
Proof of imperative programs, when they are not functional programs in
hiding - mostly when there can be aliasing - , needs to carry around a
full and complete model of the state of memory, whereas pure functions
just need to relate arguments and results. 
And proved programs running java byte code sure is important. 


Less relevant digression about static typing and Dependant Type Theory
-

Now that I have started talking about program certification it is
impossible to stop me. So please forgive me if I am too long.

The part of this area I know best, Type Theory, proves the correctness
of programs by representing properties in very precise types.
Types are allowed to depend on values, and computations are allowed to
happen in types, making them far more powerful than types in a language
than Haskell.
 Translating these programs to another language (a process called
extraction) is not always possible to a usual ML-like language - without
unsafe cast - because some expressions are not typable in such a
language. 
There is a few practical examples (including things that look a bit like
ClojureSQL) of that in (it's time for self advertisement): 

http://sneezy.cs.nott.ac.uk/~npo/PowerPi.pdf

So being a dynamically typed functional language with clean construct
for concurrency makes Clojure an interesting language for certification
I believe.

Apologies for my long mail, never gives the opportunity to someone to
talk about his work...

Best regards,

Nicolas.

 


 What they are talking about is (semi) automated theorem proving [1]
 (subfield of automated reasoning). To do that you need to have a
 modeling language with very strict semantics, because you can only
 prove if you can 'reason' (make a guarantee based on certain
 assumptions) in an way about what a 'sentence' of your model language
 says. Very strict semantics with possibility to reason about it
 without actually running the program translates in the field of
 computer programming languages to static type systems. And here be
 sure to notice that the Haskell (static) type system is a couple of
 orders of magnitude more capable than the (static) type system of
 Java.
 
 I don't know where you would want to use Java and/or Clojure, but I
 doubt that you can get very far, because Java's static type system is
 too limited, and Clojure is dynamically typed. I think a functional
 language is easier to reason about compared to an object oriented one
 (please someone comment on this), but it's not enough for theorem
 proving.
 
 The documentation available in HTML on the site is a bit thin as to
 how they actually used Haskell and C together, check the paper: seL4:
 Formal verification of an OS kernel [2]. The actual implementation
 and what they prove (and not prove) can be found in section 2 -
 Overview.
 
 Cheers,
 Daniel
 
 [1] http://en.wikipedia.org/wiki/Automated_theorem_proving
 [2] http://ertos.nicta.com.au/publications/papers/Klein_EHACDEEKNSTW_09.pdf
 
  http://ertos.nicta.com.au/research/l4.verified/ and 
  http://ertos.nicta.com.au/research/l4.verified/approach.pml
 
  The L4.verified project
 
A Formally Correct Operating System Kernel
 
  In current software practice it is widely accepted that software will always
  have problems and that we will just have to live with the fact that it may
  crash at the worst possible moment: You might be on a deadline. Or, much
  scarier, you might be on a plane and there's a problem with the board
  computer.
 
  Now think what we 

Re: Can dosync transaction result computation be parallelized over multiple threads?

2009-08-16 Thread Chas Emerick


On Aug 14, 2009, at 8:53 PM, Mark Volkmann wrote:

 So it seems the biggest impact of the change can be summarized as
 follows. In the past, once you successfully ensured a Ref, you knew
 you could write to it later because no other thread could also ensure
 it. Now you don't know that. You know you can stop other threads from
 writing the Ref, but you won't be able to write the Ref as long as
 other threads have also ensured it.

 I'm not criticizing the change. There were likely good reasons for it.

 Please let me know if I have interpreted anything incorrectly.

Totally aside from the correctness of that analysis (which I've no  
reason to doubt a.t.m.), I just want to clarify that I never actually  
encountered any deadlocks (though I absolutely did burn a bunch of  
cycles trying to figure out why some fn was seeing old values in  
certain refs...due to the fn being involved in a pmap over a series of  
objects that contained refs).

- 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: A funny thing happened on the way to running Clojure

2009-08-16 Thread John Newman
In general, when writing documentation about software, you have to ask your
self what if the user downloaded 0.9? or what if the user downloaded
1.1?  How do you know what other docs someone might have written, that
might have led the user to have downloaded one version or another?  So the
doc's author was probably trying to be general, expecting you to know what
to do.  Some people won't though.

Perhaps some more specific wording like replace 'clojure.jar' with the
version of Clojure that you have downloaded. might be of help with those
edge cases.

Welcome to Clojure!

On Sat, Aug 15, 2009 at 5:13 PM, Waysys wshaf...@waysysweb.com wrote:


 Today I downloaded Clojure version 1.0.0 as a new Clojure user.  I
 prepared a .cmd file to run the program.  I copied and pasted in the
 instructions from the readme file into the .cmd file:

 java -cp clojure.jar clojure.lang.Repl

 (This is also the instruction on the Getting Started documentation
 on the Web site.

 I received this error:

 Exception in thread main java.lang.NoClassDefFoundError: clojure/
 lang/Repl

 While preparing a blistering message on software that does not even
 start up, I noticed that the .jar file was actually named
 clojure-1.0.0.jar.  When the correct .jar file name is used, things
 work much better.

 However, accurate documentation is nice too.

 



-- 
John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure success story ... hopefully :-)

2009-08-16 Thread Chas Emerick

On Aug 14, 2009, at 3:10 PM, bradford cross wrote:

 We have just released flightcaster.com which uses statistical  
 inference and machine learning to predict flight delays in advance  
 of airlines (initial results appear to do so with 85 - 90 % accuracy.)

 The webserver and webapp are all rails running on the Heroku  
 platform; which also serves our blackberry and iphone apps.

 The research and data heavy lifting is all in Clojure.

Congratulations to you and your team!  I'm glad to see more clojure  
getting out into production environments.

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: Alternative implementation of structures.

2009-08-16 Thread Chas Emerick


On Aug 16, 2009, at 7:32 AM, Nicolas Oury wrote:

 after having spend a bit of time optimizing the n-body benchmark, I  
 had
 an idea for another implementation of structures.

 - Create a java object Structure, that contains a pointer to a
 persistent hash map and a private abstract class Field, containing a
 method set and a method get, both takes a Structure object as well as
 the usual arguments).

 - When the user want to define a new structure type foo with fields  
 a b
 and c,
 * create an object Foo inheriting Structure with fields a, b and c.
 * create a static initial persistent hash-map whose entries
 corresponding to a b and c contain an object of type Field referencing
 to the field a, b and c.

Much of what you've described is either provided by newnew, or is  
relatively easy to produce with a couple of macro wrappers involving  
gen-interface and newnew:

http://www.assembla.com/wiki/show/clojure/New_new

The sands are shifting in that area though, as it's definitely  
bleeding-edge.  I'm certain contributions are welcome, but be prepared  
for some potential whiplash as the details are worked out.

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: Alternative implementation of structures.

2009-08-16 Thread Nicolas Oury


 Much of what you've described is either provided by newnew, or is  
 relatively easy to produce with a couple of macro wrappers involving  
 gen-interface and newnew:

That's what I was hoping for. No code generation code to write for it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: what's the appropriate way to process inner nested seqs in clojure?

2009-08-16 Thread botgerry



On 8月16日, 下午10时08分, botgerry botge...@gmail.com wrote:
 On 8月16日, 下午8时49分, James Reeves weavejes...@googlemail.com wrote:

  On Aug 16, 10:02 am, botgerry botge...@gmail.com wrote:

   1:  searching in a, if find one inner vector includes number 9 then
   append it a number 13
[[1 2 3 4] [ ok metoo] [ 5 8 9 ]]  = [[1 2 3 4] [ ok metoo]
   [ 5 8 9 13]]

  (into []
(for [x a]
  (if (contains? x 9)
(conj x 13)
x)))

 this much better ,but should s/contains/includes

   2: searching in a, if found two or many inner vectors include same
   element the merge them as one inner vector
   others not touch

   (def b ( conj  a  [ 5  10 oops]))  = [[1 2 3 4] [ok metoo] [5 8
   9] [5 10 oops]]
   in b, [5 8 9] and [5 10 oops] both include 5, it should be merge to
   [5 8 9 10 oops] :
   [[1 2 3 4] [ok metoo] [5 8 9] [5 10 oops]]  = [[1 2 3 4] [ok
   metoo] [5 8 9 10 oops]]

  Does the order matter? If it doesn't, this could probably be most
  easily done with sets and maps.

 order don't matter.

(defn merge-inner-blocks [x blocks]
  (let [with-out-x  (for [b blocks :when (not (includes? b x))] b)
with-x  (for [b blocks :when (includes? b x)] b) ]
 (conj  with-out-x (vec (set (flatten with-x))
now this works
--~--~-~--~~~---~--~~
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 funny thing happened on the way to running Clojure

2009-08-16 Thread Michael Wood

2009/8/16 John Newman john...@gmail.com:
 In general, when writing documentation about software, you have to ask your
 self what if the user downloaded 0.9? or what if the user downloaded
 1.1?  How do you know what other docs someone might have written, that
 might have led the user to have downloaded one version or another?  So the
 doc's author was probably trying to be general, expecting you to know what
 to do.  Some people won't though.

True, but in this case, I think, it is like that because before 1.0
was released the jar was called clojure.jar.  Only when 1.0 was
released was the version number included in the jar file name.

 Perhaps some more specific wording like replace 'clojure.jar' with the
 version of Clojure that you have downloaded. might be of help with those
 edge cases.

Yes, that's probably a good idea.

-- 
Michael Wood esiot...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A funny thing happened on the way to running Clojure

2009-08-16 Thread Wilson MacGyver

part of the confusion is also in the clojure build system. it builds
both clojure.jar and clojure-version.jar

for example, in the git clone version of clojure. it builds
both clojure.jar and clojure-1.1.0-alpha-SNAPSHOT.jar

which is probably how this got snuck by.

On Sun, Aug 16, 2009 at 3:19 PM, Michael Woodesiot...@gmail.com wrote:

 2009/8/16 John Newman john...@gmail.com:
 In general, when writing documentation about software, you have to ask your
 self what if the user downloaded 0.9? or what if the user downloaded
 1.1?  How do you know what other docs someone might have written, that
 might have led the user to have downloaded one version or another?  So the
 doc's author was probably trying to be general, expecting you to know what
 to do.  Some people won't though.

 True, but in this case, I think, it is like that because before 1.0
 was released the jar was called clojure.jar.  Only when 1.0 was
 released was the version number included in the jar file name.

 Perhaps some more specific wording like replace 'clojure.jar' with the
 version of Clojure that you have downloaded. might be of help with those
 edge cases.

 Yes, that's probably a good idea.

 --
 Michael Wood esiot...@gmail.com

 




-- 
Omnem crede diem tibi diluxisse supremum.

--~--~-~--~~~---~--~~
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 funny thing happened on the way to running Clojure

2009-08-16 Thread Waysys

I think the real solution is that I need to be smarter.
--~--~-~--~~~---~--~~
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 with maven - how to?

2009-08-16 Thread Mark Derricutt
I posted a simple example project to:
  http://github.com/talios/clojure-maven-example

last night which demonstrates the plugin.  As I mentioned in a post to this
list yesterday theres 3 tags - step1, step2, step3.   step1 just has a basic
pom and a test, step2 pulls in compojure and a simple webapp, step3 adds a
simple automated test for that compojure app.

Mark

-- 

On Sun, Aug 16, 2009 at 3:03 AM, Dragan Djuric draga...@gmail.com wrote:

 Can somebody help by posting a hello world example for one of (or
 both :) these issues? :)


--~--~-~--~~~---~--~~
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: Pure-functional N-body benchmark implementation

2009-08-16 Thread Meikel Brandmeyer

Hi,

Am 16.08.2009 um 12:50 schrieb Nicolas Oury:


The bad news: I am cheating a little bit...


Why is this cheating? People wrote programs in
C and dropped down to Assembly if necessary.
People write programs in Python and drop down
to C if necessary.

Why can't we write programs in Clojure and
drop down to Java if necessary?

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Clojure with maven - how to?

2009-08-16 Thread Christian Vest Hansen

Did you remember to push your tags? (git push --tags)

On Sun, Aug 16, 2009 at 9:51 PM, Mark Derricuttm...@talios.com wrote:
 I posted a simple example project to:
   http://github.com/talios/clojure-maven-example
 last night which demonstrates the plugin.  As I mentioned in a post to this
 list yesterday theres 3 tags - step1, step2, step3.   step1 just has a basic
 pom and a test, step2 pulls in compojure and a simple webapp, step3 adds a
 simple automated test for that compojure app.
 Mark
 --

 On Sun, Aug 16, 2009 at 3:03 AM, Dragan Djuric draga...@gmail.com wrote:

 Can somebody help by posting a hello world example for one of (or
 both :) these issues? :)

 




-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
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: Uncle Bob looking for clojure help!

2009-08-16 Thread Daniel Werner

David,

could you please post a version of your solution[1] annotated with
some comments on where you used which kind of optimization, and why?
Your code looks very clean to me, and with some additional
explanations I think this could become a good example on how to
optimize computation-heavy Clojure code.

[1] github.com/swannodette/convex-hull/tree/master

Thanks!

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: what's the appropriate way to process inner nested list (or vector) in clojure?

2009-08-16 Thread John Harrop
On Sun, Aug 16, 2009 at 1:30 AM, botgerry botge...@gmail.com wrote:


 Hello,all

 new to functional programming, I have one nested dynamic vecter just
 like this:

 (def a [[1 2 3 4] [ok 89 22] [25 78 99] ...]]

 it has to support ops:
 1*   add new item,it's easy: eg. (conj   a  [metoo oops] )
 2*  insert one element  into inner vector based that vector's
 content,eg  i have to append 50 in inner vectors which includes 99.
 the result  is [[1 2 3 4] [ok 89 22] [25 78 99 50]...]
 3*  merge inner vectors in a , eg. if there are same elements in
 inner vectors , they should be merged and delete same elements.
  [[1 2 3 4] [ ok 89 22] [ 5 6 7 2 ]...] - [[1 2 3 4 5 6 7] [ok 89
 22]]


If you are implementing a disjoint set forest, it might be better to use a
map from values to sets, where the lookup-set-given-value operation is a
simple map lookup, adding a new one-element set is just (assoc map object
#{object}), and merging two sets is almost as simple:

(let [new-set (into set-1 set-2)]
  (reduce #(assoc %1 %2 new-set) map new-set))

evaluates to the new forest map.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Pure-functional N-body benchmark implementation

2009-08-16 Thread Bradbev


 Why can't we write programs in Clojure and
 drop down to Java if necessary?

That's what I find funny about these threads, Clojure's Java interop
is good, Java is easy to write performant code in.  There is a clear
path to getting the best JVM performance possible from a Clojure
environment.  I'm not saying that we shouldn't worry about Clojure's
general performance - but for microbenchmarks there is a very clear
optimization strategy.

Brad
--~--~-~--~~~---~--~~
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 with maven - how to?

2009-08-16 Thread Mark Derricutt
Tags don't push automatically?  Never knew that :(  As soon as dropbox has
synced this laptop I'll push out the tags as well (and I hope they push out
old tags, and not just the new ones.
Mark
-- 

On Mon, Aug 17, 2009 at 8:46 AM, Christian Vest Hansen karmazi...@gmail.com
 wrote:

 Did you remember to push your tags? (git push --tags)


--~--~-~--~~~---~--~~
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 with maven - how to?

2009-08-16 Thread Mark Derricutt
The tags should be there now, pity github seems to be down now :(
-- 

On Mon, Aug 17, 2009 at 9:22 AM, Mark Derricutt m...@talios.com wrote:

 Tags don't push automatically?  Never knew that :(  As soon as dropbox has
 synced this laptop I'll push out the tags as well (and I hope they push out
 old tags, and not just the new ones.
 Mark
 --

 On Mon, Aug 17, 2009 at 8:46 AM, Christian Vest Hansen 
 karmazi...@gmail.com wrote:

 Did you remember to push your tags? (git push --tags)




--~--~-~--~~~---~--~~
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: Augmenting the defn attr-map

2009-08-16 Thread Stephen C. Gilardi


On Aug 13, 2009, at 4:52 PM, Chas Emerick wrote:


I've actually been using it at the REPL here and there, and I've found
it pretty pleasant -- it's a very pretty way to hint args compared to
#^, and arg:Type ordering makes for easy readability (e.g. you can
very easily scan an arg form and see what the names of the args are,
as opposed to actively parsing them due to #^ hints or scanning for
the (relatively unobtrusive) colon in the Type:arg style).

Code below.


Very cool! I like this a lot. Would you be up for writing some doc  
strings and including it in clojure.contrib.def?


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Augmenting the defn attr-map

2009-08-16 Thread Chas Emerick
On Aug 16, 2009, at 6:29 PM, Stephen C. Gilardi wrote:

 On Aug 13, 2009, at 4:52 PM, Chas Emerick wrote:

 I've actually been using it at the REPL here and there, and I've  
 found
 it pretty pleasant -- it's a very pretty way to hint args compared to
 #^, and arg:Type ordering makes for easy readability (e.g. you can
 very easily scan an arg form and see what the names of the args are,
 as opposed to actively parsing them due to #^ hints or scanning for
 the (relatively unobtrusive) colon in the Type:arg style).

 Code below.

 Very cool! I like this a lot. Would you be up for writing some doc  
 strings and including it in clojure.contrib.def?

Yeah, I could do that.

I don't actually think it's practical on its own, though.  My one  
concern is that using two hinting syntaxes in parallel (e.g. s:String  
in defh forms, but #^String s everywhere else) is, to put it lightly,  
painful.

What I might be able to do is define alternatively-hinted versions of  
let, for, doseq, etc., and rebind clojure.core/destructure during the  
evaluation of those macros so that the s:String style can get layered  
on top of binding forms (more) uniformly.

Feels hacky, thoughthoughts?

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



Improving the documentation

2009-08-16 Thread Ollie Saunders

Hi Clojurians,

I've been learning Clojure for about 5 or so days (I'm osaunders on
the channel) now and I'm liking it a lot. However, the lack of
structure of http://clojure.org/api is hampering my learning a bit. I
wonder other people think it might be a nice idea to organise the
functions into something more structured with each function having
it's own page complete with: forms, basic description, remarks,
examples, and importantly (for me) related functions.

I wouldn't mind doing a bit of work here and there in a wiki to make
that happen. I'm sure with a number of contributors the basic
functions could be covered quite quickly and over the weeks and months
it could unfurl into a rather nice language reference.

Ollie

--~--~-~--~~~---~--~~
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: Improving the documentation

2009-08-16 Thread Mark Volkmann

On Sun, Aug 16, 2009 at 6:12 PM, Ollie
Saundersoliver.saund...@gmail.com wrote:

 Hi Clojurians,

 I've been learning Clojure for about 5 or so days (I'm osaunders on
 the channel) now and I'm liking it a lot. However, the lack of
 structure of http://clojure.org/api is hampering my learning a bit. I
 wonder other people think it might be a nice idea to organise the
 functions into something more structured with each function having
 it's own page complete with: forms, basic description, remarks,
 examples, and importantly (for me) related functions.

 I wouldn't mind doing a bit of work here and there in a wiki to make
 that happen. I'm sure with a number of contributors the basic
 functions could be covered quite quickly and over the weeks and months
 it could unfurl into a rather nice language reference.

I took a shot at it at
http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
for changes to this are welcomed. Also check out
http://ociweb.com/mark/clojure/article.html.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Improving the documentation

2009-08-16 Thread Abhishek Reddy
You might find these pages somewhat helpful:

http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
http://java.ociweb.com/mark/clojure/ClojureCategorized.html

More generally, I'd agree that the Clojure sites need some structural work.
For example, I count no fewer than three wikis associated with the project
-- on Wikibooks, GitHub and Assembla.  (Actually, you might count five
including clojure.org itself and the old Google Code account.)

Are there plans to improve Clojure's web presence?  Is there any way to
contribute work towards it?


On Mon, Aug 17, 2009 at 11:12 AM, Ollie Saunders
oliver.saund...@gmail.comwrote:


 Hi Clojurians,

 I've been learning Clojure for about 5 or so days (I'm osaunders on
 the channel) now and I'm liking it a lot. However, the lack of
 structure of http://clojure.org/api is hampering my learning a bit. I
 wonder other people think it might be a nice idea to organise the
 functions into something more structured with each function having
 it's own page complete with: forms, basic description, remarks,
 examples, and importantly (for me) related functions.

 I wouldn't mind doing a bit of work here and there in a wiki to make
 that happen. I'm sure with a number of contributors the basic
 functions could be covered quite quickly and over the weeks and months
 it could unfurl into a rather nice language reference.

 Ollie

 



-- 
Abhishek Reddy
http://abhishek.geek.nz

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



commute and ref-set

2009-08-16 Thread Mark Volkmann

Once commute has been called on a Ref (within a transaction of
course), ref-set and alter cannot be called on it within the same
transaction.
This is enforced by the following code from the doSet method in
LockingTransaction.java.

   if(commutes.containsKey(ref))
throw new IllegalStateException(Can't set after commute);

Given that, I'm trying to figure out why the run method in
LockingTransaction.java contains this code in the loop that is
responsible for calling all the commute functions a second time during
the commit.

for(Map.EntryRef, ArrayListCFn e : commutes.entrySet())
{
Ref ref = e.getKey();
if(sets.contains(ref)) continue;
...

It seems that the Ref can't be in the sets HashSet if commute was
called first on the Ref.
Maybe it's there in case ref-set or alter was called on the Ref before commute.
In that case, does that mean that the commute functions for that Ref
won't be called a second time during the commit?

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Improving the documentation

2009-08-16 Thread Chas Emerick

On Aug 16, 2009, at 7:12 PM, Ollie Saunders wrote:

 I've been learning Clojure for about 5 or so days (I'm osaunders on
 the channel) now and I'm liking it a lot. However, the lack of
 structure of http://clojure.org/api is hampering my learning a bit. I
 wonder other people think it might be a nice idea to organise the
 functions into something more structured with each function having
 it's own page complete with: forms, basic description, remarks,
 examples, and importantly (for me) related functions.

 I wouldn't mind doing a bit of work here and there in a wiki to make
 that happen. I'm sure with a number of contributors the basic
 functions could be covered quite quickly and over the weeks and months
 it could unfurl into a rather nice language reference.

+10 on this.  One of the nicest things about Common Lisp is the  
hyperspec, insofar as it is a comprehensive, nicely cross-referenced  
body of documentation.  Clojure would benefit greatly from something  
analogous, especially if each piece of documentation (e.g. a page per  
fn, a page per fn category, etc) could link off to related utilities,  
either in the stdlib, contrib, or third-party libraries on github,  
etc.  Mix in some slick discovery UI along the lines of 
http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html 
 , and that's a resource everyone could love.

One thing I'd hope is that all this documentation be centralized  
somewhere, with very open policies in place to allow almost anyone to  
contribute documentation from their own libraries, place annotations  
on stdlib pages detailing how they use various fns, etc.  Things like  
this usually reach a critical mass of quality and usefulness when  
they're a focal point for all such efforts.

 On Aug 16, 2009, at 8:52 PM, Mark Volkmann wrote:

 I took a shot at it at
 http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
 for changes to this are welcomed. Also check out
 http://ociweb.com/mark/clojure/article.html.

Indeed, Mark, there's a ton of great material there -- I know I  
benefitted from it a number of times.  I hope you'll consider  
contributing all or parts of it to whatever central resource develops.

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: Augmenting the defn attr-map

2009-08-16 Thread Stephen C. Gilardi


On Aug 16, 2009, at 7:38 PM, Chas Emerick wrote:


On Aug 16, 2009, at 6:29 PM, Stephen C. Gilardi wrote:


Very cool! I like this a lot. Would you be up for writing some doc  
strings and including it in clojure.contrib.def?


Yeah, I could do that.

I don't actually think it's practical on its own, though.  My one  
concern is that using two hinting syntaxes in parallel (e.g.  
s:String in defh forms, but #^String s everywhere else) is, to put  
it lightly, painful.


Good point.

What I might be able to do is define alternatively-hinted versions  
of let, for, doseq, etc., and rebind clojure.core/destructure during  
the evaluation of those macros so that the s:String style can get  
layered on top of binding forms (more) uniformly.


Feels hacky, thoughthoughts?


My current favorite is a gen-class'd alternative to clojure.main that  
calls bindRoot on clojure.core/destructure to replace it with your  
customized version and then calls clojure.main. This way we can play  
with this pervasively both in the repl and in loaded code with the  
only tweak being calling your customized entry point instead of  
clojure.main.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Improving the documentation

2009-08-16 Thread Glen Stampoultzis
 I took a shot at it at
 http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
 for changes to this are welcomed. Also check out
 http://ociweb.com/mark/clojure/article.html.

 --
 R. Mark Volkmann
 Object Computing, Inc.


Since you're asking. :-)

That page would be greatly enhanced by a link through to the documentation
for each function.

There was a nice summary in the files section as well that was somewhat
similar to what you've done.

My ideal would be a system that categories all the docs, included links
through to the detailed documentation for each function as well as links to
examples.  A lot of this stuff is there if you search hard enough - it's
just not all nicely cross referenced.

--~--~-~--~~~---~--~~
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: Improving the documentation

2009-08-16 Thread David Plumpton

On Aug 17, 11:12 am, Ollie Saunders oliver.saund...@gmail.com wrote:
 Hi Clojurians,

 I've been learning Clojure for about 5 or so days (I'm osaunders on
 the channel) now and I'm liking it a lot. However, the lack of
 structure ofhttp://clojure.org/apiis hampering my learning a bit. I
 wonder other people think it might be a nice idea to organise the
 functions into something more structured with each function having
 it's own page complete with: forms, basic description, remarks,
 examples, and importantly (for me) related functions.

I feel that the examples would the most valuable aspect. This is the
main reason that the Hyperspec is so useful.

--~--~-~--~~~---~--~~
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: Improving the documentation

2009-08-16 Thread Mark Volkmann

On Sun, Aug 16, 2009 at 8:27 PM, Chas Emerickcemer...@snowtide.com wrote:

 On Aug 16, 2009, at 8:52 PM, Mark Volkmann wrote:

 I took a shot at it at
 http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
 for changes to this are welcomed. Also check out
 http://ociweb.com/mark/clojure/article.html.

 Indeed, Mark, there's a ton of great material there -- I know I
 benefitted from it a number of times.  I hope you'll consider
 contributing all or parts of it to whatever central resource develops.

Consider it contributed! Everything I've written about Clojure is
freely available for inclusion in some central repository of Clojure
documentation.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Augmenting the defn attr-map

2009-08-16 Thread tsuraan

 (defh a
[b:String [c:Double :as list:java.util.List] {d:java.util.Random :d}]
(.toCharArray b)
(.size list)
(.floatValue c)
(.nextInt d))

What's that :as in the [ c:Double :as list:java.util.List ] vector?

--~--~-~--~~~---~--~~
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: Augmenting the defn attr-map

2009-08-16 Thread Stephen C. Gilardi


On Aug 16, 2009, at 11:56 PM, tsuraan wrote:


(defh a
  [b:String [c:Double :as list:java.util.List]  
{d:java.util.Random :d}]

  (.toCharArray b)
  (.size list)
  (.floatValue c)
  (.nextInt d))


What's that :as in the [ c:Double :as list:java.util.List ] vector?



The entire expression you quoted requests destructuring of a  
sequential thing (such as a vector, seq, list, or something seq-able)  
as the second argument to a. The :as clause allows you to give a name  
to the entire sequential thing.


This desctruturing can be read as:

bind c to the first item in the sequential thing
bind list to the entire sequential thing

Here are a few examples:

user= (let [[c :as b] [5 4 3 2 1]] (prn c b))
5 [5 4 3 2 1]
nil
user= (let [[c m :as b] [5 4 3 2 1]] (prn c m b))
5 4 [5 4 3 2 1]
nil
	user= (let [[c m :as b] (java.util.ArrayList. [:a :b :c])] (prn c m  
b))

:a :b #ArrayList [:a, :b, :c]
nil

The official docs for this are at: http://clojure.org/ 
special_forms#let .


(and (doc let) contains a pointer there)

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Vimclojure and Namespaces

2009-08-16 Thread Konrad Scorciapino
Hi there!

I'm new with Clojure, and I'm having a problem with Vimclojure and
Namespaces. I'm following
thishttp://java.ociweb.com/mark/clojure/article.htmltutorial,
currently trying to evaluate the code below. If I evaluate the
whole file, it works, but not if I do so line-by-line via \et.

What seems to be happpening is that *ns* doesn't really change with (ns). If
I'm connected to 3 REPLs and def user/foobar to 3 in one of them, it'll be
defined in all REPLs, however if I try to change *ns*, the change in one
repl does not affect the others. Why is this happening?

Here is the code:

(ns com.ociweb.demo
  (:require [clojure.contrib.str-utils :as su])
  (:use [clojure.contrib.math :only (gcd, sqrt)])
  (:import (java.text NumberFormat) (javax.swing JFrame JLabel)))

(println (su/str-join $ [1 2 3])) ; - 1$2$3
(println (gcd 27 72)) ; - 9
(println (sqrt 5)) ; - 2.236
(println (.format (NumberFormat/getInstance) Math/PI)) ; - 3.142
;
; See the screenshot that follows this code.
(doto (JFrame. Hello)
  (.add (JLabel. Hello, World!))
  (.pack)
  ;(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) ; doesn't work with
this, for some reason
  (.setVisible true))

Thanks!

-- 
Et Forum delendum est!

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