Re: introspecting types and records

2010-06-08 Thread ataggart
The field names and order in the constructor will always match the
values specified in deftype (excepting certain character issues, such
as turning a dash into an underscore).

Introspecting is easy enough:

user= (deftype foo [bar baz])
user.foo
user= (map #(.getName %) (.getDeclaredFields foo))
(bar baz)

Though defrecord emits quite a few more fields beyond what was
specified.


On Jun 7, 3:55 pm, Chris Kent cjk...@gmail.com wrote:
 Hi

 Is there a way to introspect types defined with deftype and
 defrecord?  I'd just like to know the field names and their order in
 the constructor.  Java reflection works fine but requires some
 fiddling around to filter the static fields and __meta and __extmap.
 It feels like something that someone has probably aready done.

 Also, is it safe to rely on the order the fields are returned from the
 class?  They are in the same order as in defrecord and the constructor
 but I'm not sure if this by design or an implementation detail of my
 particular JVM.

 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lein deps failure

2010-06-08 Thread Brian Troutwine
Indeed. This was a helpful resource, for those in the future that face
a similar issue and are not familiar with Java packaging:

http://github.com/technomancy/leiningen/blob/master/INTRO.md

On Mon, Jun 7, 2010 at 3:20 PM, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 07.06.2010 um 21:20 schrieb Brian Troutwine:

 Why does this work?
 change [org.clojure/swank-clojure 1.2.1] = [swank-clojure 1.2.1]

 Each dependency has a group and an artifact name. org.clojure/swank-clojure 
 means group org.clojure and artifact swank-clojure. swank-clojure is a 
 short hand notation for swank-clojure/swank-clojure.

 So it works,  because you look in the right place. ;)

 Sincerely
 Meikel

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


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


Broken Link in Clojure Contrib Docs

2010-06-08 Thread Daniel Glauser
Hello all,

Not sure where to report this but I noticed a broken link when taking
a look at the docs for sql in Clojure Contrib.

http://richhickey.github.com/clojure-contrib/sql-api.html

The link for Example code points here:

http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/sql/test.clj

Which is no longer around.  If I'm reporting this in the wrong place
then please let me know and I'll move the post.

Cheers,
Daniel

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


Re: Complex type in clojure

2010-06-08 Thread Daniel
These notation arguments are compelling.

On Jun 5, 8:17 pm, Travis Hoffman travis.a.hoff...@gmail.com wrote:
 Konrad,

  Thanks, I'll look at that...

 I should warn that my changes don't quite seem to be working, there's
 something running amuck in the code yet that I'm still working on
 debugging, but the core is a bit mystifying.

   Also, it seems more elegant to me to be able to simply write a complex
   number in a natural way i.e. 5+3i. I didn't see a way to do that
   without modifying clojure core

  No. But I wonder if 5+3i is very natural for a language that doesn't  
  have infix arithmetic. This notation is just a sum of a real and an  
  imaginary number, so in Clojure I'd expect to see (+ 5 3i) instead.

 Konrad, I see your point, but it seems that Rich has chosen a less
 lisp purist perspective on this. Please consider the following
 examples:

 (class (/ 3 4)) ; legal
 (class 3/4)     ; legal
 (class 3 / 4)   ; illegal
 (class 3/ 4)    ; illegal
 (class 3 /4)    ; illegal
 (class 1.234e+14) ; legal
 (class 1.234e-14)  ; legal
 (class 1.234 e-14) ; illegal
 (class 1.234e -14) ; illegal
 (class 1.234 e -14) ; illegal

 It seems to be that Rich has the perspective that a Ratio's toString()
 output is also valid input as well, even though this appears to be an
 infix notated '/'. What I'm proposing is that a number ending with 'i'
 is imaginary or complex, and that a '+' with no spaces may be used to
 define a complex

 I think the 3+5i form makes more sense *because* there isn't infix
 notation in the language. Please also consider the example of an
 exponentiated double. It's permissible to have a '+' or a '-' in the
 middle of that number, but it isn't to be confused with an infixed '+'
 operation.

  What trouble?

 I need to reinvestigate what the trouble was. Maybe it was in the
 complexity of parsing, or simply because Rich used BigInteger in
 Ratio. I'll get back to you on that one!

  Perhaps a good compromise would be to have a thin Clojure wrapper  
  around a good Java library.

 This is what I was thinking too.

