Re: print-base / print-radix?

2009-07-05 Thread Parth



On Jul 5, 9:02 pm, Tom Faulhaber tomfaulha...@gmail.com wrote:
 Parth,

 I've created a little wrapper as promised at:http://gist.github.com/141001.

 It gives you my-pprint:

 user (binding [*print-base* 2] (my-pprint (range 10)))
 (0 1 10 11 100 101 110 111 1000 1001)
 nil
 user


Thanks Tom. This works beautifully :)

Here is the example that earlier example in the thread:

user= (binding [wrap-base/*print-base* 16] (wrap-base/my-pprint
(decode :b32 (test-ops 3
{:inst
 {:prefix (),
  :code (c7 45 f8 a 0 0 0),
  :op :movl,
  :args [{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} a]},
 :more ()}
nil
user=



 While doing this, I realized to my horror that ~r doesn't do 0
 correctly for non-standard bases. I'll fix that soon.

 Also, I've started to implement *print-radix* and *print-base* for
 real in cl-format and the pretty printer, so those should be available
 soon.



Fantastic ... pprint just keeps getting better :)

Regards,
Parth

 Enjoy,

 Tom

 On Jul 3, 3:16 am, Parth parth.malwan...@gmail.com wrote:

  On Jul 3, 11:25 am, Tom Faulhaber tomfaulha...@gmail.com wrote:

   Parth,

   I was thinking about this a little more today and I came up with a way
   to extend the pretty printer easily to support *print-radix* with a
   little wrapper. I'll try to get a chance to write it up for you
   tomorrow.

   Tom

  Sounds perfect. Thanks very much :)

  Regards,
  Parth

   On Jul 2, 6:29 pm, Parth parth.malwan...@gmail.com wrote:

On Jul 3, 6:15 am, Parth parth.malwan...@gmail.com wrote:

 Tom, Chouser, Thanks for your responses.

 As of now I am doing the same thing as suggested.
 However, this tends be become painful the moment structures
 start to nest. For e.g. I am using Clojure to decode a bit
 of assembly and below is what I end up doing to see the
 values of interest in hex:

 user= (decode :b32 (nth test-ops 3))
 {:inst {:prefix (), :code (199 69 248 10 0 0 0), :op :movl, :args
 [{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} 10]}, :more ()}
 user= (def r (decode :b32 (nth test-ops 3)))
 #'user/r
 user= (map hex (get-in r [:inst :code]))
 (c7 45 f8 a 0 0 0)
 user= (hex (second (get-in r [:inst :args])))
 a
 user=

 Basically, I need to extract each number seq or value
 individually and print it in hex for every instruction I
 decode and view.

 This isn't too much fun to do in the middle of  a debug session :)

 Having something like *print-base* would be ideal IMHO
 would make scenarios like this really easy as one could
 simply do:

 user= (set! *print-base* 16)
 user= (decode :b32 (nth test-ops 3))
 {:inst {:prefix (), :code (c7 47 f8 a 0 0 0), :op :movl, :args
 [{:type :Ev-mem, :arg {:reg :ebp, :disp f8}} a]}, :more ()}

 In the absence of this I thought of writing a function
 that would take an arbitrary Clojure structure/coll and print
 it out in the manner like above. But then it won't
 be much different from pprint with radix support but without
 the pretty part.

 I suppose what I am hoping is that a feature request for
 *print-base* sort of a mechanism get considered
 for Clojure as it makes scenarios like the above very
 easy to deal with. Any chance of this being somewhere
 on the Clojue todo? :)

Rich,

If this is something you think would be a good addition
to Clojure I could give a shot at creating a patch for
this (with a CA of course). Please let me know.

I think rather than a generic radix support, if
we have hex, bin and octal supported, most uses
cases should be covered.

Regards,
Parth

 I will probably create a poor mans radix based print
 in the mean time for the this scenario. That should
 be an interesting exercise.

 Thanks,
 Parth

 On Jul 2, 10:58 pm, Chouser chou...@gmail.com wrote:

  On Thu, Jul 2, 2009 at 4:51 AM, Parth

  Malwankarparth.malwan...@gmail.com wrote:

   I frequently deal with hex and binary numbers.
   As of now when I need to view a list of numbers
   I just map a little hex function to it to translate it
   into a list of hex strings at the repl.

   Having something like *print-base* / *print-radix* [1] may be
   valuable in such a scenario

  I don't think Java's built-in formatter is nearly as
  flexible as those, but getting hex or octal strings is easy
  enough:

  user= (format %d 255)
  255
  user= (format %o 255)
  377
  user= (format %x 255)
  ff
  user= (format %X 255)
  FF

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

Re: print-base / print-radix?

2009-07-03 Thread Parth



On Jul 3, 11:25 am, Tom Faulhaber tomfaulha...@gmail.com wrote:
 Parth,

 I was thinking about this a little more today and I came up with a way
 to extend the pretty printer easily to support *print-radix* with a
 little wrapper. I'll try to get a chance to write it up for you
 tomorrow.

 Tom


Sounds perfect. Thanks very much :)

Regards,
Parth


 On Jul 2, 6:29 pm, Parth parth.malwan...@gmail.com wrote:

  On Jul 3, 6:15 am, Parth parth.malwan...@gmail.com wrote:

   Tom, Chouser, Thanks for your responses.

   As of now I am doing the same thing as suggested.
   However, this tends be become painful the moment structures
   start to nest. For e.g. I am using Clojure to decode a bit
   of assembly and below is what I end up doing to see the
   values of interest in hex:

   user= (decode :b32 (nth test-ops 3))
   {:inst {:prefix (), :code (199 69 248 10 0 0 0), :op :movl, :args
   [{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} 10]}, :more ()}
   user= (def r (decode :b32 (nth test-ops 3)))
   #'user/r
   user= (map hex (get-in r [:inst :code]))
   (c7 45 f8 a 0 0 0)
   user= (hex (second (get-in r [:inst :args])))
   a
   user=

   Basically, I need to extract each number seq or value
   individually and print it in hex for every instruction I
   decode and view.

   This isn't too much fun to do in the middle of  a debug session :)

   Having something like *print-base* would be ideal IMHO
   would make scenarios like this really easy as one could
   simply do:

   user= (set! *print-base* 16)
   user= (decode :b32 (nth test-ops 3))
   {:inst {:prefix (), :code (c7 47 f8 a 0 0 0), :op :movl, :args
   [{:type :Ev-mem, :arg {:reg :ebp, :disp f8}} a]}, :more ()}

   In the absence of this I thought of writing a function
   that would take an arbitrary Clojure structure/coll and print
   it out in the manner like above. But then it won't
   be much different from pprint with radix support but without
   the pretty part.

   I suppose what I am hoping is that a feature request for
   *print-base* sort of a mechanism get considered
   for Clojure as it makes scenarios like the above very
   easy to deal with. Any chance of this being somewhere
   on the Clojue todo? :)

  Rich,

  If this is something you think would be a good addition
  to Clojure I could give a shot at creating a patch for
  this (with a CA of course). Please let me know.

  I think rather than a generic radix support, if
  we have hex, bin and octal supported, most uses
  cases should be covered.

  Regards,
  Parth

   I will probably create a poor mans radix based print
   in the mean time for the this scenario. That should
   be an interesting exercise.

   Thanks,
   Parth

   On Jul 2, 10:58 pm, Chouser chou...@gmail.com wrote:

On Thu, Jul 2, 2009 at 4:51 AM, Parth

Malwankarparth.malwan...@gmail.com wrote:

 I frequently deal with hex and binary numbers.
 As of now when I need to view a list of numbers
 I just map a little hex function to it to translate it
 into a list of hex strings at the repl.

 Having something like *print-base* / *print-radix* [1] may be
 valuable in such a scenario

I don't think Java's built-in formatter is nearly as
flexible as those, but getting hex or octal strings is easy
enough:

user= (format %d 255)
255
user= (format %o 255)
377
user= (format %x 255)
ff
user= (format %X 255)
FF

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



print-base / print-radix?

2009-07-02 Thread Parth Malwankar

I frequently deal with hex and binary numbers.
As of now when I need to view a list of numbers
I just map a little hex function to it to translate it
into a list of hex strings at the repl.


Having something like *print-base* / *print-radix* [1] may be
valuable in such a scenario

Or maybe an enhanced pprint? Not sure if pprint already provides
such an option or if its planned.

I would appreciate any comments or ideas if someone
is doing something similar.

Thanks.
Parth
[1] http://www.lispworks.com/documentation/lw50/CLHS/Body/v_pr_bas.htm
--~--~-~--~~~---~--~~
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: print-base / print-radix?

2009-07-02 Thread Parth

Tom, Chouser, Thanks for your responses.

As of now I am doing the same thing as suggested.
However, this tends be become painful the moment structures
start to nest. For e.g. I am using Clojure to decode a bit
of assembly and below is what I end up doing to see the
values of interest in hex:

user= (decode :b32 (nth test-ops 3))
{:inst {:prefix (), :code (199 69 248 10 0 0 0), :op :movl, :args
[{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} 10]}, :more ()}
user= (def r (decode :b32 (nth test-ops 3)))
#'user/r
user= (map hex (get-in r [:inst :code]))
(c7 45 f8 a 0 0 0)
user= (hex (second (get-in r [:inst :args])))
a
user=

Basically, I need to extract each number seq or value
individually and print it in hex for every instruction I
decode and view.

This isn't too much fun to do in the middle of  a debug session :)

Having something like *print-base* would be ideal IMHO
would make scenarios like this really easy as one could
simply do:

user= (set! *print-base* 16)
user= (decode :b32 (nth test-ops 3))
{:inst {:prefix (), :code (c7 47 f8 a 0 0 0), :op :movl, :args
[{:type :Ev-mem, :arg {:reg :ebp, :disp f8}} a]}, :more ()}

In the absence of this I thought of writing a function
that would take an arbitrary Clojure structure/coll and print
it out in the manner like above. But then it won't
be much different from pprint with radix support but without
the pretty part.

I suppose what I am hoping is that a feature request for
*print-base* sort of a mechanism get considered
for Clojure as it makes scenarios like the above very
easy to deal with. Any chance of this being somewhere
on the Clojue todo? :)

I will probably create a poor mans radix based print
in the mean time for the this scenario. That should
be an interesting exercise.

Thanks,
Parth


On Jul 2, 10:58 pm, Chouser chou...@gmail.com wrote:
 On Thu, Jul 2, 2009 at 4:51 AM, Parth

 Malwankarparth.malwan...@gmail.com wrote:

  I frequently deal with hex and binary numbers.
  As of now when I need to view a list of numbers
  I just map a little hex function to it to translate it
  into a list of hex strings at the repl.

  Having something like *print-base* / *print-radix* [1] may be
  valuable in such a scenario

 I don't think Java's built-in formatter is nearly as
 flexible as those, but getting hex or octal strings is easy
 enough:

 user= (format %d 255)
 255
 user= (format %o 255)
 377
 user= (format %x 255)
 ff
 user= (format %X 255)
 FF

 --Chouser
--~--~-~--~~~---~--~~
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: print-base / print-radix?

2009-07-02 Thread Parth



On Jul 2, 9:44 pm, Tom Faulhaber tomfaulha...@gmail.com wrote:
 Hi Parth,

 It is on the agenda to support this for pprint, but I don't know
 exactly when.


Thanks Tom.

I look forward to this addition to the wonderful pprint function :)

Regards,
Parth

 In the meantime, arbitrary bases *are* supported in the common lisp
 compatible format function (cl-format) which is also part of
 clojure.contrib.pprint.

 The interesting directives are ~X, ~B, and ~bR, where b is the base of
 interest. For example,

 (cl-format nil ~X 256) = 100

 (cl-format nil ~12r 256) = 194

 (cl-format true ~{~X ~}~% [2 4 8 16 32 64 128 256])

 prints to *out*:

 2 4 8 10 20 40 80 100

 For all the dirt on using radix, look at the Common Lisp 
 Hyperspec:http://www.lispworks.com/documentation/HyperSpec/Body/22_cb.htm

 More info about the clojure implementation of format 
 here:http://code.google.com/p/clojure-contrib/wiki/CommonLispFormat(a
 little out of date and about to be moved).

 HTH,

 Tom
 On Jul 2, 1:51 am, Parth Malwankar parth.malwan...@gmail.com wrote:

  I frequently deal with hex and binary numbers.
  As of now when I need to view a list of numbers
  I just map a little hex function to it to translate it
  into a list of hex strings at the repl.

  Having something like *print-base* / *print-radix* [1] may be
  valuable in such a scenario

  Or maybe an enhanced pprint? Not sure if pprint already provides
  such an option or if its planned.

  I would appreciate any comments or ideas if someone
  is doing something similar.

  Thanks.
  Parth
  [1]http://www.lispworks.com/documentation/lw50/CLHS/Body/v_pr_bas.htm
--~--~-~--~~~---~--~~
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: print-base / print-radix?

2009-07-02 Thread Parth



On Jul 3, 6:15 am, Parth parth.malwan...@gmail.com wrote:
 Tom, Chouser, Thanks for your responses.

 As of now I am doing the same thing as suggested.
 However, this tends be become painful the moment structures
 start to nest. For e.g. I am using Clojure to decode a bit
 of assembly and below is what I end up doing to see the
 values of interest in hex:

 user= (decode :b32 (nth test-ops 3))
 {:inst {:prefix (), :code (199 69 248 10 0 0 0), :op :movl, :args
 [{:type :Ev-mem, :arg {:reg :ebp, :disp -8}} 10]}, :more ()}
 user= (def r (decode :b32 (nth test-ops 3)))
 #'user/r
 user= (map hex (get-in r [:inst :code]))
 (c7 45 f8 a 0 0 0)
 user= (hex (second (get-in r [:inst :args])))
 a
 user=

 Basically, I need to extract each number seq or value
 individually and print it in hex for every instruction I
 decode and view.

 This isn't too much fun to do in the middle of  a debug session :)

 Having something like *print-base* would be ideal IMHO
 would make scenarios like this really easy as one could
 simply do:

 user= (set! *print-base* 16)
 user= (decode :b32 (nth test-ops 3))
 {:inst {:prefix (), :code (c7 47 f8 a 0 0 0), :op :movl, :args
 [{:type :Ev-mem, :arg {:reg :ebp, :disp f8}} a]}, :more ()}

 In the absence of this I thought of writing a function
 that would take an arbitrary Clojure structure/coll and print
 it out in the manner like above. But then it won't
 be much different from pprint with radix support but without
 the pretty part.



 I suppose what I am hoping is that a feature request for
 *print-base* sort of a mechanism get considered
 for Clojure as it makes scenarios like the above very
 easy to deal with. Any chance of this being somewhere
 on the Clojue todo? :)


Rich,

If this is something you think would be a good addition
to Clojure I could give a shot at creating a patch for
this (with a CA of course). Please let me know.

I think rather than a generic radix support, if
we have hex, bin and octal supported, most uses
cases should be covered.

Regards,
Parth



 I will probably create a poor mans radix based print
 in the mean time for the this scenario. That should
 be an interesting exercise.

 Thanks,
 Parth

 On Jul 2, 10:58 pm, Chouser chou...@gmail.com wrote:

  On Thu, Jul 2, 2009 at 4:51 AM, Parth

  Malwankarparth.malwan...@gmail.com wrote:

   I frequently deal with hex and binary numbers.
   As of now when I need to view a list of numbers
   I just map a little hex function to it to translate it
   into a list of hex strings at the repl.

   Having something like *print-base* / *print-radix* [1] may be
   valuable in such a scenario

  I don't think Java's built-in formatter is nearly as
  flexible as those, but getting hex or octal strings is easy
  enough:

  user= (format %d 255)
  255
  user= (format %o 255)
  377
  user= (format %x 255)
  ff
  user= (format %X 255)
  FF

  --Chouser
--~--~-~--~~~---~--~~
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: Hash Consing

2009-06-29 Thread Parth



On Jun 29, 3:09 pm, Nicolas Oury nicolas.o...@gmail.com wrote:
 Dear all,

 I am coding a (very) small hash consing library for clojure.

 For those we don't happen to know what hash consing is, it is a way of
 allowing equal data structures to be shared in memory.
 This leverages the purity (as in immutability) of data structures to
 reduce memory footprint (no duplication of data for just a constant
 overhead per allocation) and makes hashing and equality tests faster.
 (You can use java non overloaded hashCode, and == to test equality,
 because of the sharing. So both operations are O(1), with a very small
 constant, whatever is the complexity of the hash consed data
 structures.)

I don't know anything about hash consing. Based on my
limited understanding of the description I am just wondering
if this is different from structural sharing that Clojure collections
have.

Quoting the docs[1]:

In particular, the Clojure collections support efficient creation of
'modified'
versions, by utilizing structural sharing, and make all of their
performance
bound guarantees for persistent use.


Do you have something different in mind with hash consing?

Regards,
Parth

[1] http://clojure.org/data_structures#toc12

 This can then be used, in combination with referential transparency to
 make memoized function faster.

 I have a java file and a clojure interface that seem to work, at least
 on my example. I plan to put something somewhere someday, but before
 spending too much time in making this releasable, i Have a few
 questions:

 - does something already exists in contrib that I have missed?
 - is someone else working on that?
 - are there any features that I need and that you must implement that
 you think of?

 My current plans are:
 - using a java concurrent hash map to soft referenced objects for the
 hash consing table.
 - only two fields in an hash consed object: the value it represents,
   and a generic field called cached_data used to store anything you
 want to memoize about this data structure. (Keeping this cached data a
 bit longer is the reason I plan to use soft references and not weak
 references)

 I am not a clojure expert and I am not a java coder at all, so don't
 hesitate to tell me if my plans are somehow wrong.

 Bets 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: accum

2009-06-17 Thread Parth



On Jun 17, 10:24 am, Wrexsoul d2387...@bsnow.net wrote:
 On Jun 17, 12:44 am, Daniel Lyons fus...@storytotell.org wrote:




  (use 'clojure.contrib.seq-utils)

 Don't have that library. Still hasn't been released yet, last I
 checked.

I am not sure if a pre-built clojure-contrib.jar is available.

You could consider building from sources. It should be quite
straightforward.

[src]% git clone  git://github.com/richhickey/clojure-contrib.git
[src]% cd clojure-contrib
[clojure-contrib]% ant clean jar -Dclojure.jar=../clojure/clojure.jar
[clojure-contrib]% ls
build.xml  classes/  ClojureCLR/  clojure-contrib.jar  clojure-contrib-
slim.jar  clojurescript/  CPL.TXT*  epl-v10.html  launchers/  pom.xml
README.txt  Revisions  src/
[clojure-contrib]%

Note that -Dclojure.jar in the ant command above should point
to whereever you have the clojure.jar.

clojure-contrib has a lot of useful libs that you will miss out
on in case you are not using it.

Regards,
Parth

--~--~-~--~~~---~--~~
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: Dynamically accessing static fields

2009-06-15 Thread Parth



On Jun 15, 7:08 am, James Koppel darmanith...@gmail.com wrote:
 I am trying to write a function to simplify working with GridBagConstraints
 -- that is, instead of writing

 (let [c (GridBagConstraints.)]
     (set! (.weightx c) 2.0)
     (set! (.gridwidth c) GridBagConstraints/REMAINDER)
     (let [button (JButton. Hello, world!)]
       (.setConstraints (.getLayout *my-container*) button c)
       (.add *my-container* button)))

 I could simply write

 (gridbag-add *my-container*
                   (JButton. Hello, world!)
                   weightx=2.0;gridwith=GridBagConstraints/REMAINDER)

 A simple combination of regexes and read-string would easily allow me to
 extract the symbol 'GridBagConstraints/REMAINDER from the example string,
 but I'm having trouble actually converting it into its value. Using resolve
 simply returns nil, and getting . to work dynamically seems to be
 fruitless, as even this simple call

 (. (resolve 'GridBagConstraints) REMAINDER)

 throws an exception.

 So, the question is, how do I go dynamically from a string like
 GridBagConstraints/REMAINDER to the actual value of the static field?

 Of course, eval does the trick, but I'd rather not have to resort to it.

One way to do that would be to use a map:

user= (def m {Math/PI Math/PI Math/E Math/E})
#'user/m
user= (defn foo [n s] [n (get m s :not-found)])
#'user/foo
user= (foo 10 Math/PI)
[10 3.141592653589793]
user=

You could also consider writing a function that takes these
as parameters and returns the updated container. That way
you can avoid the regex.

Regards,
Parth



 Sorry if the answer is obvious; I'm a Clojure-newbie.
--~--~-~--~~~---~--~~
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: matlab like clojure

2009-06-15 Thread Parth



On Jun 15, 7:23 pm, Bugs icebe...@gmail.com wrote:
 Hi, everyone.

 I'm a newbie on Clojure and LISP, and I'm interasted in matlab
 replacement languages.
 It is just my hobby, but I'm trying to implement a matlab like
 language extension.

 I think that Clojure has ability enough to be numerical language like
 a Matlab or Mathematica.

 So, I'm finding examples for matrix operation ( + - * .*
 transpose ./ .^, and so on)

 Does anyone have the examples?


I don't know much about matlab or mathematica but you
might find incanter interesting.
http://github.com/liebke/incanter/tree/master

Regards,
Parth


 Regards,
--~--~-~--~~~---~--~~
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: Performance Penalty Converting from Java Code

2009-06-14 Thread Parth



On Jun 14, 7:00 pm, tmountain tinymount...@gmail.com wrote:
 I've been playing around with rewriting some Java code in Clojure and
 did some simple benchmarking in the process. In this case, there's a
 huge disparity in the performance numbers between the two languages,
 and I'm wondering what the cause may be. The program rotates a string
 from , aaab, ..., . The Java version takes 0.77 seconds
 to complete while the Clojure version takes 22 seconds. I've tried to
 make the scripts relatively isomorphic and have verified that they
 produce the same results. I'm pasting the source below.


Here is a clojure version that runs significantly faster
on my system. The main optimizations I have done are
coercion to primitives and using unchecked ops.
As I understand it, the original clojure version is slow
because its safer (checks for overflows etc.).

(defn xbase26 [n]
  (let [seed-string 
s (new StringBuilder seed-string)
a_val (int \a)]
(loop [pos 3 x (int n)]
  (when (pos? x)
(let [digit (char (+ a_val (unchecked-remainder x 26)))]
  (.setCharAt s pos digit)
  (when (pos? pos)
(recur (int (dec pos)) (unchecked-divide x 26))
(.toString s)))

These are the numbers I see:

;; java
[clojure]% time java -cp .
Base26
java -cp . Base26  0.40s user 0.02s system 88% cpu 0.476 total

;; original
[clojure]% time java -cp .:classes:/home/parthm/src/clojure/
clojure.jar base26
java -cp .:classes:/home/parthm/src/clojure/clojure.jar base26  33.08s
user 1.18s system 99% cpu 34.456 total
[clojure]%

;; optimized
[clojure]% time java -cp .:classes:/home/parthm/src/clojure/
clojure.jar base26
java -cp .:classes:/home/parthm/src/clojure/clojure.jar base26  1.75s
user 0.11s system 104% cpu 1.784 total


While this works well, I more optimization may
be possible by choosing an algorithm thats more suited
and ideomatic for clojure. I suppose that intent here
is to do a micro-benchmark.

Regards,
Parth


 tra...@travis-ubuntu:/tmp% time clj base26.clj
 clj base26.clj  21.99s user 1.23s system 85% cpu 27.318 total

 tra...@travis-ubuntu:/tmp% time java Base26
 java Base26  0.77s user 0.04s system 78% cpu 1.029 total

 clojure version:

 (defn base26 [n]
   (let [seed-string 
         s (new StringBuilder seed-string)]
     (loop [pos (- (count seed-string) 1)
            x n]
       (if ( x 0)
         (let [digit (+ (int \a) (mod x 26))]
           (. s setCharAt pos (char digit))
           (if (and ( pos 0) ( x 0))
             (recur (- pos 1) (/ x 26))
     (. s toString)))

 (doseq [i (range (Math/pow 26 4))]
     (base26 i))

 java version:

 import java.lang.StringBuilder;

 public class Base26 {
     public static void main(String[] args) {
         for (int i = 0; i  Math.pow(26, 4); i++) {
             Base26.base26(i);
         }
     }

     public static String base26(int num) {
         if (num  0) {
             throw new IllegalArgumentException(Only positive numbers
 are supported);
         }
         StringBuilder s = new StringBuilder();
         for (int pos = 3; pos = 0  num  0 ; pos--) {
             char digit = (char) ('a' + num % 26);
             s.setCharAt(pos, digit);
             num = num / 26;
         }
         return s.toString();
     }

 }

 I've tried warn-on-reflection, and it didn't report anything.

 Thanks,
 Travis
--~--~-~--~~~---~--~~
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: macro escapes and passing method names are function arguments

2009-06-09 Thread Parth



On Jun 9, 11:50 am, Josh  Smith kogn...@gmail.com wrote:
 I've been trying to understand the macro syntax in clojure.  I think
 macro's are closer to the kind of functionality I'm looking for (as
 opposed to multi-methods) but I'm not sure.

 http://gist.github.com/126315


Hi Josh,

As a general recommendation, its better to use functions
instead of macros as functions provide a lot of flexibility
(e.g. you can apply them). The thumb rule I use to use a
macro only if I can't do something with a function.

user= (defmacro double-mac [x] `(* ~x ~x))
#'user/double-mac
user= (double-mac 2)
4
user= (defn double-fn [x] (* x x))
#'user/double-fn
user= (map double-fn [1 2 3])
(1 4 9)
user= (map double-mac [1 2 3])
java.lang.Exception: Can't take value of a macro: #'user/double-mac
(NO_SOURCE_FILE:8)
user=

Another minor comment, Lisp style programming
usually stacks up parenthesis at the end rather than
put them in separate lines like C or Java.
E.g.
(defn foo [coll]
   (map inc  coll))

rather than
(defn foo [coll]
  (map inc coll)
)


 I wrote the above code, which simply processes Java-style Properties
 files (using the java interfaces) as
 a learning exercise.  It works, but I'm still hazy about exactly why
 it works.


I don't know java too well so I can't really talk much about
properties file. :(

There are some functions dealing with properties in
clojure.contrib.java-utils. They might be good for use/reference
in case you haven't seen them already.

http://code.google.com/p/clojure-contrib/wiki/JavaUtilsApiDoc


 I spent a lot of time figuring out the escape/not escape syntax.  What
 do you recommend as a starting place for understanding what needs to
 be escaped, and what doesn't?  Is that even the right question?
 What's the best way to learn the proper care and feeding of macros?
 Is there another/better way of passing a method name to a function as
 an argument than via a macro?


I found PCL and OnLisp very useful to understand macros.

http://gigamonkeys.com/book/
http://www.paulgraham.com/onlisp.html

Both are available online. You could just look at the chapters
relevant to macros. Though these books deal with Common Lisp
the same principles hold and the macro system is similar
(in clojure you don't need gensym as often).

 Another question I have is that the Properties class is listed as
 being thread safe.  Does that mean
 it can safely be used in the multi-threaded Clojure app?

 Lastly,  is there any way to turn a string into a :thing?  For
 example,  I've got stow and I want a function
 that returns :stow.


The :thing are called keywords in Lisp/Clojure and are very
useful. I think what you are looking for is:

user= (keyword stow)
:stow

Regards,
Parth

 Thank you


--~--~-~--~~~---~--~~
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: Threadring Benchmark

2009-06-07 Thread Parth

So I got a chance to do some tweaks to the clojure code
and run the benchmark. I also used the approved (not alternative)
version of java code for comparison.
I must say I am impressed with the clojure agent performance.

The previous implementation results for 20,000,000 hops was:
java: 27.14 sec, 92% cpu
scala: 190.78 sec, 183% cpu
clojure: 215.26 sec, 134% cpu

The new results are:
java: 33.56 sec, 94% cpu
scala: 191.08 sec, 177% cpu
clojure: 77.01 sec, 91% cpu

The tweaks to clojure code were minor. Basically,
coercing hops to (int hops) and using (neg? hops) instead
of =.

Detailed Log: http://gist.github.com/125614
Updated Clojure Code: http://gist.github.com/125615
Jave Code: 
http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadringlang=javaid=4
Scala Code: 
http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadringlang=scalaid=1

Regards,
Parth

On Jun 6, 2:39 pm, Parth parth.malwan...@gmail.com wrote:
 On Jun 6, 11:44 am, Sean Devlin francoisdev...@gmail.com wrote:

  This problem came up on the mailing list recently:

 http://groups.google.com/group/clojure/browse_thread/thread/5e0c078d0...

  You might want to compare your code to what was done here, but at a
  glance the implementations are similar.

  You provide relative speed comparisons (Such and such is %
  better...).  Would you be able to share absolute times as well?  I'm
  just curious at this point.

  Sean

 For some reason the google spreadsheet link provided in
 my original mail requires users to login for viewing.
 The same numbers are available in this published
 google spreadsheet (hopefully without login).

 http://tinyurl.com/ofhync

 Regards,
 Parth



  On Jun 6, 12:41 am, Parth Malwankar parth.malwan...@gmail.com wrote:

   Hello,

   In order to understand the agent model of Clojure
   better I wrote the alioth shootout threadring benchmark [1].
   I ran some tests to compare it with the Java and Scala
   implementation [2, 3] which I picked from the published
   benchmarks.

   The clojure code can be found here:http://gist.github.com/124688

   The benchmark from my two core 1.7GHz pentium system
   (ubuntu 9.04) w/ 1GB RAM can be found 
   here:http://spreadsheets.google.com/ccc?key=rQLD6jgTTV5OqXwHdXtrTyg

   In summary, scala implementation is 6.34x times slower than
   java, clojure is 7.8x. Avg CPU consumption is 93.3% for java and
   179.2% and 131.34% for scala and clojure respectively.

   I thought of sharing this in case others are interested.
   As this is my first program using clojure agents I would appreciate
   any
   comments on improving the Clojure implementation (or in case
   there are any bugs).

   Thanks.
   Parth
   PS: For the Java implementation I happen to pick the interesting
   alternate programs (Java 6 -server #5) but it was already quite
   late in the cycle when I realized that. So the Java numbers are
   probably better than the other java implementations.

   [1]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
   [2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
   [3]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
--~--~-~--~~~---~--~~
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: Threadring Benchmark

2009-06-06 Thread Parth



On Jun 6, 11:44 am, Sean Devlin francoisdev...@gmail.com wrote:
 This problem came up on the mailing list recently:

 http://groups.google.com/group/clojure/browse_thread/thread/5e0c078d0...

 You might want to compare your code to what was done here, but at a
 glance the implementations are similar.

 You provide relative speed comparisons (Such and such is %
 better...).  Would you be able to share absolute times as well?  I'm
 just curious at this point.

 Sean

For some reason the google spreadsheet link provided in
my original mail requires users to login for viewing.
The same numbers are available in this published
google spreadsheet (hopefully without login).

http://tinyurl.com/ofhync

Regards,
Parth



 On Jun 6, 12:41 am, Parth Malwankar parth.malwan...@gmail.com wrote:

  Hello,

  In order to understand the agent model of Clojure
  better I wrote the alioth shootout threadring benchmark [1].
  I ran some tests to compare it with the Java and Scala
  implementation [2, 3] which I picked from the published
  benchmarks.

  The clojure code can be found here:http://gist.github.com/124688

  The benchmark from my two core 1.7GHz pentium system
  (ubuntu 9.04) w/ 1GB RAM can be found 
  here:http://spreadsheets.google.com/ccc?key=rQLD6jgTTV5OqXwHdXtrTyg

  In summary, scala implementation is 6.34x times slower than
  java, clojure is 7.8x. Avg CPU consumption is 93.3% for java and
  179.2% and 131.34% for scala and clojure respectively.

  I thought of sharing this in case others are interested.
  As this is my first program using clojure agents I would appreciate
  any
  comments on improving the Clojure implementation (or in case
  there are any bugs).

  Thanks.
  Parth
  PS: For the Java implementation I happen to pick the interesting
  alternate programs (Java 6 -server #5) but it was already quite
  late in the cycle when I realized that. So the Java numbers are
  probably better than the other java implementations.

  [1]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
  [2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
  [3]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring;...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Threadring Benchmark

2009-06-05 Thread Parth Malwankar

Hello,

In order to understand the agent model of Clojure
better I wrote the alioth shootout threadring benchmark [1].
I ran some tests to compare it with the Java and Scala
implementation [2, 3] which I picked from the published
benchmarks.

The clojure code can be found here:
http://gist.github.com/124688

The benchmark from my two core 1.7GHz pentium system
(ubuntu 9.04) w/ 1GB RAM can be found here:
http://spreadsheets.google.com/ccc?key=rQLD6jgTTV5OqXwHdXtrTyg

In summary, scala implementation is 6.34x times slower than
java, clojure is 7.8x. Avg CPU consumption is 93.3% for java and
179.2% and 131.34% for scala and clojure respectively.

I thought of sharing this in case others are interested.
As this is my first program using clojure agents I would appreciate
any
comments on improving the Clojure implementation (or in case
there are any bugs).

Thanks.
Parth
PS: For the Java implementation I happen to pick the interesting
alternate programs (Java 6 -server #5) but it was already quite
late in the cycle when I realized that. So the Java numbers are
probably better than the other java implementations.

[1] 
http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadringlang=all
[2] 
http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadringlang=javaid=5
[3] 
http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadringlang=scalaid=1

--~--~-~--~~~---~--~~
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: AIML pattern matcher design

2009-05-08 Thread Parth Malwankar

On Fri, 08 May 2009 22:20:13 +0530, dhs827 scheur...@gmail.com wrote:




 ; First thing to learn is XML parsing with Clojure.

snip

 Other comments, tips, disses?

 Dirk

In case you don't expect end users or other languages
to access the configuration, one option you have is
to save the configuration directly as Clojure data.

As Clojure is a lisp, you have access to the reader and
you could read the data (maps, vectors, etc.)
directly from the file.

E.g.:

user= (def x (read-string {:a 1 :b 2}))
#'user/x
user= x
{:a 1, :b 2}
user=

See also: (doc read)

If you decide to go ahead with xml, you can use
the xml support in clojure core:

http://clojure.org/api#toc673

Regards,
Parth


--~--~-~--~~~---~--~~
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
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 function that returns the opposite of a predicate?

2009-04-30 Thread Parth Malwankar

On Thu, 30 Apr 2009 23:20:14 +0530, samppi rbysam...@gmail.com wrote:


 I know there's a core function that takes a predicate and returns its
 opposite:

 (defn mystery [predicate]
   (fn [x] (not (predicate x

 I'm having a lot of trouble finding the name of it in the docs,
 though. Could anyone give me its name? Or does this function not exist
 in the core?

user= (doc complement)
-
clojure.core/complement
([f])
   Takes a fn f and returns a fn that takes the same arguments as f,
   has the same effects, if any, and returns the opposite truth value.
nil
user=

Regards,
Parth


--~--~-~--~~~---~--~~
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
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: new in duck-streams: with-out-writer / with-in-reader

2009-03-28 Thread Parth



On Mar 29, 7:36 am, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 Following a discussion from a few days ago, I've added two new macros
 to clojure.contrib.duck-streams:

 (defmacro with-out-writer
   Opens a writer on f, binds it to *out*, and evalutes body.
   [f  body]
   `(with-open [stream# (writer ~f)]
      (binding [*out* stream#]
       �...@body)))

 (defmacro with-in-reader
   Opens a PushbackReader on f, binds it to *in*, and evaluates body.
   [f  body]
   `(with-open [stream# (PushbackReader. (reader ~f))]
      (binding [*in* stream#]
       �...@body)))

 -Stuart Sierra

This is very useful. Thank you :)

--~--~-~--~~~---~--~~
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
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: exposing specific functions via namespace

2009-03-26 Thread Parth



On Mar 26, 8:35 am, John D. Hume duelin.mark...@gmail.com wrote:
 On Wed, Mar 25, 2009 at 12:05 PM, Parth parth.malwan...@gmail.com wrote:
  I have split up the foo namespace across multiple files. So,
  I have the following now:

  src/org/ppm/foo.clj - org.ppm.foo
  src/org/ppm/bar.clj - org.ppm.foo
  src/org/ppm/baz.clj - org.ppm.foo

  With foo.clj using the ns :load for loading bar and baz.

  (ns org.ppm.foo
   (:load bar baz))

  This meets my needs well as the code is split in
  logical units while exposing the same namespace
  to the end user.

 You may want to take a look at 
 compojure.ns-utils/immigrate.http://github.com/weavejester/compojure/tree/master
 It just creates public vars pointing at all the public vars in the
 source namespace.

 -hume.
 --http://elhumidor.blogspot.com/

Thats a neat way to do it. Thanks for pointing it out.

Parth


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



exposing specific functions via namespace

2009-03-25 Thread Parth Malwankar

Hello,

I am trying to organise my code in namespaces and needed a
little help.

Basically I have created the following namespaces similar to
the following:

src/org/ppm/foo.clj - org.ppm.foo
src/org/ppm/foo/
src/org/ppm/foo/bar.clj - org.ppm.foo.bar
src/org/ppm/foo/baz.clj - org.ppm.foo.baz

foo.clj is an empty file which does nothing but
combines bar and baz:

== foo.clj ==
(ns org.ppm.foo
  (:use [org.ppm.foo bar baz]))

After having the jar in classpath, I create a simple
test.clj script that I load.

== test.clj ==
(use 'org.ppm.foo)
(bar-func)
(baz-func)

At this point, test.clj does not see the functions
defined in bar and baz.
Doing a (in-ns 'org.ppm.foo) before function calls
makes it work fine.

Is there a way to have foo.clj selectively (or all) expose
functions from bar and baz to the end user via foo namespace?

Do I need to put all exposed functions into foo.clj? I would
prefer to keep them in bar and baz if possible as those
are logical blocks for me.

Thanks.
Parth

--~--~-~--~~~---~--~~
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
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: file io

2009-03-24 Thread Parth Malwankar



e wrote:
 is there something as simple as this in clojure?

 whole python program:

 of = open(filename,w)
 of.write(hello)
 of.close()

 I checked the api and looked around the wiki and google quickly and saw how
 to use java's stuff to do it ... but, welll...


There are possibly other (better) ways to do it. One way is:
user= (use 'clojure.contrib.duck-streams)
nil
user= (with-open [f (writer (file test.txt))]
 (binding [*out* f]
   (println hello world !!!)))
nil
user=
% cat test.txt
hello world !!!
%

clojure.contrib.duck-stream has an interesting set of
functions.

Parth

 I noticed slurp in the api for reading ... but only the whole file at once
 (read() but no readline()).  Is there something symmetrical for writing
 (outputting)?  Is there a web page called File IO somewhere?

 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
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: file io

2009-03-24 Thread Parth



On Mar 24, 11:53 pm, e evier...@gmail.com wrote:
 does anyone else think that should be more fundamental like the python
 example?  imagine saying that out loud to your friend who asks . . . and the
 amount of noise, visually:

 use clojure dot contrib dot duck dash streams.

 perhaps it is already the hope that it will spit will eventually sit next
 to slurp?


This has come up before on the list.
I am not sure about where things stand with that though.

http://groups.google.com/group/clojure/browse_thread/thread/31f01808c225ecc1/d0e286fa0c8ef7d2
http://groups.google.com/group/clojure/browse_thread/thread/d8064dbb94c5cd2c/ba355cfe2c708068

I think it would be nice to have spit in the core, especially for
people like me who aren't too good with java. But having
clojure-contrib.duck-streams definately makes life easier :)

Parth

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



arbitrary partitioning of collection

2009-03-23 Thread Parth Malwankar

Hello,

I have a use case for reading binary data from a file
into a C equivalent structure. I read the binary date
into a byte array before processing.

I came up with a split-byte-array function for this:

(defn split-byte-array
  takes a byte-array and returns its various fields
  as a list of sequences. the length of each field in
  bytes is taken from the list lens
user= (split-byte-array (range 10) [3 2 2 3])
[(0 1 2) (3 4) (5 6) (7 8 9)]
 ([byte-array lens] (split-byte-array byte-array lens []))
 ([byte-array lens acc]
  (if (empty? lens) acc
(let [[s r] (split-at (first lens) byte-array)]
  (recur r (rest lens) (conj acc s))

As shown in documentation for the function, the
stream gets split up into 3 2 2 and 3 bytes in the
above case.

I was wondering if there is a better way to do this.
This reminds me of partition but that doesn't
support something like a vector of partition sizes.

This is a common use case for a handling a
binary dump of c structures.

Is there any better way to do it than above?
Is this a common enough case to have something
like (partition coll ns) in contrib or core?

Parth

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



dot and nums in keywords

2009-01-23 Thread Parth Malwankar

Hello,

As per the docs for keywords ( http://clojure.org/reader ), keywords
cannot contain '.'.

They cannot contain '.' or name classes.

However, the following works on the repl:

user= :..
:..
user= (keyword? :..)
true

Are '.'s allowed and the docs need updating? Or should
we see an exception?

Also, would a keyword with only numbers be a valid keyword?
e.g. :

Thanks.
Parth

--~--~-~--~~~---~--~~
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
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 encapsulate local state in closures

2008-12-22 Thread Parth Malwankar



On Dec 22, 12:25 pm, Mark Engelberg mark.engelb...@gmail.com
wrote:
 I misspoke; it's the call to counter that's the problem.  Let's say
 you want to use a counter to count the number of times a ref is set,
 something like this:

 (dosync (counter) (ref-set r 1))

 If your var-set causes the transaction to retry, an atom-based counter
 will increment twice.  As I understand it, atoms are one of the most
 dangerous things in Clojure, and should be avoided unless you're
 completely sure it will not change the semantics of your program if it
 gets executed multiple times.  Aside from the memoization example for
 which it was invented, I am hard-pressed to think of a good use for
 atoms.  For something like a counter, you really have to use ref, and
 that should remain people's default when dealing with mutability.

 I haven't done much with atoms yet, so if I've misunderstood Rich's
 posts, feel free to explain my mistake.

Thats a valid example. counter should not be used
in the dosync.

However, if the counter is meant for a single thread then one
way to use it would be:

... (counter) (dosync (ref-set r 1)) ...

Basically, as counter has side-effects it shouldn't be called
in dosync as stated in the docs ( http://clojure.org/refs )

To quote the docs:
7. I/O and other activities with side-effects should be avoided
in transactions, since transactions will be retried. The io!
macro can be used to prevent the use of an impure function
in a transaction.

End quote.

The above is a general rule so for e.g. we should not
have (dosync (println done setting) (ref-set r 1)). If my
understanding is correct, this should be:

... (println done setting) (dosync (ref-set r 1)) ...

If we want a counter to count events across
multiple threads, then yes, it would make sense to
use refs.

If I get it right, atoms are quite useful to maintain state
in the context of a single thread with memoization and
counter (within a thread) being two examples.

There may possibly be performance implications
for refs and atoms but I haven't really benchmarked it.

Parth


--~--~-~--~~~---~--~~
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
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 encapsulate local state in closures

2008-12-21 Thread Parth Malwankar



On Dec 21, 11:47 pm, chris cnuern...@gmail.com wrote:
 I would like to be able to encapsulate local state in a closure.
 Specifically, I would like a function that returns an incrementing
 integer, thus:
 (test_func)
 1
 (test_func)
 2
 What is the best way to go about this?  With local bindings is failing
 and I can't figure just why...


One way to do this would be to use atom.

(defn mk-counter [start]
  (let [n (atom start)]
(fn [] (swap! n inc

(def counter (mk-counter 0))

user= (counter)
1
user= (counter)
2
user= (counter)
3

Parth
 (def test_closure
            (with-local-vars [one 1]
              (fn [] (var-get one
 #'user/test_closure
 user (test_closure)
 ; Evaluation aborted.
 The var is null when I call the closure.

 Thanks,
 Chris
--~--~-~--~~~---~--~~
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
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.lang.Script

2008-12-21 Thread Parth Malwankar



On Dec 21, 8:21 pm, Emeka emekami...@gmail.com wrote:
  java -cp clojure.jar clojure.lang.Script yourapp.clj

 In my SciTe I added  java -cp clojure.jar clojure.lang.Script $(FilePath)
 plus others and when I click 'GO' or F5 instead of running the code and
 printing result. I have



  java -cp clojure.jar clojure.lang.Script C:\janus\myapp.clj

   exit 0

 No other thing comes out. So how do I cause it to print the result of the
 code I have written. It works in SciTe, however, it doesn't print result.
 Have you used clojure.Lang.Script with SciTe before?

If you are using the latest Clojure you can probably try:
java -cp clojure.jar clojure.main filename.clj

I haven't used SciTe but this is what I do in my clojure launch
script.

Parth


 Emeka.
--~--~-~--~~~---~--~~
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
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 encapsulate local state in closures

2008-12-21 Thread Parth Malwankar



On Dec 22, 5:24 am, Brian Doyle brianpdo...@gmail.com wrote:
 I haven't been following the new atom stuff, so I was wondering why atom
 would be best in this
 situation, vs a ref?  Thanks.

Rich discusses the use of atoms, refs and agents in good detail
in this thread:
http://groups.google.com/group/clojure/msg/fd0371eb7238e933

In case you don't want multiple counters but just one,
the following can also be done.

user= (let [n (atom 0)] (defn counter [] (swap! n inc)))
#'user/counter
user= (counter)
1
user= (counter)
2
user= (counter)
3

Parth



 On Sun, Dec 21, 2008 at 1:03 PM, Parth Malwankar
 parth.malwan...@gmail.comwrote:



  On Dec 21, 11:47 pm, chris cnuern...@gmail.com wrote:
   I would like to be able to encapsulate local state in a closure.
   Specifically, I would like a function that returns an incrementing
   integer, thus:
   (test_func)
   1
   (test_func)
   2
   What is the best way to go about this?  With local bindings is failing
   and I can't figure just why...

  One way to do this would be to use atom.

  (defn mk-counter [start]
   (let [n (atom start)]
     (fn [] (swap! n inc

  (def counter (mk-counter 0))

  user= (counter)
  1
  user= (counter)
  2
  user= (counter)
  3

  Parth
   (def test_closure
              (with-local-vars [one 1]
                (fn [] (var-get one
   #'user/test_closure
   user (test_closure)
   ; Evaluation aborted.
   The var is null when I call the closure.

   Thanks,
   Chris
--~--~-~--~~~---~--~~
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
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 encapsulate local state in closures

2008-12-21 Thread Parth Malwankar



On Dec 22, 5:45 am, Mark Engelberg mark.engelb...@gmail.com wrote:
 But if mk-counter is called twice because it's retried in part of a
 transaction, then you're in big trouble when you use atom.  Better to
 use a ref here.  atom needs to be reserved for the very few cases when
 retries don't matter (like a cache).

If I understand it right, as long as the counter is used
within a single thread and not across threads there shouldn't
be any issues. Same as a cache.

If the idea is to use one counter across multiple threads
then refs can be used.

I don't think I follow why mk-counter would be retried. There
is not reason for it to fail as it simply creates a new counter
and returns it and doesn't need to block or be blocked.

Parth



--~--~-~--~~~---~--~~
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
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: Noob question on strings.

2008-12-09 Thread Parth Malwankar



On Dec 9, 4:47 pm, Ant [EMAIL PROTECTED] wrote:
 Hi all,

 I've just started looking with interest at the language, and have
 decided to port some of my smaller programs and scripts to Clojure as
 a way of getting to know the language. I am stumbling over Strings at
 the moment, as I am trying to read a file. I have tried the following:

 user= C:\dev\java\clojure\clj-repl.bat
 )\n
 user= java.lang.Exception: Invalid token: C:
 java.lang.Exception: ReaderError:(8,1) Invalid token: C:
         at clojure.lang.LispReader.read(LispReader.java:164)
         at clojure.lang.Repl.main(Repl.java:68)
 Caused by: java.lang.Exception: Invalid token: C:
         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
         at clojure.lang.LispReader.read(LispReader.java:156)
         ... 1 more

 OK, so that didn't work. I read the docs on Strings:

 Strings - Enclosed in double quotes. May span multiple lines.
 Standard Java escape characters are supported.

 So next I tried, thinking it may be the backslashes that were the
 problem, and needed escaping:



  C:\\dev\\java\\clojure\\clj-repl.bat
 \n
 user= java.lang.Exception: Invalid token: C:

Seems to work for me (on Linux with svn HEAD):

user=  C:\\dev\\java\\clojure\\clj-repl.bat
C:\\dev\\java\\clojure\\clj-repl.bat
user=  C:/dev/java/clojure/clj-repl.bat
C:/dev/java/clojure/clj-repl.bat
user= C:
C:

What release are you using? I am assuming you are on
windows based on the string. Maybe you can try with the
latest svn sources.

Parth


 java.lang.Exception: ReaderError:(10,1) Invalid token: C:
         at clojure.lang.LispReader.read(LispReader.java:164)
         at clojure.lang.Repl.main(Repl.java:68)
 Caused by: java.lang.Exception: Invalid token: C:
         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
         at clojure.lang.LispReader.read(LispReader.java:156)
         ... 1 more

 Same error, and it seems to me that the double quoted string isn't
 being accepted as a string literal. I tried converting the path to
 forward slashes:

 java.lang.Exception: No such namespace: C:/dev/java/clojure
 clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:0: No such
 namespace: C:/dev/java/clojure
         at clojure.lang.Compiler.analyze(Compiler.java:3713)
         at clojure.lang.Compiler.analyze(Compiler.java:3671)
         at clojure.lang.Compiler.eval(Compiler.java:3895)
         at clojure.lang.Repl.main(Repl.java:75)
 Caused by: java.lang.Exception: No such namespace: C:/dev/java/clojure
         at clojure.lang.Compiler.resolveIn(Compiler.java:3998)
         at clojure.lang.Compiler.resolve(Compiler.java:3972)
         at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3955)
         at clojure.lang.Compiler.analyze(Compiler.java:3686)
         ... 3 more

 So it seems that this isn't being treated as a string at all! It
 thinks that the slashes are denoting a namespace. What am I missing
 here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: recur vs. lazy: establishing guidelines

2008-12-09 Thread Parth Malwankar



On Dec 9, 11:18 pm, Stuart Halloway [EMAIL PROTECTED] wrote:
 Hi all,

 I am working on the functional programming chapter for the book this  
 week, and I have been reviewing uses of loop/recur vs. lazy-cat/lazy-
 cons in Clojure to come up with some guidelines.

 Here is where I am: If your function creates/returns only atoms or  
 fixed size collections, loop/recur is fine. If it might return (or  
 internally create) variable/huge/infinite collections, use lazy-*.

 To make this more concrete: If you buy these guidelines, then butlast  
 is incorrect. If you point it at something huge it consumes all of  
 memory:

 (last (butlast (take 1 (iterate inc 0
 - java.lang.OutOfMemoryError: Java heap space

 A lazy version works just fine:

 (defn lazy-butlast [s]
    (if (rest s)
      (lazy-cons (first s) (allbutlast (rest s)))
      nil))

 (last (lazy-butlast (take 1 (iterate inc 0
 - 9998

 But I bet that isn't the whole story. What are the counterarguments in  
 favor of non-lazy butlast?

 Cheers,
 Stuart

I am assuming 'allbutlast' is 'lazy-butlast'.

Not really an in favor of butlast, but lazy-butlast also seems
much faster.

user= (time (last (butlast (take 100 (iterate inc 0)
Elapsed time: 2710.068764 msecs
98
user= (time (last (lazy-butlast (take 100 (iterate inc 0)
Elapsed time: 714.63721 msecs
98
user= (time (last (butlast (take 100 (iterate inc 0)
Elapsed time: 1832.329244 msecs
98
user= (time (last (lazy-butlast (take 100 (iterate inc 0)
Elapsed time: 710.971437 msecs
98
user= (time (last (butlast (take 100 (iterate inc 0)
Elapsed time: 1266.704242 msecs
98
user= (time (last (lazy-butlast (take 100 (iterate inc 0)
Elapsed time: 701.681986 msecs
98
user= (time (last (butlast (take 100 (iterate inc 0)
Elapsed time: 1712.931529 msecs
98
user= (time (last (lazy-butlast (take 100 (iterate inc 0)
Elapsed time: 694.106062 msecs
98
user=

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Running clojure-contrib.jar

2008-12-06 Thread Parth Malwankar



On Dec 7, 3:51 am, janus [EMAIL PROTECTED] wrote:
 All,

 It is my mistake, this is the error once again. Failed to load Main-
 Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar.
 I did what Shulz said , however , I still have the same problem.


Could you copy the error messages to the list? That would help
in understanding the error better.

Also, are you using the latest sources from the svn or the released
version? In there latest sources there are some enhancements to
the main (like adding -h, -e options etc.).

So, with the latest svn HEAD, the windows equivalent of the following
should work for you:

java -server -cp /home/parth/src/clojure/clojure.jar:/home/parth/src/
clojure-contrib/clojure-contrib.jar clojure.main

Note that on windows, apart from the path changes
 you would need to use ; instead of :.

Parth

 Emeka

 On Dec 6, 7:17 pm, Stuart Halloway [EMAIL PROTECTED] wrote:

  If you have a space between jar and ; that is a problem.

  Stuart

   Start by telling us precisely what you did to run clojure.

   I have the below in my batch file
   SET CLASSPATH=/clojure/clojure/clojure.jar
   /clojure/clojure/clojure-contrib.jar;\
   java clojure.lang.Repl

   To run means clicking batch file. I followed the instructiom from
   Clojure Programming Book.
   I got a message box with the Failed to load Main-Class manifest
   attribute from C;/clojure/
   clojure/clojure. On click ok, it opened the Repl.

   Emeka
   Also: Sometimes for things like this asking on the #clojure IRC  
   channel
   is more expedient, assuming it's a time of day when many people are
   around.

   Emeka

   Randall Schulz- Hide quoted text -

  - Show quoted text -
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: memory issue with nth

2008-12-06 Thread Parth Malwankar



On Dec 7, 11:18 am, Paul  Mooser [EMAIL PROTECTED] wrote:
 I also have this problem, unless I set my heap to be substantial -
 going up in increments of 128M, I need to have at least a 768M heap
 for this to not occur. That seems completely crazy, but the rest of
 you are saying you don't have this issue.

I am not seeing this problem. I set the heapsize down to 32M but
this still works.

[parth:~]% java -Xmx32M -cp /home/parth/src/clojure/clojure.jar
clojure.main
Clojure
user= (nth (repeatedly (fn [] 0)) 1000)
0
user= (.maxMemory (Runtime/getRuntime))
33357824
user= (nth (repeatedly (fn [] 0)) 1)
0
user= (System/getProperty java.version)
1.6.0_07
user=

This is on debian.

Parth


 Maybe it's time to start looking at what platforms we are running, and
 how much memory you have the JVM configured to use? If people have
 their heap set to be large enough, they might not realize this is
 happening, or if it is a bug on a subset of platforms, then that might
 explain it as well.

 I'm running on OS X Leopard, and I've tried both the 1.5 and 1.6 JVMs.
 I don't normally pass any non-standard memory size arguments to the VM
 unless I expect I'll need it for something I'm doing.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Atoms

2008-12-05 Thread Parth Malwankar



On Dec 5, 6:02 am, Rich Hickey [EMAIL PROTECTED] wrote:
 I've added a new reference type - atom.

 Docs here:

 http://clojure.org/atoms

 Feedback welcome,

 Rich

Are the following equivalent or is one recommended over
the other? The first (using atoms) is definitely more convenient
and less verbose.

user= (def a (ref {:a 1 :b 2 :c 3}))
#'user/a
user= (def a (atom {:a 1 :b 2 :c 3}))
#'user/a
user= (swap! a assoc  :a 5)
{:c 3, :b 2, :a 5}
user= a
#AtomicReference$IRef {:c 3, :b 2, :a 5}

OR

user= (def b (ref {:a 1 :b 2 :c 3}))
#'user/b
user= (dosync (ref-set b (assoc @b :a 5)))
{:c 3, :b 2, :a 5}
user= b
#Ref [EMAIL PROTECTED]
user= @b
{:c 3, :b 2, :a 5}
user=

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Serializing Clojure objects

2008-12-02 Thread Parth Malwankar



Tayssir John Gabbour wrote:
 Hi!

 How should I approach serialization? I made a little test function
 which serializes and deserializes Clojure objects. It works for
 strings, integers, symbols, LazilyPersistentVectors and.. oddly..
 PersistentHashMaps that have exactly one element. (My Clojure is about
 a month old.)


I am not much of a Java guy so this would be what I would do.
Clojure has reader syntax of its data structures (maps, vectors etc.)
so they can be easily written to a stream as test using write.

Reading it is equally simple:

user= (def a (with-in-str {:a 1 :b 2} (read)))
#'user/a
user= a
{:a 1, :b 2}
user=

So as long as your data has reader syntax its not too much
of an issue. If the data needs to be shared between languages
as highlighted by someone, you may consider using another
format like json or so.

If the data used java object it may not be serializable so
easily. Generally my approach is to stick to data structures
at Clojure level as it has reader syntax.

Parth


 But for other things, like keywords and most PersistentHashMaps, it
 throws NotSerializableException.

 My imagined possible solutions:

 * Implement Serializable for Clojure data -- but is it possible in a
   dynamic Hey I'll just write a new method! way?

 * Go into Clojure's source and implement Serializable to the Java
   classes.


 My end goal is using a nonrelational DB like Tokyo Cabinet or
 BerkeleyDB.

 Thanks,
 Tayssir


 PS: Here's my test code:

 (defn my-identity Copies obj through serialization and
 deserialization.
   [obj]
   (let [byte-out (new java.io.ByteArrayOutputStream)
 obj-out  (new java.io.ObjectOutputStream byte-out)]
 (try (.writeObject obj-out obj)
  (finally (.close obj-out)))
 (let [obj-in  (new java.io.ObjectInputStream
(new java.io.ByteArrayInputStream (.toByteArray
 byte-out)))]
   (try (.readObject obj-in)
(finally (.close obj-in))
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: NullPointer when just returning nil?

2008-11-29 Thread Parth Malwankar



On Nov 29, 5:29 pm, Ralf Bensmann [EMAIL PROTECTED]
wrote:
 Hi,

 is this the intended behavior?

 user= #(nil)
 java.lang.NullPointerException (NO_SOURCE_FILE:12)
 user= (def b #(nil))
 java.lang.NullPointerException (NO_SOURCE_FILE:13)


This is expected.
#(nil) is the same as (fn [] (nil)) and hence the failure.
(fn [] nil) is what you want.

 This works:
 user= #('nil)
 #user$eval__43$fn__45 [EMAIL PROTECTED]


I am not very clear on whats happening here to comment.

Parth

 Thanks,
 -Ralf
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: SVN or release?

2008-11-29 Thread Parth Malwankar



Kyle Schaffrick wrote:
 Hi all,

 I've been playing with Clojure for a few days now, following the mailing
 list, searching and tinkering, etc. I'm really excited about this
 language!

 I'm running the latest packaged release, and I'd like to start writing
 some more serious spikes in Clojure, but I'm starting to get the
 impression that I should be using the SVN version instead to get the
 latest hotness.

 I say this because I've noticed a few things here and there in 3rd party
 code and in the docs that are not working, it seems, because they depend
 on features/changes only present in SVN, such as the Java method call
 operators, and some namespace shuffling. Being a Vimmer, for example, I
 tried to set up Chimp and am getting a mysterious exception from the
 STM's innards when Vim tries to connect to Chimp's REPL listener.

 Is there a general recommendation here? Should I be on SVN or is this
 just my bad luck :)

I think Rich is working towards a 1.0.
For now I prefer to follow svn HEAD. Its best to check
the svn release log before using just in case there are any
intermediate checkins. These are typically marked
Interim checkin - DO NOT USE!! in the log.
I plan to stick to releases post 1.0.

Regarding Chimp, maybe you can try Gorilla:
http://groups.google.com/group/clojure/browse_thread/thread/c8b7bc3106c39791
I haven't used it personally yet.

Parth



 Thanks,
 -Kyle
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



File Copy

2008-11-23 Thread Parth Malwankar

Hello,

I am trying to translate the following Java
snippet into a file copy routine in Clojure.

  public static void copy(InputStream in, OutputStream out)throws
IOException {
byte[] buffer = new byte[1024];
while (true) {
  int bytesRead = in.read(buffer);
  if (bytesRead == -1) break;
  out.write(buffer, 0, bytesRead);
}
  }

I was barely able to start:

(defn copy [iname oname]
  (let [in (new FileInputStream iname)
out (new FileOutputStream oname)]
nil))

But now I am totally lost at the nil. I am not sure how to translate
the while loop.

I would appreciate any pointers on how to do this (or maybe a more
ideomatic
way).

Thanks.
Parth


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



printing *command-line-args*

2008-11-20 Thread Parth Malwankar

Hello,

I have a single line file (tmp.clj) where I am trying to
print *command-line-args*.
And I get an exception if I run it. I am not sure what I
am doing wrong here.

[parth:~]% cat tmp.clj
(prn *command-line-args*)

[parth:~]% clj tmp.clj hello world
nil
Exception in thread main java.io.FileNotFoundException: hello (No
such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.init(FileInputStream.java:106)
at java.io.FileInputStream.init(FileInputStream.java:66)
at clojure.lang.Compiler.loadFile(Compiler.java:4395)
at clojure.lang.Script.main(Script.java:65)

[parth:~]% clj tmp.clj
nil

I am using clojure from HEAD.
Any suggestions appreciated.

Thanks.
Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A value that equals everything, or, ignoring things in multi-dispatch

2008-11-15 Thread Parth Malwankar



On Nov 16, 12:36 am, samppi [EMAIL PROTECTED] wrote:
 Is there a way to get a value—call it 'anything—so that (isa? anything
 x) is always true for any x?

 I need this for multimethod dispatch—sometimes, I want a method to
 ignore some of the stuff its dispatch function returns:

   (defmulti a #(%1 %2))

   (defmethod a [3 2] [x y] ...)

   ; in this method, the second dispatch value is ignored and
   ; the method matches any call whose first argument is 5

   (defmethod a [5 anything] [x y] ...)

 I wish the _ symbol would do this, but it doesn't work (if practical,
 it'd be cool if it were implemented in the future :). Is there some
 sort of solution possible right now?

There could be some problem constraints I don't understand
here but maybe you could just use first (or some custom
function) to extract the relevant args

user= (defmulti a #(first [%1 %2]))
#'user/a
user= (defmethod a 3 [x y] :three)
#MultiFn [EMAIL PROTECTED]
user= (defmethod a 5 [x y] :five)
#MultiFn [EMAIL PROTECTED]
user= (a 3 4)
:three
user= (a 3 5)
:three
user= (a 5 5)
:five

Parth


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: iterate

2008-11-13 Thread Parth Malwankar



On Nov 13, 12:25 pm, notallama [EMAIL PROTECTED] wrote:
 i put this at the end of my boot.clj for added fun:

 (defn iterate
   returns a lazy seq of arg1, arg2 ... argn, (f arg1 ... argn), (f
 arg2 ... argn (f arg1 ... argn)), etc.
   [f  [x  rest :as all]]
   (lazy-cons x (apply iterate f (concat rest [(apply f all)]

 user= (take 10 (iterate + 1 1))
 (1 1 2 3 5 8 13 21 34 55)

 user= (take 4 (iterate #(* % %) 2))
 (2 4 16 256)

 is this good as a contrib? is there a better way to implement this?


There is already an iterate in Clojure.
Your implementation much have shadowed it.

user= (doc iterate)
-
clojure/iterate
([f x])
  Returns a lazy seq of x, (f x), (f (f x)) etc. f must be free of
side-effects
nil
user= (iterate #(+ 1 %) 1)
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29 3
0 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 ...)

But it doesn't take multiple arguments like your
implementation. Thats a nice enhancement.

Parth


 also, this language is delightful.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure.zip: replace error

2008-11-13 Thread Parth Malwankar

Hello,

While setting ns to clojure.zip, I get the following error:

user= (ns clojure.zip)
java.lang.IllegalStateException: replace already refers to:
#'clojure.zip/replace in namespace: clojure.zip (NO_SOURCE_FILE:0)
clojure.zip=

Is this expected?

Thanks.
Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Patch: callable defstruct (PersistentStructMap$Def extends AFn)

2008-11-06 Thread Parth Malwankar



On Nov 6, 9:19 am, Chouser [EMAIL PROTECTED] wrote:
 On Wed, Nov 5, 2008 at 12:10 AM, Chouser [EMAIL PROTECTED] wrote:
   The attached patch allows:

  user= (point 42 11)
  {:x 42, :y 11}


Seems like a very nice enhancement to me. It would make
the code more terse.

Parth


 The right tool for the job makes all the difference.  Attached is a
 much simpler patch to accomplish the same thing.

 --Chouser

  structmap-def-extends-restfn.patch
 1KViewDownload
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Files in Clojure Google Groups

2008-11-02 Thread Parth Malwankar



Rich Hickey wrote:
 On Oct 30, 3:57 pm, bc [EMAIL PROTECTED] wrote:
  Hi all,
 
  Is there any way to enter an annotation or comments when a file is
  uploaded to the Clojure Google Groups file area? I've recently had a
  look at a few things there and it would be nice to have some context
  or background on why they were uploaded. For example, tsp.zip is a
  Traveling Salesperson example but, unless you download it and look at
  the code, how would you know that? Another example is Clojure.png
  which has a nice graphical representation of the Clojure reader. Was
  this part of a documentation effort or was it uploaded as an example
  as part of a discussion (a search on Clojure.png in the group didn't
  produce any matches)? It would be nice to have some form of comments/
  annotations about the files.
 


 That's a good point. Unfortunately, it doesn't look like Google Groups
 supports any annotations on the files. Suggestions for alternatives
 welcome.

Recently I noticed that the vim_dev google group set up
the pages section to list patches and their summary.
http://groups.google.com/group/vim_dev/web/vim-patches

Maybe something like that can be used.

Parth


 Rich
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: lazy death

2008-10-25 Thread Parth Malwankar



On Oct 25, 4:55 pm, Timothy Pratley [EMAIL PROTECTED] wrote:
 When I screw up a lazy-cons (which happens quite a lot to me),
 my repl goes nuts and appears to corrupt the box it lives in. If I
 leave it running my monitor blanks out periodically... like some
 system register got reset. I can't break the cycle with ctrl-c.
 Here is a screenshot of the corruption 
 starting:http://groups.google.com/group/clojure/web/lazy-death.PNG

 I realise that this isn't a clojure problem (its doing what I told it
 to), more an environment issue.
 Currently Im using winXP cmd box to start the repl.
 Below is an example of how to reproduce:

 (defn lazy-death [x  more]
   (lazy-cons x (lazy-death more)))
 user= (lazy-death [1 2 3])
 ; fills the box with nil, then colors go wonky, then monitor may reset
 periodically

 ; I made a silly omission, can fix it easily:
 (defn lazy-death [x  more]
   (when x (lazy-cons x (lazy-death more
 user= (lazy-death [1 2 3])
 ([1 2 3])

 I guess maybe its just the windows cmd box floods the monitor somehow
 with the nils? Anyhow... is there any way to save me from myself in
 this scenario? I find when I'm working on a lazy-cons I spend most of

svn rev 1077 has a patch for *print-length* and *print-level*.
Discussed here: 
http://groups.google.com/group/clojure/browse_thread/thread/3664c80d9d45f2c7#

This handles the issue.

With:

(set! *print-length* 50)
(set! *print-level* 10)

I get:

user= (lazy-death [1 2 3])
([1 2 3] nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil ...)
user=

You would need to get the latest sources from svn for this to work.

Parth


 my time opening cmd boxes to replace the ones I've killed off :)

 What does work is invoking as a script... ie:
 edit foo.clj
 clj foo.clj
 ; here I can press ctrl-c and break from the loop, fix it and try
 again

 My prefered work flow is copy+pasting to a repl snipets from my main
 source.

 Regards,
 Tim.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: lazy death

2008-10-25 Thread Parth Malwankar



On Oct 25, 5:27 pm, Timothy Pratley [EMAIL PROTECTED] wrote:
  (set! *print-length* 50)

 Ah perfect. Thanks! Is there a way to make this default?

clojure.lang.Repl will run all the files listed before it goes to
the prompt. So I have my clj script updated to accept a
.cljrc.clj file that has my settings:

clj launch script -- start:
  #!/bin/bash

  BREAK_CHARS=(){}[],[EMAIL PROTECTED];:'|\\
  CLJRC=~/.cljrc.clj

  if [ $# -eq 0 ]; then
   rlwrap --remember -b $BREAK_CHARS -f /home/
parth/.clj_completions \
   java -server -cp $CLASSPATH clojure.lang.Repl $CLJRC
  else
   java -server -cp $CLASSPATH clojure.lang.Script $@
  fi

clj launch script -- end:

Note the $CLJRC above. On windows you should be able to
do something similar to the batch file you use for launching
clojure repl (clj.bat I assume from 
http://en.wikibooks.org/wiki/Clojure_Programming#Installation)
Note the I haven't used $CLJRC for clojure.lang.Script as I want
to run my scripts in a clean environment. You could use $CLJRC
with scripts also if you want to.

.cljrc.clj file -- start:
  (set! *print-length* 50)
  (set! *print-level* 10)

. cljrc.clj file -- end:

I then to use the .cljrc.clj file for any settings I want to
use across repls (including any convenience functions as
it just a regular clojure source file).

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Reader + Macros on untrusted S Expressions: Security considerations?

2008-10-22 Thread Parth Malwankar



On Oct 22, 3:42 pm, Parth Malwankar [EMAIL PROTECTED] wrote:
 On Oct 22, 1:30 pm, Brett Morgan [EMAIL PROTECTED] wrote:

 - Recently the #= reader macro was added. This makes the reader
   do the evaluation before using the value. You may want to
   disable this. E.g.

   user= #=(+ 1 1)
   2

   I am not sure how to disable this. There is a
   similar thing #. in CL and it is important to disable it before
   reading potentially unsafe expressions. Maybe Rich or someone
   else can comment on how to disable this.


Oops. The example I meant to give was:
user= `(+ 1 1)
(clojure/+ 1 1)
user= `#=(+ 1 1)
2

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



importing clojure.contrib.miglayout

2008-10-21 Thread Parth Malwankar

Hello,

I am trying to import clojure.contrib.miglayout. The simple import
seems to work fine, but the moment I use :require  it fails.
Am I doing something wrong here or is this a bug?
Seems to work for other modules like pred and command_line.

[parth:~]% clj
Clojure
user= (ns test (:refer-clojure) (:require clojure.contrib.miglayout))
java.lang.ClassNotFoundException: net.miginfocom.swing.MigLayout
(miglayout.clj:0)
test= (ns test (:refer-clojure) (:require clojure.contrib.pred))
nil
test= (import '(clojure.contrib.miglayout))
nil
test= (ns test (:refer-clojure) (:require
[clojure.contrib.miglayout :as miglayout]))
java.lang.ClassNotFoundException: net.miginfocom.swing.MigLayout
(miglayout.clj:0)
test=

Parth


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Suggestions on handling state for a game...

2008-10-20 Thread Parth Malwankar



On Oct 20, 1:38 am, Adam Jones [EMAIL PROTECTED] wrote:
 I'm starting up work again on my Clojure-based game. Up until this
 point I've been doing things the dirty way by re-defing a bunch of
 global variables and/or storing the values in the Java objects I need
 to use to get access to the game framework.

 This approach is pretty unwieldy, and means I miss out on a lot of the
 cool things Clojure has to offer. So, I need to figure out how to
 handle state from within Clojure. The two ideas that I think will work
 are:

 1. Store the game world as a var, and have the game structured as a
 function from the game world to the game world. Since I need to pass
 control back to Java to handle a lot of the details this would require
 me to store the game world in Java between updates.

 2. Store the game world as a ref and use the facilities of that to
 modify the game state on updates. This seems cleaner in that it can
 all be handled without resorting to Java for intermediary storage. I
 am concerned that using the STM system would add too much performance
 overhead.


Hi Adam,

In such a scenario, I would probably go with option (2) that
you outlined. A good example is available here:
http://en.wikibooks.org/wiki/Clojure_Programming#Mutation_Facilities

The approach would be to define your game as a clojure
namespace with pure functions that take the entire game state
and return the update state. This will make the functions
and the game easier to test and debug. (corresponding to
the private functions update-role and delete-by-name in the
employee example above).

There can be a thin wrapper (your main application) that
manages state using refs and the library functions defined
 above (corresponding to update-employee-role and
 delete-employee-by-name in the employee example).

The main game loop can probably be built around the
wrapper functions that work with refs to handle state.

 I guess what this all comes down to is, between vars and refs, which
 one is the better choice for a program that I don't think will really
 need multithreading?

Even if the program does not need multi-threading it
would be nicer (and easier) to go with refs and pure functions. The
reason being that it would be easier to test and debug
you code. Also, should a need come to make it multi-threaded
at a later date, that would be a trivial change in your code.
Note that the employee example doesn't use threads.

I think the re-defing approach is ok for simple experiments
on the REPL but would make programs more difficult to
maintain as they grow in size.

Performance should really be a problem with refs. A good
essay by Rich on Clojures approach to state is
http://clojure.org/state

Parth


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on the use of functional hash maps

2008-10-20 Thread Parth Malwankar



On Oct 20, 6:16 am, Tom Emerson [EMAIL PROTECTED] wrote:
 Hi all,

 I have a somewhat embarassing newbie question on the use of hash maps
 in a functional environment.

 Consider a little utility that counts the number of unique words in a
 file. A hash map mapping strings to integers is the obvious data
 structure for this, but the fact that (assoc) returns a new map each
 time it is called is tripping me up: since I can't define a 'global'
 hash map to accumulate the counts, do you pass one around in a
 function? or do you structure the code a different way? This is a
 difference from what I would do in Common Lisp, where I would just
 have a global that is used for the collection.

The word count program already mentioned in this thread is
nice.

If you do need to maintain state, this thread has some pointers:
http://groups.google.com/group/clojure/browse_thread/thread/a60b20955ad47fca

Parth


 Thanks in advance for your wisdom.

     -tree

 --
 Tom Emerson
 [EMAIL PROTECTED]://www.dreamersrealm.net/~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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Multiple return values

2008-10-20 Thread Parth Malwankar



On Oct 20, 3:51 pm, Fredrik Appelberg [EMAIL PROTECTED]
wrote:
 Hi all,

 The CL feature for handling multiple return values from a function come in
 really handy sometimes and make for cleaner APIs. For example, the ROUND
 function returns the integer part of a float as the regular value (as this
 is what you want most of the time), but optionally also returns the floating
 point part in case you want it.

 I haven't found anything like MULTIPLE-VALUE-BIND in Clojure. Are there any
 plans of incorporating any kind of mechanism for multiple return values?

Hi Fredrik,

Similar results can be accomplished using vectors and
destructuring in Clojure.

user= (defn foo [] [:one :two :three])
#=(var user/foo)
user= (let [[a b c] (foo)] (println b))
:two
nil
user=

The destructuring capabilities of let are quite nice.
A bunch of examples are available in the let reference:
http://clojure.org/special_forms

Parth


 Cheers,
 -- Fredrik
 ==
 What am I up to?http://twitter.com/appelberg
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Fibonacci function performance compare between clojure and scala

2008-10-19 Thread Parth Malwankar



On Oct 19, 7:49 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Clojure's

 (defn fib [n]
(if  (or (zero? n) (= n 1))
1
   (+  (fib (dec n) )  (fib (- n 2)

 (time (fib 36))

 Elapsed Time:  10475.325226 msecs
 24157817

 Scala's

 def fib(n:Int):Int=if (n==0||n==1)1 else fib(n-1)+fib(n-2)
 def time(cal: =Int)={
  val beginTime=System.currentTimeMillis
  cal
  val endTime=System.currentTimeMillis
  println(endTime-beginTime)}

 fib(36)
 res70:Int=24157817
 time(fib(36))
 263


I am not a scala expert but I suspect scala Int maps directly to
java ints.

In clojure, the number are boxed and checked by default IIRC.
This would roughly correspond to BigInt in scala.

For clojure, you could coerce ints to native java types using
(int ..).
Also, unchecked-dec could be used.
Doing this should make the code as fast as java or scala.
There was some discussion along these lines here:
http://groups.google.com/group/clojure/browse_thread/thread/4274ce8bd44664ef#

That said, for most practical uses the default behavior
should be fast enough. Its not considered idiomatic to
use coersion and unchecked operation unless absolutely
necessary.

Parth


 Both not tail recursive,both running on Repl (scala's interpreter),but
 the difference between two is huge
 10475~263
 My box : Intel core2 cpu 1.86G,2G mem
 Clojure and scala both latest build from svn

 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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-10-17 Thread Parth Malwankar



On Oct 17, 2:27 pm, Rastislav Kassak [EMAIL PROTECTED] wrote:
 Hello Clojurians,

 I think after 1st year of Clojure life it's good to check how far has
 Clojure spread all over the world.

 So wherever are you come from, be proud and say it.

 I'm from Slovakia. :)

 RK

Bangalore, India.


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: toUpperCase on java.lang.String

2008-10-16 Thread Parth Malwankar



On Oct 16, 4:29 pm, Rich Hickey [EMAIL PROTECTED] wrote:
 On Oct 15, 11:47 pm, Stephen C. Gilardi [EMAIL PROTECTED] wrote:



  Hi Parth,

   But if I do this in a doto, it doesn't seem to work but
   I don't get any error message.

   user= (doto (new java.lang.String hello) (toUpperCase))
   hello
   user= (class (new java.lang.String))
   #=java.lang.String

   Shouldn't this be working? If this is (by design) because strings are
   immutable (so no doto) shouldn't there be an error message?

   What am I missing here.

  doto operates on an object and returns the object that it operated
  on. In your case, it's the original string that gets returned. Strings
  are immutable so the toUpperCase call created a new string which was
  then thrown away.

  The - operator will accomplish what you're looking for here. It
  returns the result of the operations, each result becoming the input
  for the next::

  user= (- (String. hello) .toUpperCase)
  HELLO

 Another semantic marker here is 'do'. do in Clojure implies side-
 effects. Since you can't uppercase a string by side effect, doto isn't
 the right tool for this job.

 doto can't throw an error here or elsewhere when used on an immutable
 object because:

 a) It can't generally know which objects are immutable
 b) Even immutable objects may have methods with other side-effects

 Rich

That makes sense. Thanks everyone for all the help.

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure's first year

2008-10-16 Thread Parth Malwankar



On Oct 16, 9:36 pm, Rich Hickey [EMAIL PROTECTED] wrote:
 A year ago today I 'released' Clojure, by sending a message to my jFli
 and Foil mailing lists. It got blogged, picked up by Planet Lisp and
 redditted in the course of a day or so, and has been a wild ride ever
 since. I couldn't have possibly imagined the year Clojure (and I) have
 had.

 Community

 Releasing a language means hoping others will use it, and I truly
 appreciate the risks taken by those very first users, trying Clojure
 of their own interest and initiative with no recommendations or
 testimonials. I've tried to repay that interest with support and
 explanations, bug fixes and enhancements. Most satisfying has been
 seeing a community grow, and gain a collective experience it can
 share. We're now at 650 members on the Google Group, and have had over
 4500 message over the year, 500 messages in the first half of October
 alone! Even better, only 15% of those messages were mine (down from
 50% in the early days). There are newcomers kicking the tires, people
 who've spent enough time to know their way around, and those who,
 through their extended experience, really 'get' the model behind
 Clojure, and have developed idiomatic sensibilities. In addition, it's
 a diverse community, including some Java experts, and some Lisp
 experts, with experience in a wide variety of domains, all of which is
 being shared too.

 The discourse and attitude has been consistently positive and
 supportive, and Clojure has benefitted tremendously from the feedback
 and suggestions of the user community.

 Contributors

 Releasing something as open source means hoping that, eventually,
 giving something away will yield returns of contributions that will
 allow your project to grow in ways you couldn't achieve alone. I'm
 happy to see that starting now, as people get familiar enough with how
 Clojure works to make tangible contributions.

 A substantial source of contributions that don't end up in Clojure
 itself are on the tools side. People have built editor support for
 emacs and vim, the enclojure IDE for Netbeans, swank/slime etc. Other
 contributions take the form of additions to the wiki, tutorial blogs,
 and answering questions on the group and IRC.

 Awareness

 Clojure has gotten a lot of attention - I've been invited to give
 talks at the Dynamic Languages Symposium at ECOOP, the European Lisp
 Workshop, IBM Research, the JVM Languages Summit, Boston Lisp, and
 next week at Lisp 50 at OOPSLA. There has been a lot of blogging,
 which continues to grow. Clojure has made its presence felt in both
 the Lisp and JVM communities it bridges, which have very little
 overlap otherwise. The feedback has been overwhelmingly positive.

 The Language

 I've done almost 600 checkins in the past year. Many were small bug
 fixes and enhancements, others were significant features like first-
 class namespaces, in-source docs, gen-class and proxy, primitives
 support, ad hoc hierarchies, destructuring, list comprehensions, var
 metadata, regex support, zippers, first-class sets, agents, struct
 maps, java.util integration, parallel support, etc. All of this
 happened in a context of considerable stability and robustness, which
 is a testament to the Lisp model of using a small core, with most of
 the language provided by independent functions and macros.

 Moving Forward

 The net result is that the prospects for Clojure going forward are
 very good. The core model of Clojure has held up well and continues to
 appeal - accessible, robust, thread-safe, efficient dynamic functional
 programming, on a world-class infrastructure, with a huge set of
 libraries. Oh yeah, and it's great fun!

 People coming to Clojure now find a vibrant community, plenty of
 support, a variety of tools and more on the way, a wiki and blogs full
 of examples, a book on the way, many online screencasts and talks, a
 huge message archive etc. The language itself continues to grow in
 capabilities while remaining stable, and the growing pool of
 contributors promises more hands in pursuing bug fixes and new
 features. There's still more to do, but more people to do it as well.

 I designed and built Clojure so that I could pursue the next 20 years
 of my career in a language I wouldn't mind thinking in. In order to be
 commercially accepted, a language needs to be technically viable and
 have wide enough awareness and use. I think Clojure has great
 prospects in both of those areas, as it continues to improve and usage
 grows.

 Thanks to all for being part of Clojure!

 On to year two,

 Rich

Congrats to Rich and the Clojure community. I know I keep
trying to find reasons to use Clojure every day rather than
something else. It a very enjoyable experience :)

Parth

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

Re: primitive meta data

2008-10-15 Thread Parth Malwankar



On Oct 15, 8:34 am, Islon [EMAIL PROTECTED] wrote:
 Hi.

 I've made a dumb (very dumb) performance comparison function just to play
 with the language.
 I wanted to mark some symbols with a float primitive type but the compiler
 complained so I had to annotate it with the Float class.
 Here is the function:

 (defn dumb-test []
   (let [#^Float f2 567.09723]
     (loop [#^Float f 1.8, i 1000]
       (if (zero? i)
         f
         (recur (/ f f2) (dec i))

 And the test:

 (loop [i 50]
   (time (dumb-test))
   (if (zero? i)
     i
     (recur (dec i

 There's a way to put a float primitive type in the metadata to prevent the
 Float - float unboxing?
 Feel free to point some mistakes I probably made, I've just started learn
 clojure.


 The clojure version took an average: Elapsed time: 217.833342 msecs in my
 machine.

The following was somewhat faster.

(defn dumb-test []
  (let [f2 (float 567.09723)]
(loop [f (float 1.2), i (long 1000)]
  (if (zero? i)
f
(recur (/ f f2) (dec i))

I get about 59ms on my machine.
user= (time (dumb-test))
Elapsed time: 59.245176 msecs
0.0

Parth




 The java version (below) took average 23 msecs:

 private static float dumbTest() {
         float f = 1.8f;
         float f2 = 567.09723f;
         for(int i = 0; i  1000; i++) {
             f /= f2;
         }
         return f;
     }

 Regards.
 Islon
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



toUpperCase on java.lang.String

2008-10-15 Thread Parth Malwankar

Calling a java method on a string directly works.

user= (.toUpperCase hello)
HELLO
user= (class hello)
#=java.lang.String

But if I do this in a doto, it doesn't seem to work but
I don't get any error message.

user= (doto (new java.lang.String hello) (toUpperCase))
hello
user= (class (new java.lang.String))
#=java.lang.String

Shouldn't this be working? If this is (by design) because strings are
immutable (so no doto) shouldn't there be an error message?

What am I missing here.

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What reasoner?

2008-10-06 Thread Parth Malwankar



Josip Gracin wrote:
 Hi!

 Rich, in the Boston talk you mentioned that you're considering some
 kind of a reasoner (if I understood correctly) for working with
 databases.  You also mentioned a project whose name sounded like ios
 reasoner.  I can't find references on anything spelled ios
 reasoner.  Could you tell me the actual name of the project.  Thanks!

I think it was the iris-reasoner datalog, also mentioned on
IRC here:
http://clojure-log.n01se.net/date/2008-10-02.html#14:45

http://iris-reasoner.org/

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Debian package for clojure

2008-09-12 Thread Parth Malwankar



On Sep 11, 6:22 pm, Paul Stadig [EMAIL PROTECTED] wrote:
 I have created a debian package for clojure. I've basically packaged
 up the JAR with the bin script 
 fromhttp://github.com/jochu/clojure-extra/tree/master. It's still a
 work-in-progress, but if there are any debian users out there, I'd
 like feedback. To install the debian package you need to first add the
 following line to your apt sources:

 debhttp://ppa.launchpad.net/pjstadig/ubuntuhardy main

 Then just do an apt update and sudo apt-get install clojure and it
 should work for you (*fingers crossed*).  You can find my GPG key out
 in the ether ([EMAIL PROTECTED]) to verify the installation, whether
 you *trust* me is another issue (Who is this guy?!). ;) This deb was
 actually built on Ubuntu. I think it'll work on any debian based
 distribution, but I'm a newb at this, so please send me your feedback.

 This project raises (at least) two issues:

 1. How can we get this into the standard debian distribution? It is my
 understanding that someone has to be (or become) an official debian
 developer to get it into the distribution. I'm willing to pursue that
 unless someone else is already there.

 2. How should this be maintained/expanded? I am willing to contribute
 the debian build files back to clojure (it just adds a debian
 directory with some files in it). However, some of the things that are
 part of the debian build should probably be integrated into the main
 project and build file (man pages, bin scripts, etc.), because there
 may be other distributions that could reuse some of those files.
 Additionally, this could all be expanded to include bin scripts and
 such for Windows, too. If we're not going to merge this back into the
 main source (or if we don't want to do it yet), I could setup a GitHub
 project to maintain the debian build system separately.

 Any thoughts on all this?


Hi Paul,

As a debian user I really like the idea for having a Clojure deb.
This is generally my preferred method for installing software on
debian
and was the first thing I looked for.

Regarding, 2, as already mentioned by you it would be nice
if the clj script + some man pages could go in. It would definitely
make life easier, especially for new user.

Perhaps, Rich can comment on rolling some of these into
the trunk.

Can rlwrap be marked as a deb package dependency for clj script?
this will ensure that the base interactive shell installation works
with
tab-completion and stuff.

Currently, I use Clojure from svn as it gets me the latest
and greatest feature set :)

Are you planning to pull from svn at a certain frequency
(1 a fortnight?) or to stick to the official releases? I suppose
once Clojure goes 1.0, at that point you could stick to the
latest stable release.

Maybe we could have the following packages:
clojure
clojure-doc
  - this could be txt files generated from the deb release
clj-vim
 - VimClojure
clj-emacs
 - emacs + slime stuff

My 2c.

Thanks for this.
Parth




 Paul
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: local functions?

2008-09-11 Thread Parth Malwankar



On Sep 11, 3:01 am, Allen Rohner [EMAIL PROTECTED] wrote:
  For very short functions one can use the cut notation: #(...). In case
  there are several functions or functions going over several lines, this
  is a sign that they should go into an own defn(-) with appropriate
  docstring.

 Maybe the solution is to use defn-. Scheme made me used to the local
 function approach for encapsulation. I don't have a problem with doing

 (defn foo [x]
     (defn bar [y]
 )
     (defn baz [z])
     (do_stuff (bar[x]))

 except that the interior defns are public.

I like the idea. defn- would also work like this but that won't
prevent bar
and baz from being used inside the package itself.

(let [foo (fn [x]
...)]
   (foo 42))

Does tend to get a little ugly if fn grows more than a line or two.
Not sure how it can be done though.

Parth



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



generating clj docs

2008-08-30 Thread Parth Malwankar

Hello,

I have uploaded a script gen-clj-docs.clj in the file area
that goes through all the clojure and clojure-contrib
modules and dumps out the latest docs from
sources as txt files. It leverages clojure.contrib.ns-utils
for this (thanks!).

Thought that some people might find this useful.
http://groups.google.com/group/clojure/web/gen-clj-docs.clj

Note that its best to run this in a separate folder
as it creates 1 txt file for each ns.

Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: updating nested structure

2008-08-28 Thread Parth Malwankar



On Aug 28, 8:13 am, Chouser [EMAIL PROTECTED] wrote:
 On Wed, Aug 27, 2008 at 10:37 PM, Parth Malwankar

 [EMAIL PROTECTED] wrote:
  In case the access path were vectors the above could become:

  (mk-get my-fridge (item-path :mango) :quantity)
  (mk-assoc my-fridge (item-path :mango) :quantity new-quantity)

  Much less noise.

 apply actually can do the conj'ing for you:

 (apply mk-get my-fridge (item-path :mango) :quantity)

I get an error with this.

user= (item-path :mango)
[:fruits :mango]
user= (apply mk-get my-fridge (item-path :mango) :quantity)
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Keyword : :quantity
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Keyword : :quantity
at clojure.lang.RT.seqFrom(RT.java:461)
at clojure.lang.RT.seq(RT.java:444)
at clojure.seq__28.invoke(boot.clj:92)
at clojure.spread__132.invoke(boot.clj:357)
at clojure.spread__132.invoke(boot.clj:358)
at clojure.spread__132.invoke(boot.clj:358)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at user.eval__2237.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3847)
at clojure.lang.Repl.main(Repl.java:75)
user= (apply mk-get my-fridge (conj (item-path :mango) :quantity))
30

Is this supposed to work? If it does it will be very convenient.

Parth


 --Chouser
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: updating nested structure

2008-08-28 Thread Parth Malwankar



On Aug 28, 8:08 pm, Rich Hickey [EMAIL PROTECTED] wrote:
 On Aug 27, 10:37 pm, Parth Malwankar [EMAIL PROTECTED]
 wrote:



  On Aug 28, 12:10 am, Rich Hickey [EMAIL PROTECTED] wrote:

   I posted a variant here:

  http://paste.lisp.org/display/65964

  Rich,

  It works very nicely. Thanks.

  Just one thought in case the functions args are still being
  decided on. Could we consider taking access path as a
  vector rather than directly as function args.

  Here is the use case I have in mind.

  I think most access paths [:a :b :c] would be generated.
  Nested structures would be something like

  processor - GPRs (general purpose regs) - r0 r1 .. rN
            -  FPRs (floating point regs) - f0 f1 .. fN

  fridge - fruits - apple mango ...
         - veggies - eggplant ...
         - diary - milk yoghurt ...

  So the developer may set up something like a
  (fridge-item-path (get-fruit)) = [:fruits :apple]
  (processor-reg-path (get-reg-arg-from-instruction)) = [:gpr-set :r0]

  With the current arg handling this is what we would need to do:

  user= (item-path :mango)
  [:fruits :mango]

  user= (apply mk-get my-fridge (conj (item-path :mango) :quantity))
  30

  user= (apply mk-assoc my-fridge (conj (item-path :mango) :quantity
  40))
  {:fruits {:mango {:quantity 40, :color :yellow},
            :apple {:quantity 20, :color :red}},
    :diary-products {:milk {:quantity 1, :color :white,
                            :type :low-fat},
                     :yoghurt {:quantity 10, :color :pink,
                               :type :strawberry}}}

  [formatting added above for readability]

  In case the access path were vectors the above could become:

  (mk-get my-fridge (item-path :mango) :quantity)
  (mk-assoc my-fridge (item-path :mango) :quantity new-quantity)

  Much less noise.

 I don't see this (partial path + separate last key) as a general way
 of doing things. The only other way I would consider is the entire
 path as a sequence:

 (defn mk-get [m ks]
   (reduce get m ks))

 (defn mk-assoc [m [k  ks] v]
   (if ks
     (assoc m k (mk-assoc (get m k) ks v))
     (assoc m k v)))

 ;usage
 (def nx {:a {:b {:c {:content [1 10] :other 2)

 (mk-get nx [:a :b :c :content])
 - [1 10]

 (mk-assoc nx [:a :b :c :content 0] 42)
 - {:a {:b {:c {:other 2, :content [42 10]

 (mk-assoc {} [:a :b :x] 42)
 - {:a {:b {:x 42}}}


Thanks Rich.
Sounds like a good idea to me. Works beautifully.

user= (load-file fruits.clj)
#'user/my-fridge
user= (mk-get my-fridge (item-quantity-path :mango))
30
user= (mk-assoc my-fridge (item-quantity-path :mango) 50)
{:fruits {:mango {:quantity 50, :color :yellow}, :apple {:quantity
20, :color :red}}, :diary-products {:yoghurt {:quantity
10, :color :pink, :type :strawberry}, :milk {:quantity
1, :color :white, :type :low-fat}}}
user=

Parth

 Rich
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: updating nested structure

2008-08-27 Thread Parth Malwankar



On Aug 28, 12:10 am, Rich Hickey [EMAIL PROTECTED] wrote:

 I posted a variant here:

 http://paste.lisp.org/display/65964


Rich,

It works very nicely. Thanks.

Just one thought in case the functions args are still being
decided on. Could we consider taking access path as a
vector rather than directly as function args.

Here is the use case I have in mind.

I think most access paths [:a :b :c] would be generated.
Nested structures would be something like

processor - GPRs (general purpose regs) - r0 r1 .. rN
  -  FPRs (floating point regs) - f0 f1 .. fN

fridge - fruits - apple mango ...
   - veggies - eggplant ...
   - diary - milk yoghurt ...

So the developer may set up something like a
(fridge-item-path (get-fruit)) = [:fruits :apple]
(processor-reg-path (get-reg-arg-from-instruction)) = [:gpr-set :r0]

With the current arg handling this is what we would need to do:

user= (item-path :mango)
[:fruits :mango]

user= (apply mk-get my-fridge (conj (item-path :mango) :quantity))
30

user= (apply mk-assoc my-fridge (conj (item-path :mango) :quantity
40))
{:fruits {:mango {:quantity 40, :color :yellow},
  :apple {:quantity 20, :color :red}},
  :diary-products {:milk {:quantity 1, :color :white,
  :type :low-fat},
   :yoghurt {:quantity 10, :color :pink,
 :type :strawberry}}}

[formatting added above for readability]

In case the access path were vectors the above could become:

(mk-get my-fridge (item-path :mango) :quantity)
(mk-assoc my-fridge (item-path :mango) :quantity new-quantity)

Much less noise.

Its not a big deal as the user would probably be writing a layer
on top of mk-get/mk-assoc e.g. fridge-add-item fridge-check-item
but then with access-paths as vectors it usage will be cleaner.

If you think this is a common enough case it could be considered.

Also, thanks for the [m [k  ks] v] destructuring trick. I didn't know
we could do that. Very neat.

Thanks very much.
Parth

 Rich
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



updating nested structure

2008-08-26 Thread Parth Malwankar

Hello,

In order to update fields in nested structures/maps easily
I have created a macro 'field-write'.
(defmacro field-write [st k v access-spec]
  ; st=data, k=key to update, v=val to put, access-spec=access
vector
  ; ... code listing after interaction

user= nx
{:a {:b {:c {:content 10
user= (field-write nx :content 1000 [:a :b :c])
{:a {:b {:c {:content 1000
user= (macroexpand '(field-write nx :content 1000 [:a :b :c]))
(clojure/assoc
  nx :a
  (clojure/assoc
(clojure/- nx :a) :b
(clojure/assoc
  (clojure/- nx :a :b) :c
  (clojure/assoc
(clojure/- nx :a :b :c):content 1000

[formatting added above for readability]

It seems to be working fine but I thought it may be
good to get inputs from the Clojure experts here to
see if there is a better way to do this in Clojure.

(def nx {:a {:b {:c {:content 10)

(def field-write)
(defmacro field-write [st k v access-spec]
  ; st=data, k=key to update, v=val to put, access-spec=access
vector
  (if (pred/empty? access-spec)
`(assoc ~st ~k ~v)
(field-write st (last access-spec)
 `(assoc (- ~st [EMAIL PROTECTED]) ~k ~v)
 (butlast access-spec

Thanks.
Parth

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



path: some more error info for Don't know how to create ISeq from...

2008-08-26 Thread Parth Malwankar

Hello,

Attached is a patch to give a little more information
for java.lang.IllegalArgumentException: Don't know how
to create ISeq from: error.

The current behavior is:
user= (map identity 1)
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Integer
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Integer
. snipped 

with patch:
user= (map identity 1)
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Integer : 1
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Integer : 1
 snipped 

I found it a helpful to understand macro expansion errors
better:

user= (macroexpand '(field-write-priv x :c 20 (vector :a :b)))
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Symbol : G__2867
java.lang.RuntimeException: java.lang.IllegalArgumentException:
Don't know how to create ISeq from: Symbol : G__2867
at clojure.lang.LazyCons.rest(LazyCons.java:63)
at clojure.lang.RT.printInnerSeq(RT.java:1320)
... snipped ..
at clojure.lang.RT.print(RT.java:1173)
at clojure.lang.Repl.main(Repl.java:76)
Caused by: java.lang.IllegalArgumentException: Don't know how to
create ISeq from: Symbol : G__2867
at clojure.lang.RT.seqFrom(RT.java:461)
... snipped ..
at clojure.lang.LazyCons.rest(LazyCons.java:59)
... 11 more
(let* [G__2867 (vector :a :b)] (if (clojure.contrib.pred/empty?
G__2867) (clojure/list (quote clojure/assoc) x :c 20) (user/field-
write-priv x (clojure/last G__2867) (clojure/list (quote clojure/
assoc) (clojure/- xuser= java.lang.IllegalArgumentException:
Don't know how to create ISeq from: Symbol : G__2716

I am not a Java or Clojure expert so there may be a
better way to do this.  Patch follows.

Parth


[parth:~/src/clojure/src/jvm/clojure/lang]% svn update
At revision 1006.
[parth:~/src/clojure/src/jvm/clojure/lang]% svn diff RT.java
Index: RT.java
===
--- RT.java (revision 1006)
+++ RT.java (working copy)
@@ -458,7 +458,7 @@
 // else if(coll instanceof Enumeration)
 // return EnumerationSeq.create(((Enumeration) coll));
else
-   throw new IllegalArgumentException(Don't know how to
create ISeq from:  + coll.getClass().getSimpleName());
+   throw new IllegalArgumentException(Don't know how to
create ISeq from:  + coll.getClass().getSimpleName() +  :  +
coll.toString());
 }

 static public ISeq keys(Object coll){
[parth:~/src/clojure/src/jvm/clojure/lang]%

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---