-- 
You 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: SLIME REPL clojure completion

2010-06-08 Thread Rick Moynihan
On 7 June 2010 16:52, Rick Moynihan rick.moyni...@gmail.com wrote:
 On 7 June 2010 16:35, Phil Hagelberg p...@hagelb.org wrote:
 On Mon, Jun 7, 2010 at 5:41 AM, Rick Moynihan rick.moyni...@gmail.com 
 wrote:
 I've just updated slime to 20100404 in ELPA, and I've noticed that tab
 completion in the REPL buffer has stopped working.

 Pressing TAB to complete a symbol prints No dynamic expansion for
 `user foo' found.  Any ideas how to get this working again?

 There are a couple functions needed for slime support that got moved
 to clojure-mode. Are you running version 1.7.1?

 Yes... it's also the ELPA installed version, along with clojure-test-mode 1.4.

 I'm also using swank-clojure 1.1.0 from ELPA, though am I right in
 thinking that I dont need this as I  use swank via lein/mvn and
 slime-connect?

Anymore ideas on this?  Oddly I seem to get completion occaisionally,
but not for example on java classes, e.g.

user java.lang.StrTAB

No dynamic expansion for `user java.lang.Str' found.

R.

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


Opposite to bean?

2010-06-08 Thread Michael Jaaka
Hi!

We have function bean which takes POJO and returns read-only map
with values. How about opposite function?

It would be nice to have function like:

(defmacro unbean
  ([^Class class-name map-of-fields-and-values  omit-fields] ... )
  ([^Object obj-ref map-of-fields-and-values  omit-fields] ... )  )

Which would take classname symbol or object, map of fieldname - its
values (for example the result from bean) and fields to omit (for
example field to omit because it has an ID set by a database or
reference to heavy object initialized with side-effecting method
call). With classname the no-arg constructor had to be called for
object reference.


Any ideas?

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


Re: mapping a collection and a transposed collection of collections

2010-06-08 Thread Eugen Dück
That's perfect - Thanks!

On Jun 7, 11:43 am, ataggart alex.tagg...@gmail.com wrote:
 (map list x (apply map list y))

 On Jun 6, 5:51 am, Eugen Dück eu...@dueck.org wrote:

  Suppose I have two collections:

  (def x [1 2])
  (def y [[\a \b] [\d \e] [\f \g]])

  And want to iterate over them in the following manner:

  user= (map list x (transpose y))
  ((1 (\a \d \f))
  (2 (\b \e \g)))

  Where this is the transpose fn:

  (defn transpose
    [in]
    (partition (count in) (apply interleave in)))

  Is there any other nice way to do this without relying on some home-
  grown fn?

  Cheers
  Eugen

-- 
You 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: RFC: clj-ds Clojure data structure for Java (et al.)

2010-06-08 Thread B Smith-Mannschott
On Tue, Jun 8, 2010 at 14:34, Krukow karl.kru...@gmail.com wrote:
 I would like to hear the groups opinion before (and if) I release this
 to the general public.

 http://github.com/krukow/clj-ds

 README:
 ...
 *WHY*
 First, I love Clojure :) ...
 Unfortunately sometimes clients require that I use Java...

 The data structures used in the Clojure programming language are a
 great
 implementation of a number of useful persistent data structures
 (see e.g., the section on immutable data structures on
 http://clojure.org/functional_programming).

...

Yes please!

One nit: you probably didn't mean to check in your build products. The
classes directory is full of *.class files.

-- 
You 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: Broken Link in Clojure Contrib Docs

2010-06-08 Thread Stuart Halloway
Fixed in the repos, thanks. Will show up in docs shortly.

Stu

 Hello all,
 
 Not sure where to report this but I noticed a broken link when taking
 a look at the docs for sql in Clojure Contrib.
 
 http://richhickey.github.com/clojure-contrib/sql-api.html
 
 The link for Example code points here:
 
 http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/sql/test.clj
 
 Which is no longer around.  If I'm reporting this in the wrong place
 then please let me know and I'll move the post.
 
 Cheers,
 Daniel
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You 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: Complex type in clojure

2010-06-08 Thread Steven Devijver


On 8 jun, 05:47, Daniel doubleagen...@gmail.com wrote:
 These notation arguments are compelling.


I'm not convinced. The notation would only work for literals, and how
often would one write literal complex numbers?

For non-literals the notation would need to support this:

(* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
algo z)i)

This is no issue at all without this notation:

(complex-times [(my-complicated-algo x) (my-other-complicated-algo y)]
[0 (another-algo z)])

Implementing this notation would obviously require a serious overhaul
of clojure for a nice-to-have feature.

-- 
You 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: SLIME REPL clojure completion

2010-06-08 Thread Joost
On Jun 8, 12:34 pm, Rick Moynihan rick.moyni...@gmail.com wrote:
 user java.lang.StrTAB

 No dynamic expansion for `user java.lang.Str' found.

check your slime-complete-symbol-function.
slime-complete-symbol* does not complete java classes, but slime-
simple-complete does

HTH,
Joost.

-- 
You 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: SLIME REPL clojure completion

2010-06-08 Thread Joost
Oops:

 check your slime-complete-symbol-function.
 slime-complete-symbol* does not complete java classes, but slime-
 simple-complete does

that last one should be slime-simple-complete-symbol

-- 
You 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: SLIME REPL clojure completion

2010-06-08 Thread Joost
Oh, and make SURE pressing TAB actually calls slime-complete-symbol
and not some non-slime completion function.

You can check by doing (in a clojure-mode buffer) C-h C-k TAB

I believe the default binding is C-c TAB and M-TAB - not TAB.

Joost.

-- 
You 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: RFC: clj-ds Clojure data structure for Java (et al.)

2010-06-08 Thread Krukow


On Jun 8, 3:11 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote:
 Yes please!

OK :)

 One nit: you probably didn't mean to check in your build products. The
 classes directory is full of *.class files.


No, I didn't want the class files - I was a bit fast on the commit.
I'll clean it up.

/Karl

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


Results from the State of Clojure, Summer 2010 Survey

2010-06-08 Thread Chas Emerick
Last week, many of you were kind enough to participate in a survey I  
linked to here and elsewhere, that I awkwardly titled The State of  
Clojure, Summer 2010.


I've written up a summary of the results, and linked to the raw survey  
result data:


http://bit.ly/dtdAwb

There's a lot of interesting information there, a lot to be proud of,  
and a lot to think about.


I want to thank everyone who participated in the survey, and urge  
everyone on this list to think about what you can do to contribute to  
the community so that results from the next State of Clojure survey  
will show the kind of growth and maturation that we all hope for.


Cheers,

- Chas

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


Re: Complex type in clojure

2010-06-08 Thread Mike Meyer
On Tue, 8 Jun 2010 06:33:25 -0700 (PDT)
Steven Devijver steven.devij...@gmail.com wrote:
 On 8 jun, 05:47, Daniel doubleagen...@gmail.com wrote:
  These notation arguments are compelling.
 
 
 I'm not convinced. The notation would only work for literals, and how
 often would one write literal complex numbers?
 
 For non-literals the notation would need to support this:
 
 (* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
 algo z)i)

Why? It isn't supported for rationals or exponents. Or are you
claiming that because we support 3/4 we should also support

(* (my-complicated-algo val)/(my-other-complicated-algo exp)
   1/(another-complicated-algo exp2))

with similar problems because we support 1e3?

mike

-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

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

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


Re: SLIME REPL clojure completion

2010-06-08 Thread Rick Moynihan
On 8 June 2010 14:42, Joost jo...@zeekat.nl wrote:
 Oh, and make SURE pressing TAB actually calls slime-complete-symbol
 and not some non-slime completion function.

 You can check by doing (in a clojure-mode buffer) C-h C-k TAB

 I believe the default binding is C-c TAB and M-TAB - not TAB.


Thanks for the help.  Your suggestions helped me diagnose and fix the problem.

R.

-- 
You 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: Complex type in clojure

2010-06-08 Thread Steven Devijver


On 8 jun, 16:38, Mike Meyer mwm-keyword-googlegroups.
620...@mired.org wrote:

 Why? It isn't supported for rationals or exponents. Or are you
 claiming that because we support 3/4 we should also support

 (* (my-complicated-algo val)/(my-other-complicated-algo exp)
    1/(another-complicated-algo exp2))

 with similar problems because we support 1e3?

     mike

What would (Math/pow (Math/E (* 2/5 2 Math/PI i))) return?

-- 
You 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: Complex type in clojure

2010-06-08 Thread ataggart


On Jun 8, 6:33 am, Steven Devijver steven.devij...@gmail.com wrote:
 On 8 jun, 05:47, Daniel doubleagen...@gmail.com wrote:

  These notation arguments are compelling.

 I'm not convinced. The notation would only work for literals

Correct.


 For non-literals the notation would need to support this:

 (* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
 algo z)i)

You're conflating notation with operation.


 This is no issue at all without this notation:

 (complex-times [(my-complicated-algo x) (my-other-complicated-algo y)]
 [0 (another-algo z)])

The point here is not simply to add a literal notation, but to
integrate complex type handling into the math functions.  Bifurcating
the math functions is a horrible idea.


 Implementing this notation would obviously require a serious overhaul
 of clojure for a nice-to-have feature.

Augmenting the math functions to support complex numbers requires a
serious overhaul. Augmenting the reader to handle the notation is
trivial, so I'm not clear on why you're obsessing about it.

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


Re: Complex type in clojure

2010-06-08 Thread Steven Devijver


On 8 jun, 19:43, ataggart alex.tagg...@gmail.com wrote:
 On Jun 8, 6:33 am, Steven Devijver steven.devij...@gmail.com wrote:

  On 8 jun, 05:47, Daniel doubleagen...@gmail.com wrote:

   These notation arguments are compelling.

  I'm not convinced. The notation would only work for literals

 Correct.

  For non-literals the notation would need to support this:

  (* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
  algo z)i)

 You're conflating notation with operation.



  This is no issue at all without this notation:

  (complex-times [(my-complicated-algo x) (my-other-complicated-algo y)]
  [0 (another-algo z)])

 The point here is not simply to add a literal notation, but to
 integrate complex type handling into the math functions.  Bifurcating
 the math functions is a horrible idea.

  Implementing this notation would obviously require a serious overhaul
  of clojure for a nice-to-have feature.

 Augmenting the math functions to support complex numbers requires a
 serious overhaul. Augmenting the reader to handle the notation is
 trivial, so I'm not clear on why you're obsessing about it.

It's a mischaracterization to say I'm obsessed about this. I think
this whole idea is an waste of time and effort with no valuable
outcome. Color me skeptical.

-- 
You 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: Complex type in clojure

2010-06-08 Thread Mike Meyer
On Tue, 8 Jun 2010 10:27:28 -0700 (PDT)
Steven Devijver steven.devij...@gmail.com wrote:

 On 8 jun, 16:38, Mike Meyer mwm-keyword-googlegroups.
 620...@mired.org wrote:
 
  Why? It isn't supported for rationals or exponents. Or are you
  claiming that because we support 3/4 we should also support
 
  (* (my-complicated-algo val)/(my-other-complicated-algo exp)
     1/(another-complicated-algo exp2))
 
  with similar problems because we support 1e3?
 
 What would (Math/pow (Math/E (* 2/5 2 Math/PI i))) return?

Why is this relevant to a discussion of whether or not support for
complex literals is desirable? All but i is involved with the
semantics of complex values, not the literal.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

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

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


Re: A simple csv parsing library

2010-06-08 Thread Jonas Enlund
I've added my work on the csv reader/writer library to github
(http://github.com/jonase/cljcsv). Please let me know If anyone finds
it useful.

Thanks,
Jonas

On Wed, May 26, 2010 at 6:40 AM, Jonas Enlund jonas.enl...@gmail.com wrote:
 Hi there

 I built a simple csv parsing library[1] last weekend which I want to
 show you guys. It follows the RFC 4180[2] pretty closely but it allows
 for any character as separator and quote mark. It would be great if
 someone would take time and read the code. I would like to know:

 a) Can performance still be improved?
 b) Is it idiomatically written?
 c) What should an idiomatic csv parsing API look like in Clojure?
 Currently there is only one public function, 'parse' (like
 clojure.xml).

 The end of the file contains a few usage examples.

 happy hacking!
 /Jonas

 [1] http://gist.github.com/414023
 [2] http://tools.ietf.org/html/rfc4180


-- 
You 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: Broken Link in Clojure Contrib Docs

2010-06-08 Thread Tom Faulhaber
Stu,

I don't see a commit from you on this.

Tom

On Jun 8, 6:16 am, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Fixed in the repos, thanks. Will show up in docs shortly.

 Stu

  Hello all,

  Not sure where to report this but I noticed a broken link when taking
  a look at the docs for sql in Clojure Contrib.

 http://richhickey.github.com/clojure-contrib/sql-api.html

  The link for Example code points here:

 http://code.google.com/p/clojure-contrib/source/browse/trunk/src/cloj...

  Which is no longer around.  If I'm reporting this in the wrong place
  then please let me know and I'll move the post.

  Cheers,
  Daniel

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

-- 
You 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: Broken Link in Clojure Contrib Docs

2010-06-08 Thread Stuart Halloway
Sorry, should be there now.

 Stu,
 
 I don't see a commit from you on this.
 
 Tom
 
 On Jun 8, 6:16 am, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Fixed in the repos, thanks. Will show up in docs shortly.
 
 Stu
 
 Hello all,
 
 Not sure where to report this but I noticed a broken link when taking
 a look at the docs for sql in Clojure Contrib.
 
 http://richhickey.github.com/clojure-contrib/sql-api.html
 
 The link for Example code points here:
 
 http://code.google.com/p/clojure-contrib/source/browse/trunk/src/cloj...
 
 Which is no longer around.  If I'm reporting this in the wrong place
 then please let me know and I'll move the post.
 
 Cheers,
 Daniel
 
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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


Quick question

2010-06-08 Thread Allan Moore
Does anybody know how I can produce a sorted-set from a list without
overflowing the stack on a list of up to 20 items?

-- 
You 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: Complex type in clojure

2010-06-08 Thread Jason Smith
Why not just treat is as a vector, do vector math operations on it,
and be done with it?  1+2j is equivalent to [1 2].  1+2j represents a
2-D vector, does it not?  Not only does this handle imaginaries, but
higher forms, such as [1 2 3 4].  The beauty of Lisp is that once you
accept the basic syntax (atoms and groupings), you don't have to worry
about developing EBNF forms for every arbitrary human readable
notation.

Or I could be totally wrong.


On Jun 8, 12:03 pm, Mike Meyer mwm-keyword-googlegroups.
620...@mired.org wrote:
 On Tue, 8 Jun 2010 10:27:28 -0700 (PDT)

 Steven Devijver steven.devij...@gmail.com wrote:
  On 8 jun, 16:38, Mike Meyer mwm-keyword-googlegroups.
  620...@mired.org wrote:

   Why? It isn't supported for rationals or exponents. Or are you
   claiming that because we support 3/4 we should also support

   (* (my-complicated-algo val)/(my-other-complicated-algo exp)
      1/(another-complicated-algo exp2))

   with similar problems because we support 1e3?

  What would (Math/pow (Math/E (* 2/5 2 Math/PI i))) return?

 Why is this relevant to a discussion of whether or not support for
 complex literals is desirable? All but i is involved with the
 semantics of complex values, not the literal.

         mike
 --
 Mike Meyer m...@mired.org          http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

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

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


Re: Quick question

2010-06-08 Thread Peter Schuller
 Does anybody know how I can produce a sorted-set from a list without
 overflowing the stack on a list of up to 20 items?

I'm thinking I must be misunderstanding the question, but (apply
sorted-set lst)?

-- 
/ Peter Schuller

-- 
You 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: Complex type in clojure

2010-06-08 Thread Travis Hoffman
Steven,

I see your point, however, if we look (again) at Ratio for insight:

user= (+ (+ 1 2)/(+ 3 4) 5)
java.lang.ClassCastException: clojure.core$_SLASH_ cannot be cast to
java.lang.Number (NO_SOURCE_FILE:0)

The sort of notation for non-literals you suggest would be required
would actually not be required nor, in my humble opinion, advisable.
Or, at least it is not implemented for Ratio.

Perhaps you're thinking of the '+' and '-' as infixed addition or
subtraction, when they're not intended to be, no more than the '/' is
infixed division in a Ratio. Instead, one could do:

user= (+ 1 2i)
1+2i

Lastly, I'll argue it's not so much literals that are the big need as
are stored values. If you saved a Ratio in a String (say, in a
Database), you can retrieve and read it in naturally with it's
toString() format. I suppose java serialized storage does avoid this,
but we still would need to handle the natural toString() format of
the output of a complex number, just as Ratio does.

On a side note, I really appreciate all these contrasting opinions.
Ultimately, I'm going to have to convince Rich and the other core
developers to make this change, and I think I'm going to have a much
more well-reasoned and developed argument for the change when I
do! :-)

-Travis

On Jun 8, 6:33 am, Steven Devijver steven.devij...@gmail.com wrote:
 On 8 jun, 05:47, Daniel doubleagen...@gmail.com wrote:

  These notation arguments are compelling.

 I'm not convinced. The notation would only work for literals, and how
 often would one write literal complex numbers?

 For non-literals the notation would need to support this:

 (* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
 algo z)i)

 This is no issue at all without this notation:

 (complex-times [(my-complicated-algo x) (my-other-complicated-algo y)]
 [0 (another-algo z)])

 Implementing this notation would obviously require a serious overhaul
 of clojure for a nice-to-have feature.

-- 
You 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: Complex type in clojure

2010-06-08 Thread Travis Hoffman
Well, I don't find the question to be irrelevant. It makes me think
about a couple issues:

1.) Should Complex and Imaginary extend java.lang.Number?
2.) What do we do with the standard Java math functions?
3.) Is 'i' by itself, valid input as a number?

First, I do not propose that just i or j is enough to indicate the
imaginary number, no more than just 'd' means the number 1.0d (the
latter is correct way to write a double in Java and in clojure).

That said, I would expect the same result that clojure gives now:

user= (Math/pow (Math/E (* 2/5 2 Math/PI i)))
java.lang.Exception: Unable to resolve symbol: i in this context
(NO_SOURCE_FILE:4)

If you use: 1.0i

user= (Math/pow (Math/E (* 2/5 2 Math/PI 1.0i)))
java.lang.IllegalArgumentException: No matching method: E
(NO_SOURCE_FILE:1)

Oops! You have an extra set of parenthesis!

If you meant (Math/pow Math/E (* 2/5 2 Math/PI 1.0i)), then the answer
depends on whether Imaginary extends Number. If it does logical (but
perhaps confusing) answer is:

user= (Math/pow (Math/E (* 2/5 2 Math/PI 1.0i))
1.0

Why? Because you're forcing java.lang.Math.pow(double, double). Java
will then force the cast of the Imaginary number to a double by
calling doubleValue() on 2.51327412i which has no real component,
thus, you're finding E^0.0 = 1.0. This is the exact same behavior you
would have in Java if you were working with a custom Complex Java type
which extends Number.

If, however, we choose the route Commons Math chooses (to not extend
Number), we should get something like we get now if we pass a non-
Number type to Math/pow:

user= (Math/pow Math/E cat)
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number (NO_SOURCE_FILE:0)

So, I would expect something like:

user= (Math/pow Math/E 5i)
java.lang.ClassCastException: clojure.lang.Imaginary cannot be cast to
a java.lang.Number (NO_SOURCE_FILE:0)

To get something useful, one would have to use a library (a standard
clojure math library) which supports the complex type, just as it is
in Java. This seems to be the preferable approach.

Thanks for the skepticism and the question!

-Travis

On Jun 8, 11:03 am, Mike Meyer mwm-keyword-googlegroups.
620...@mired.org wrote:
 On Tue, 8 Jun 2010 10:27:28 -0700 (PDT)

 Steven Devijver steven.devij...@gmail.com wrote:
  On 8 jun, 16:38, Mike Meyer mwm-keyword-googlegroups.
  620...@mired.org wrote:

   Why? It isn't supported for rationals or exponents. Or are you
   claiming that because we support 3/4 we should also support

   (* (my-complicated-algo val)/(my-other-complicated-algo exp)
      1/(another-complicated-algo exp2))

   with similar problems because we support 1e3?

  What would (Math/pow (Math/E (* 2/5 2 Math/PI i))) return?

 Why is this relevant to a discussion of whether or not support for
 complex literals is desirable? All but i is involved with the
 semantics of complex values, not the literal.

         mike
 --
 Mike Meyer m...@mired.org          http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

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

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


Re: RFC: clj-ds Clojure data structure for Java (et al.)

2010-06-08 Thread Jason Smith
I really like the idea of modularizing the language.  Not just the
Java parts, since Clojure compiles to class files as well.  The
clojure.jar / clojure-contrib.jar split is artificial, and the bigger
these libraries get, the more obvious it will become that they need to
be broken into multiple separate projects.

On Jun 8, 8:08 am, Krukow karl.kru...@gmail.com wrote:
 On Jun 8, 3:11 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote:

  Yes please!

 OK :)

  One nit: you probably didn't mean to check in your build products. The
  classes directory is full of *.class files.

 No, I didn't want the class files - I was a bit fast on the commit.
 I'll clean it up.

 /Karl

-- 
You 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: Quick question

2010-06-08 Thread Peter Schuller
 Yes, that answers my question.

Cool :)

 Sorry still a newbie to clojure and
 lisps in general here.

No problem. I didn't mean to imply there was anything wrong with the
question as such. It's just that you mentioned specifically
overflowing the stack so I thought I might be missing something about
the intent.

-- 
/ Peter Schuller

-- 
You 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: Opposite to bean?

2010-06-08 Thread .Bill Smith
Michael,

See 
http://groups.google.com/group/clojure/browse_thread/thread/8e8d3c5e85e4f82d/faf0669fe3e0dca0?q=#faf0669fe3e0dca0
for one idea.

Bill Smith
Austin, TX

-- 
You 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: PDF generation with Clojure?

2010-06-08 Thread Mark Derricutt
We use flying saucer/itext , an example of this from clojure can be seen on
my blog at:

http://www.talios.com/connecting_the_clouds__the_internet_in_new_zealand_in_pdf.htm

This is some old clojure code and is quite nasty, but its only really the
last 5 lines you need for the flying saucer stuff.

This does XHTML+CSS-PDF.

-- 
Pull me down under...

On Tue, May 25, 2010 at 10:22 AM, Jim Tittsler j...@onjapan.net wrote:

 Is there a library for generating PDF pages/reports with Clojure?  (Or
 a Java library that interoperates more naturally than others?)


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

Re: A simple csv parsing library

2010-06-08 Thread Kyle R. Burton
 I've added my work on the csv reader/writer library to github
 (http://github.com/jonase/cljcsv). Please let me know If anyone finds
 it useful.

Thanks for the implementation, I'm very encouraged that you followed
the RFC (I've seen lots of implementations that haven't).

I took a quick look at both yours and clojure-csv [1].  I'm not using
the 1.2 snapshots so I wasn't able to try out your implementation, but
I did notice clojure-csv is lax about invalidly formatted files - if a
quoted field ends the file but is not terminated before eof, it does
not signal an error.  I think I recognize the same behavior in cljcsv
as well (though as I said I could not try it).  It might be nice to at
least have an option which allows an unterminated field to be
recognized.

Best Regards,

Kyle

[1] http://github.com/davidsantiago/clojure-csv

 On Wed, May 26, 2010 at 6:40 AM, Jonas Enlund jonas.enl...@gmail.com wrote:
 Hi there

 I built a simple csv parsing library[1] last weekend which I want to
 show you guys. It follows the RFC 4180[2] pretty closely but it allows
 for any character as separator and quote mark. It would be great if
 someone would take time and read the code. I would like to know:

 a) Can performance still be improved?
 b) Is it idiomatically written?
 c) What should an idiomatic csv parsing API look like in Clojure?
 Currently there is only one public function, 'parse' (like
 clojure.xml).

 The end of the file contains a few usage examples.

 happy hacking!
 /Jonas

 [1] http://gist.github.com/414023
 [2] http://tools.ietf.org/html/rfc4180


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



-- 
--
kyle.bur...@gmail.comhttp://asymmetrical-view.com/
--

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


Re: Complex type in clojure

2010-06-08 Thread Andrzej
On Wed, Jun 9, 2010 at 2:43 AM, ataggart alex.tagg...@gmail.com wrote:

 For non-literals the notation would need to support this:

 (* (my-complicated-algo x)+(my-other-complicated-algo y)i (another-
 algo z)i)

 You're conflating notation with operation.

I wouldn't even bother with reader notation. Both (complex -1 0) and
(complex-polar 1 3.14) are readable an compact enough to me. We would
still need some support for notation when printing the results, though
(could even be that constructor notation), unless we are happy
exposing implementation details.

This may not be that difficult, AFAIK print is already using
multimethod dispatch.

 The point here is not simply to add a literal notation, but to
 integrate complex type handling into the math functions.  Bifurcating
 the math functions is a horrible idea.

Exactly. Speaking for myself again, I use complex numbers (much) more
often than ratios (in fact, so far I only played with ratios rather
than used them) and such integration would be very useful for me.

The question is, how far are we ready to go in that way? I imagine at
least two more data types that could be plugged into numeric tower:
- vectors/matrices
- symbolic expressions

Maybe instead of hardwiring all these types, we should provide a
mechanism for overloading math operators? I guess multimethods would
be too slow and I have no experience with defrecord/... to predict
robustness of this solution.

-Andrzej

-- 
You 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: Complex type in clojure

2010-06-08 Thread Konrad Hinsen
On 09.06.2010, at 05:56, Andrzej wrote:

 The point here is not simply to add a literal notation, but to
 integrate complex type handling into the math functions.  Bifurcating
 the math functions is a horrible idea.
 
 Exactly. Speaking for myself again, I use complex numbers (much) more
 often than ratios (in fact, so far I only played with ratios rather
 than used them) and such integration would be very useful for me.

Same here. It's indeed not a trivial job, but a useful one.

 The question is, how far are we ready to go in that way? I imagine at
 least two more data types that could be plugged into numeric tower:
 - vectors/matrices
 - symbolic expressions

Neither of those are numbers in the mathematical sense. And from an 
implementation point of view, both matrices and symbolic expressions already 
have so much overhead that they don't require the same kind of optimization 
that number implementations usually get.

 Maybe instead of hardwiring all these types, we should provide a
 mechanism for overloading math operators? I guess multimethods would
 be too slow and I have no experience with defrecord/... to predict
 robustness of this solution.

That's the way I explored in clojure.contrib.generic, using multimethods. I 
don't think the new protocol mechanism is a good choice, because it is limited 
to single dispatch. As I said a few messages ago in this thread, I do think 
that generic maths operations are very useful to have, and I appreciate  
Clojure for making it possible to implement and use them in a very nice way, 
but I do not think they are the way to go for the basic number tower, because 
of the multimethod overhead. I'd like to see an efficient number tower in 
clojure.core, ideallly with complex numbers added in, and a library for generic 
operations available as an add-on.

Konrad.

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