Re: (* BigDecimal double) should result in BigDecimal, not in Double, isn't it?

2010-01-18 Thread Lauri Oherd
On page http://clojure.org/data_structures#toc2 there is written: Any
numeric operation involving Doubles yields a Double.

Hope this helps,
Lauri

On Sun, Jan 17, 2010 at 12:13 AM, Jevgeni Holodkov
jevgeni.holod...@gmail.com wrote:
 Currently, if the result of the multiplication is too small, then the
 type will be double, despite the fact that one of the parameter was
 BigDecimal:

 Clojure 1.1.0
 user= (* 100M 1.1)
 110.01
 user= (class (* 100M 1.1))
 java.lang.Double

 Such thing are really hard to find and this can be easily produced by
 non-technical person, if he is using some kind of DSL which is based
 on Clojure. Shoudn't it be BigDecimal instead?

 Wbr,
 Jevgeni

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

Case-insensitive map?

2010-01-18 Thread C. Florian Ebeling
Is there a good way to make a map case-insensitive for string keys? I
first thought just wrapping some function around it would be it, but
when I try it, it is really a bit more involved. Has anyone done this,
or is there a recommended way?

Florian

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

Re: Couverjure: an attempt at a direct bridge between Clojure and Cocoa

2010-01-18 Thread David Nolen
Very cool.

On Mon, Jan 18, 2010 at 8:51 AM, Mark Allerton mark.aller...@gmail.comwrote:

 Hi all,

 I've been hacking on a bridge between Clojure and Cocoa, and have been
 prompted to break cover by recent discussion of the subject of Objective-C
 interfacing here on this list.

 The code is strictly demo or proof of concept quality right now - the
 example code and the unit tests work, but try almost anything more than I've
 done there and it's guaranteed that something will break. But since there is
 some interest in working with Cocoa and I believe the approach I'm taking
 has some promise I thought it was worthwhile going public. You'll have to
 excuse my horrible Clojure, this is my first serious project with the
 language.

 The code and some more explanation can be found at

 http://github.com/allertonm/Couverjure


 (The name is also explained there, BTW.)

 Cheers

 ..Mark..

 --
 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.comclojure%2bunsubscr...@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: Why recur?

2010-01-18 Thread Alex Ott
Hello all

I have a question to Rich - are there plans to introduce named
loop/recur?  In Scheme it very handy to create named let, and create nested
loops.  Currently in Clojure, I need to split nested loop into separate
function, that not so often good 

-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/   http://xtalk.msk.su/~ott/
http://alexott-ru.blogspot.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: Clojure on Ideone!

2010-01-18 Thread Steve Purcell
For those who didn't click through, this is a really nifty code paste site that 
will actually run your pasted code and display the output next to the paste. 
Worth a look; it's a nice piece of work.

-Steve



On 15 Jan 2010, at 21:23, sphere research wrote:

 Hi,
 
 test Clojure on ideone.com
 (more: http://www.facebook.com/pages/ideone/245768360841)
 
 see the example: http://ideone.com/Aymq9Tg4
 
 if you wish, we could install Clojure on spoj.pl,
 
 regards,
 
 IdeoneSPOJ Team
 -- 
 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: Clojure on Ideone!

2010-01-18 Thread Alen Ribic
I've been toying around something similar.
Here is a rough preview: http://preview.xpojure.com/snippet/view/2/

-Alen


On Mon, Jan 18, 2010 at 1:02 PM, Steve Purcell st...@sanityinc.com wrote:
 For those who didn't click through, this is a really nifty code paste site 
 that will actually run your pasted code and display the output next to the 
 paste. Worth a look; it's a nice piece of work.

 -Steve



 On 15 Jan 2010, at 21:23, sphere research wrote:

 Hi,

 test Clojure on ideone.com
 (more: http://www.facebook.com/pages/ideone/245768360841)

 see the example: http://ideone.com/Aymq9Tg4

 if you wish, we could install Clojure on spoj.pl,

 regards,

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

Re: Why recur?

2010-01-18 Thread Konrad Hinsen

On 18.01.2010, at 12:03, Alex Ott wrote:


I have a question to Rich - are there plans to introduce named
loop/recur?  In Scheme it very handy to create named let, and create  
nested
loops.  Currently in Clojure, I need to split nested loop into  
separate

function, that not so often good


Nested loops work perfectly fine in Clojure:

(defn print-pairs [seq1 seq2]
  (loop [s1 seq1]
(when (seq s1)
  (loop [s2 seq2]
(when (seq s2)
  (prn (first s1) (first s2))
  (recur (rest s2
  (recur (rest s1)

(print-pairs [1 2] [a b])


I am not claiming that this is a good way to find pairs of items, but  
it's an illustration for nested loops... recur always refers to the  
innermost loop, so it can be nested to any level.


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

Re: Why recur?

2010-01-18 Thread Martin Coxall



On 18 Jan 2010, at 11:23, Konrad Hinsen konrad.hin...@fastmail.net  
wrote:



On 18.01.2010, at 12:03, Alex Ott wrote:


I have a question to Rich - are there plans to introduce named
loop/recur?  In Scheme it very handy to create named let, and  
create nested
loops.  Currently in Clojure, I need to split nested loop into  
separate

function, that not so often good


Nested loops work perfectly fine in Clojure:



Is this a recursive email? After receiving it seven times I've blown  
my stack.



(defn print-pairs [seq1 seq2]
 (loop [s1 seq1]
   (when (seq s1)
 (loop [s2 seq2]
   (when (seq s2)
 (prn (first s1) (first s2))
 (recur (rest s2
 (recur (rest s1)

(print-pairs [1 2] [a b])


I am not claiming that this is a good way to find pairs of items,  
but it's an illustration for nested loops... recur always refers to  
the innermost loop, so it can be nested to any level.


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
-- 
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: Case-insensitive map?

2010-01-18 Thread Laurent PETIT
There's a library in clojure.contrib which allows to create your own
getters / setters for maps :

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

HTH,

-- 
Laurent

2010/1/18 C. Florian Ebeling florian.ebel...@gmail.com:
 Is there a good way to make a map case-insensitive for string keys? I
 first thought just wrapping some function around it would be it, but
 when I try it, it is really a bit more involved. Has anyone done this,
 or is there a recommended way?

 Florian

 --
 Florian Ebeling
 florian.ebel...@gmail.com

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

-- 
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: (* BigDecimal double) should result in BigDecimal, not in Double, isn't it?

2010-01-18 Thread Jevgeni Holodkov
Hi Ben, thanks for the answer. Yes, I understand the problems with
representing float-point numbers using iee7654 and now I understand
that returing BigDecimal would not solve the actual problem. However,
we don't talk about 0.3(3) in my example, which is non-terminating
decimal. Entered 0.1 is actually a very precise number and the fact
that it gets imprecise somewhere internally should now affect, IMHO,
the result of multiplying two very precise numbers. What's the point
of having a possibility to build a very high-level language on top of
Clojure, when you still need to know the internals? Yes, having 1.1D
for doubles and fractions or bigdecimal for 1.1 probably would be the
best solution.. I don't know, if this is achievable now? Will there be
a impact on the perfomance or on a backward compatibility?

If is this is never to be fixed by some reason (which one can it be?),
then let me ask another question. I wonder, if there is a requirement
for user to write custom business rules himself (lets say he wants to
increase the price on 10%) and he uses 1.1, can I solve this issue
with Clojure core without using external parsers/preprocessors?
Something like replacing the 1.1 with 1.1M or 11/10 before evaluating
the code?

Wbr,
Jevgeni



On Jan 17, 7:47 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote:
 On Sat, Jan 16, 2010 at 23:13, Jevgeni Holodkov

 jevgeni.holod...@gmail.com wrote:
  Currently, if the result of the multiplication is too small, then the
  type will be double, despite the fact that one of the parameter was
  BigDecimal:

  Clojure 1.1.0
  user= (* 100M 1.1)
  110.01
  user= (class (* 100M 1.1))
  java.lang.Double

  Such thing are really hard to find and this can be easily produced by
  non-technical person, if he is using some kind of DSL which is based
  on Clojure. Shoudn't it be BigDecimal instead?

 IMO: No it should not.

 (Maybe someone else can explain this more succinctly, I feel like I'm
 muddling the point I'm trying to make.)

 The whole point of using BigDecimal is to avoid the non-intuitive
 funkyness that will result from using binary floating point (Double,
 Float) while expecting decimal behavior. Furthermore, BigDecimal can
 be arbitrarily precise, while Double has limited precision. Returning
 a BigDecimal from a (* 100M 1.1) would be pretending that the
 calculation is more precise than it actually is.

 Your example is well chosen for my line of argument. Are you aware
 that 0.1 can't be represented exactly as a Double? (It has a
 non-terminating representation in binary, just as 1/3 =
 0.33... does in decimal.) 0.1M, however can be represented
 exactly as a BigDecimal. People can be awfully picky about predictable
 arithmetic behavior when it comes to Money, which is what BigDecimal
 is often used for.

 (From a DSL standpoint, it might have been better if Clojure had
 chosen 1.1 as the syntax for BigDecimal and 1.1D (or similar) for
 Double, but there's no fixing that now.)

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

Re: Good refs on concurrency?

2010-01-18 Thread Gene Tani


On Jan 16, 4:02 pm, David Beckwith thirdreplica...@gmail.com wrote:
 Hi,

 Can you guys recommend any good books, articles or code on
 concurrency?  I'm new to concurrency issues, and just finished the
 Halloway book, so it would be great to have an introductory reference
 with lots of examples of how to make your CPUs all work happily
 together.  Bascally, I'd like to read a whole book about it relevant
 to Clojure.  

this should get you started

http://www.twine.com/item/120vrcs9n-14/resolved-language-debates

http://erlangish.blogspot.com/2008/05/overview-of-concurrency.html

http://www.tbray.org/ongoing/What/Technology/Concurrency/
---
C++, and the lock / semaphore/ mutex realm:

http://herbsutter.wordpress.com/category/concurrency/
-- 
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: (* BigDecimal double) should result in BigDecimal, not in Double, isn't it?

2010-01-18 Thread Konrad Hinsen

On 17.01.2010, at 23:13, Jevgeni Holodkov wrote:


decimal. Entered 0.1 is actually a very precise number and the fact
that it gets imprecise somewhere internally should now affect, IMHO,
the result of multiplying two very precise numbers. What's the point


There is no such thing as a precise or imprecise number as far as  
the computer is concerned. What differs is the interpretation that  
humans (programmers and users) make of the data items. The rules of  
floating-point arithmetic (in Clojure and pretty much anywhere else)  
are designed with the expectation that floats will be interpreted as  
approximations. So as soon as you use a single float in some  
expression, the whole expression becomes something to be considered  
approximate, and therefore it will be of float type.


Unlike most languages, Clojure has a way to express precise non- 
integer numbers: ratios. Just use 11/10 instead of 1.1 (or (+ 1 1/10)  
if you prefer), and you won't see any floating-point result. In fact,  
what you are complaining about is simply that the input string 1.1 is  
interpreted as a float rather than as a ratio. Obviously it can't mean  
both, so some choice has to be made.



If is this is never to be fixed by some reason (which one can it be?),
then let me ask another question. I wonder, if there is a requirement
for user to write custom business rules himself (lets say he wants to
increase the price on 10%) and he uses 1.1, can I solve this issue
with Clojure core without using external parsers/preprocessors?
Something like replacing the 1.1 with 1.1M or 11/10 before evaluating
the code?


I don't think so. The very first step of Clojure's expression  
processing system, the reader, already interprets 1.1 as a floating- 
point constant. You would need your own reader to give a different  
meaning to the input string 1.1. However, the good news is that you  
would only need a different reader, you could then plug its results  
into the standard evaluation system.


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


Re: Why recur?

2010-01-18 Thread Alex Ott
Re

Konrad Hinsen  at Mon, 18 Jan 2010 12:23:58 +0100 wrote:
 KH On 18.01.2010, at 12:03, Alex Ott wrote:

  I have a question to Rich - are there plans to introduce named
  loop/recur?  In Scheme it very handy to create named let, and create nested
  loops.  Currently in Clojure, I need to split nested loop into separate
  function, that not so often good

 KH Nested loops work perfectly fine in Clojure:

But this will not allow to jump to outer loop from inside of inner loop...

 KH (defn print-pairs [seq1 seq2]
 KH   (loop [s1 seq1]
 KH (when (seq s1)
 KH   (loop [s2 seq2]
 KH(when (seq s2)
 KH  (prn (first s1) (first s2))
 KH  (recur (rest s2
 KH   (recur (rest s1)

 KH (print-pairs [1 2] [a b])


-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/   http://xtalk.msk.su/~ott/
http://alexott-ru.blogspot.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: Good refs on concurrency?

2010-01-18 Thread Erik Price
On Sat, Jan 16, 2010 at 7:02 PM, David Beckwith
thirdreplica...@gmail.com wrote:
 Hi,

 Can you guys recommend any good books, articles or code on
 concurrency?  I'm new to concurrency issues, and just finished the
 Halloway book, so it would be great to have an introductory reference
 with lots of examples of how to make your CPUs all work happily
 together.  Bascally, I'd like to read a whole book about it relevant
 to Clojure.  (Or maybe relevant to Java.)  I want to learn a lot more

If you're interested in learning about the kinds of problems that
motivate some of Clojure's concurrency features, Java Concurrency in
Practice is excellent. The concepts are not specific only to Java,
although the examples and libraries discussed happen to be Java-based.
I especially like its pragmatic approach - it's written for working
programmers rather than for coursework, so it's a pretty fast and
interesting read.

 about the difference between atoms, vars, refs, etc and when to use
 each in practice.  I guess there are probably several classes of
 situations of when you would need to use concurrency.  I'd like to

This book doesn't discuss these programming constructs, as they are
not available in Java. But it's still an insightful book if only to
learn about what kind of concurrency problems exist, despite Clojure
offering a different way to deal with them than does Java.

e
-- 
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: Good refs on concurrency?

2010-01-18 Thread Erik Price
On Sat, Jan 16, 2010 at 7:02 PM, David Beckwith
thirdreplica...@gmail.com wrote:

 Can you guys recommend any good books, articles or code on
 concurrency?  I'm new to concurrency issues, and just finished the
 Halloway book, so it would be great to have an introductory reference
 with lots of examples of how to make your CPUs all work happily
 together.

I should add that if you're more interested in learning only how
Clojure addresses concurrency issues, rather than a book on
concurrency topics, the best thing to read is others' code. Look for
the more interesting-looking Clojure projects on Github and Bitbucket
and study the code, see how agents and refs are actually being used.
Read the back issues of some of the Clojure blogs like bestinclass.dk
if you haven't already.

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

Re: Clojure on Ideone!

2010-01-18 Thread cej38
Hi,
  This is interesting.  I have often wanted something like this.  Is
there a way to access clojure.contrib?

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

Re: StackOverflowError possible with seq ?

2010-01-18 Thread kirschkernkissen
Hi Kyle!

I encountered the same problem:

(defn stack-fail
  returns an empty lazy seq
  [l i]
  (if ( i 0)
(recur (remove #{1} (concat l '(1))) (dec i))
l))

(def foo (stack-fail () 1000))

foo
; Evaluation aborted.

if you call a non-lazy function (e.g. doall) on the collection from
time to time this wont happen.

Rgds, Robert

On 15 Jan., 00:05, mudphone kyle...@gmail.com wrote:
 Is it possible that the Clojure core seq function can cause a stack
 overflow (since it calls itself)?

 Or is there some other manner in which misuse of a lazy seq could
 cause this?  In the stack trace below, I'm seeing repeated calls to
 seq in clojure core, until the stack is blown.

 Thanks,
 Kyle

 Exception in thread main java.lang.StackOverflowError
 (session_master_boot.clj:19)
         at clojure.lang.Compiler.eval(Compiler.java:4617)
         at clojure.lang.Compiler.eval(Compiler.java:4593)
         at clojure.lang.Compiler.load(Compiler.java:4931)
         at clojure.lang.Compiler.loadFile(Compiler.java:4898)
         at clojure.main$load_script__6637.invoke(main.clj:210)
         at clojure.main$init_opt__6640.invoke(main.clj:215)
         at clojure.main$initialize__6650.invoke(main.clj:243)
         at clojure.main$null_opt__6672.invoke(main.clj:268)
         at clojure.main$legacy_script__6687.invoke(main.clj:299)
         at clojure.lang.Var.invoke(Var.java:359)
         at clojure.main.legacy_script(main.java:32)
         at clojure.lang.Script.main(Script.java:20)
 Caused by: java.lang.StackOverflowError
         at clojure.core$seq__3835.invoke(core.clj:103)
         at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
         at clojure.lang.LazySeq.sval(LazySeq.java:42)
         at clojure.lang.LazySeq.seq(LazySeq.java:56)
         at clojure.lang.RT.seq(RT.java:440)
         at clojure.core$seq__3835.invoke(core.clj:103)
         at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
         at clojure.lang.LazySeq.sval(LazySeq.java:42)
         at clojure.lang.LazySeq.seq(LazySeq.java:56)
         at clojure.lang.RT.seq(RT.java:440)
         at clojure.core$seq__3835.invoke(core.clj:103)
         at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
         at clojure.lang.LazySeq.sval(LazySeq.java:42)
         at clojure.lang.LazySeq.seq(LazySeq.java:56)
         at clojure.lang.RT.seq(RT.java:440)
         at clojure.core$seq__3835.invoke(core.clj:103)
         at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
         at clojure.lang.LazySeq.sval(LazySeq.java:42)
         at clojure.lang.LazySeq.seq(LazySeq.java:56)
         at clojure.lang.RT.seq(RT.java:440)
-- 
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: Case-insensitive map?

2010-01-18 Thread Richard Newman

Is there a good way to make a map case-insensitive for string keys? I
first thought just wrapping some function around it would be it, but
when I try it, it is really a bit more involved. Has anyone done this,
or is there a recommended way?


Do you want real case-insensitivity (i.e., you preserve the case of  
some item in the map), or just down-casing?


To do that you need to alter the hashing and equality functions of the  
map.


I have a Java implementation of a DowncaseMap which downcases String  
keys (and thus avoids specifying the hash function), but obviously the  
output is lowercase. I'm happy to share.


-- 
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: (* BigDecimal double) should result in BigDecimal, not in Double, isn't it?

2010-01-18 Thread Richard Newman

Something like replacing the 1.1 with 1.1M or 11/10 before evaluating
the code?


I don't think so. The very first step of Clojure's expression  
processing system, the reader, already interprets 1.1 as a floating- 
point constant. You would need your own reader to give a different  
meaning to the input string 1.1. However, the good news is that you  
would only need a different reader, you could then plug its results  
into the standard evaluation system.


Or, if you're taking a string from the user as your very first step,  
you could (*choke*) apply regular expressions to append M to every  
piece of floating-point syntax.


However, if those floating-point numbers come from some piece of  
software other than a keyboard driver -- for example, they're read as  
the value of a slider control -- then be careful of falsely assigning  
decimal status to a string representation of a float...


Hacking Clojure's reader to replace the floating-point reader  
shouldn't be too hard. Indeed, this might be something that can be  
parameterized a la Common Lisp's radix/base settings.


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

Interested in creating a Clojure course

2010-01-18 Thread Michael Kohl
Hi all,

I'm one of the assistant teachers at RubyLearning
(http://rubylearning.org), a site offering free/cheap Ruby courses
which are generally quite well-received and we all do this as
volunteers without any monetary interest (the paid courses are there
to finance the site). More info can be found in the FAQ:
http://rubylearning.com/satishtalim/faq.html

Anyway, despite the name we also are open for courses on other
languages, so if one of you would design a course on Clojure, we could
provide our infrastructure for hosting and running it and I would also
help out as an assistant teacher. As far as we see it this could be a
win-win situation, since it would give Clojure newbies a place to go
to while maybe also exposing RL to a new audience.

Now before anybody gets over enthusiastic, please keep in mind that
designing a full course does take quite a bit of time and running it
is only possible if *enough* qualified assistant teachers are willing
to volunteer some of their free-time for the benefit of the Clojure
community.

In case you have any more questions, please feel free to ask them here
or via a personal email (if possible keep Satish - the founder of RL -
in the CC), I'd be happy to help out as much as I can, since recently
I didn't find nearly as much time for Clojure as I'd like to.

Cheers,
Michael
-- 
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: Why recur?

2010-01-18 Thread Sean Devlin
I'm confused.  Shouldn't the inner loop have the proper conditionals
to break out of itself properly instead?

On Jan 18, 8:48 am, Alex Ott alex...@gmail.com wrote:
 Re

 Konrad Hinsen  at Mon, 18 Jan 2010 12:23:58 +0100 wrote:
  KH On 18.01.2010, at 12:03, Alex Ott wrote:

   I have a question to Rich - are there plans to introduce named
   loop/recur?  In Scheme it very handy to create named let, and create 
 nested
   loops.  Currently in Clojure, I need to split nested loop into separate
   function, that not so often good

  KH Nested loops work perfectly fine in Clojure:

 But this will not allow to jump to outer loop from inside of inner loop...

  KH (defn print-pairs [seq1 seq2]
  KH   (loop [s1 seq1]
  KH     (when (seq s1)
  KH       (loop [s2 seq2]
  KH         (when (seq s2)
  KH           (prn (first s1) (first s2))
  KH           (recur (rest s2
  KH       (recur (rest s1)

  KH (print-pairs [1 2] [a b])

 --
 With best wishes, Alex Ott, MBAhttp://alexott.blogspot.com/         
 http://xtalk.msk.su/~ott/http://alexott-ru.blogspot.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

infinite loop print out of cyclic structure at repl

2010-01-18 Thread Raoul Duke
hi,

hmmm, i wish there were a way (or that it was the default) to tell the
repl to not continue to loop for ever over things it has already
printed out when i eval something that is a cyclic thing. anybody
have a patch, or thought on this?

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

Re: Case-insensitive map?

2010-01-18 Thread C. Florian Ebeling
 Is there a good way to make a map case-insensitive for string keys? I
 first thought just wrapping some function around it would be it, but
 when I try it, it is really a bit more involved. Has anyone done this,
 or is there a recommended way?

 Do you want real case-insensitivity (i.e., you preserve the case of some
 item in the map), or just down-casing?

 To do that you need to alter the hashing and equality functions of the map.

Yes, good point. I think the reasonable thing to do is downcasing for
my application.


 I have a Java implementation of a DowncaseMap which downcases String keys
 (and thus avoids specifying the hash function), but obviously the output is
 lowercase. I'm happy to share.

Thanks for the offer :) But I don't really want to resort to Java. I
was hoping for something transparant, but I realize now the
implications.

Florian



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

Re: infinite loop print out of cyclic structure at repl

2010-01-18 Thread Mark Hamstra
See *print-length* and *print-level* in the core API.


On Jan 18, 4:22 pm, Raoul Duke rao...@gmail.com wrote:
 hi,

 hmmm, i wish there were a way (or that it was the default) to tell the
 repl to not continue to loop for ever over things it has already
 printed out when i eval something that is a cyclic thing. anybody
 have a patch, or thought on this?

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

Manual Installation (not using ELPA) of swank-clojure

2010-01-18 Thread Brent Millare
I made a write up of my experiences setting up swank-clojure from
scratch. Although my method ignores matching the versions up because
all is built from the current sources (which can potential cause parts
of swank to break), it should at least point in the generally right
direction. Hopefully this should clear things up for some.

http://tentclube.blogspot.com/2010/01/manual-installation-not-using-elpa-of.html

Best,
Brent Millare
-- 
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: infinite loop print out of cyclic structure at repl

2010-01-18 Thread Chouser
 On Jan 18, 4:22 pm, Raoul Duke rao...@gmail.com wrote:
 hi,

 hmmm, i wish there were a way (or that it was the default) to tell the
 repl to not continue to loop for ever over things it has already
 printed out when i eval something that is a cyclic thing. anybody
 have a patch, or thought on this?

On Mon, Jan 18, 2010 at 4:38 PM, Mark Hamstra markhams...@gmail.com wrote:
 See *print-length* and *print-level* in the core API.

Or if you want unlimited depth, but want to avoid printing the
value of any reference object more than once, you can try this
little thing I hacked together a while ago:

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

Note that it has to keep a reference to every IDeref object it
sees while it's printing, in order to detect duplicates.

--Chouser
http://joyofclojure.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: Case-insensitive map?

2010-01-18 Thread pmf
On Jan 18, 1:59 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
 There's a library in clojure.contrib which allows to create your own
 getters / setters for maps :

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

Not wanting to interrupt this thread, but this is amazing! I could
have used this a dozen of times in the past few months. Thanks for
pointing this out!
-- 
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: infinite loop print out of cyclic structure at repl

2010-01-18 Thread Raoul Duke
 Mark
 Chouser

thanks, all.
-- 
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: StackOverflowError possible with seq ?

2010-01-18 Thread mudphone
Hi Robert,

Thanks for your reply!  Very interesting.  I see what you're saying.
But, your code results in a OutOfMemoryError, rather than a
StackOverflow.

At least, that's what I see on my machine.  Are you seeing the same?

Is there some way that this same concept could lead to a
StackOverflow?

Thanks,
Kyle

On Jan 18, 6:36 am, kirschkernkissen robert.ste...@gmail.com wrote:
 Hi Kyle!

 I encountered the same problem:

 (defn stack-fail
   returns an empty lazy seq
   [l i]
   (if ( i 0)
     (recur (remove #{1} (concat l '(1))) (dec i))
     l))

 (def foo (stack-fail () 1000))

 foo
 ; Evaluation aborted.

 if you call a non-lazy function (e.g. doall) on the collection from
 time to time this wont happen.

 Rgds, Robert

 On 15 Jan., 00:05, mudphone kyle...@gmail.com wrote:



  Is it possible that the Clojure core seq function can cause a stack
  overflow (since it calls itself)?

  Or is there some other manner in which misuse of a lazy seq could
  cause this?  In the stack trace below, I'm seeing repeated calls to
  seq in clojure core, until the stack is blown.

  Thanks,
  Kyle

  Exception in thread main java.lang.StackOverflowError
  (session_master_boot.clj:19)
          at clojure.lang.Compiler.eval(Compiler.java:4617)
          at clojure.lang.Compiler.eval(Compiler.java:4593)
          at clojure.lang.Compiler.load(Compiler.java:4931)
          at clojure.lang.Compiler.loadFile(Compiler.java:4898)
          at clojure.main$load_script__6637.invoke(main.clj:210)
          at clojure.main$init_opt__6640.invoke(main.clj:215)
          at clojure.main$initialize__6650.invoke(main.clj:243)
          at clojure.main$null_opt__6672.invoke(main.clj:268)
          at clojure.main$legacy_script__6687.invoke(main.clj:299)
          at clojure.lang.Var.invoke(Var.java:359)
          at clojure.main.legacy_script(main.java:32)
          at clojure.lang.Script.main(Script.java:20)
  Caused by: java.lang.StackOverflowError
          at clojure.core$seq__3835.invoke(core.clj:103)
          at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
          at clojure.lang.LazySeq.sval(LazySeq.java:42)
          at clojure.lang.LazySeq.seq(LazySeq.java:56)
          at clojure.lang.RT.seq(RT.java:440)
          at clojure.core$seq__3835.invoke(core.clj:103)
          at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
          at clojure.lang.LazySeq.sval(LazySeq.java:42)
          at clojure.lang.LazySeq.seq(LazySeq.java:56)
          at clojure.lang.RT.seq(RT.java:440)
          at clojure.core$seq__3835.invoke(core.clj:103)
          at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
          at clojure.lang.LazySeq.sval(LazySeq.java:42)
          at clojure.lang.LazySeq.seq(LazySeq.java:56)
          at clojure.lang.RT.seq(RT.java:440)
          at clojure.core$seq__3835.invoke(core.clj:103)
          at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
          at clojure.lang.LazySeq.sval(LazySeq.java:42)
          at clojure.lang.LazySeq.seq(LazySeq.java:56)
          at clojure.lang.RT.seq(RT.java:440)
-- 
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: Manual Installation (not using ELPA) of swank-clojure

2010-01-18 Thread Mark Hamstra
Does from scratch assume Slime is already installed?


On Jan 18, 4:42 pm, Brent Millare brent.mill...@gmail.com wrote:
 I made a write up of my experiences setting up swank-clojure from
 scratch. Although my method ignores matching the versions up because
 all is built from the current sources (which can potential cause parts
 of swank to break), it should at least point in the generally right
 direction. Hopefully this should clear things up for some.

 http://tentclube.blogspot.com/2010/01/manual-installation-not-using-e...

 Best,
 Brent Millare
-- 
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: Manual Installation (not using ELPA) of swank-clojure

2010-01-18 Thread Brent Millare
The basic install prerequisites are emacs, slime, java, and git.

On Jan 18, 6:22 pm, Mark Hamstra markhams...@gmail.com wrote:
 Does from scratch assume Slime is already installed?

 On Jan 18, 4:42 pm, Brent Millare brent.mill...@gmail.com wrote:

  I made a write up of my experiences setting up swank-clojure from
  scratch. Although my method ignores matching the versions up because
  all is built from the current sources (which can potential cause parts
  of swank to break), it should at least point in the generally right
  direction. Hopefully this should clear things up for some.

 http://tentclube.blogspot.com/2010/01/manual-installation-not-using-e...

  Best,
  Brent Millare
-- 
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: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 16, 7:33 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
 For the non lazy version , maybe using clojure.zip would help not blow
 up the stack ?

 (using clojure.zip/zip + a loop with recur on clojure.zip/next) ?

I've just tried it and it appears to be equivalent to the lazy walk
version, which I think is fully lazy after all (not tested, see
below).

(defn lazy-recursive-string-walk-with-zipper [f form]
  (loop [loc (z/seq-zip form)]
(if (z/end? loc)
  (z/root loc)
  (recur (z/next
   (if (string? (z/node loc))
 (zip/replace loc (f (z/node loc)))
 loc))

The thing is, I should learn to read stack traces more carefully! The
StackOverflowError was coming from my test function.

(def pit (iterate list bottom!))

(defn test-walk [walker shallowest deepest]
  (doseq [depth (range shallowest deepest)]
(pprint (walker #(str depth  reached  %)
  (last (take depth pit))

It's the iterate function that was throwing the error, while used
directly it can generate a 1000 lists deep nested list, but when used
in the test-walk function it only reach 828. The stack overflow make
more sense now, yet the stack trace is not easy to decipher.

No message.
  [Thrown class java.lang.StackOverflowError]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: clojure.lang.PersistentHashMap$BitmapIndexedNode.index
(PersistentHashMap.java:467)
  1: clojure.lang.PersistentHashMap$BitmapIndexedNode.assoc
(PersistentHashMap.java:616)
  2: clojure.lang.PersistentHashMap$TransientHashMap.doAssoc
(PersistentHashMap.java:222)
  3: clojure.lang.ATransientMap.assoc(ATransientMap.java:64)
  4: clojure.lang.PersistentHashMap.create(PersistentHashMap.java:79)
  5: clojure.core$hash_map__4297.doInvoke(core.clj:279)
  6: clojure.lang.RestFn.invoke(RestFn.java:426)
  7: clojure.core$print_sequential__6823.invoke(core_print.clj:37)
  8: clojure.core$fn__6908.invoke(core_print.clj:136)
  9: clojure.lang.MultiFn.invoke(MultiFn.java:161)
 10: clojure.core$pr_on__5416.invoke(core.clj:2336)
 11: clojure.core$print_sequential__6823.invoke(core_print.clj:54)
 12: clojure.core$fn__6908.invoke(core_print.clj:136)
 13: clojure.lang.MultiFn.invoke(MultiFn.java:161)
 14: clojure.core$pr_on__5416.invoke(core.clj:2336)

I'll look a little deeper at this error and keep this post updated. In
the meantime, has anyone got an idea to replace iterate for creating
mock nested lists to test recursive-string-walk?

P.S.: Finally learned to use zippers and they can be very useful, like
that concept a lot. Found it intimidating at first but I've just read
an excellent write-up about them today:

http://scienceblogs.com/goodmath/2010/01/zippers_making_functional_upda.php?

Thanks

- budu
-- 
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: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
I've found the real problem. The overflow was coming from recursion
between pr-on and print-method. It must be that way because it's not
really useful to print such deeply nested data structure anyway.

On Jan 18, 7:06 pm, Nicolas Buduroi nbudu...@gmail.com wrote:
 On Jan 16, 7:33 pm, Laurent PETIT laurent.pe...@gmail.com wrote:

  For the non lazy version , maybe using clojure.zip would help not blow
  up the stack ?

  (using clojure.zip/zip + a loop with recur on clojure.zip/next) ?

 I've just tried it and it appears to be equivalent to the lazy walk
 version, which I think is fully lazy after all (not tested, see
 below).

 (defn lazy-recursive-string-walk-with-zipper [f form]
   (loop [loc (z/seq-zip form)]
     (if (z/end? loc)
       (z/root loc)
       (recur (z/next
                (if (string? (z/node loc))
                  (zip/replace loc (f (z/node loc)))
                  loc))

 The thing is, I should learn to read stack traces more carefully! The
 StackOverflowError was coming from my test function.

 (def pit (iterate list bottom!))

 (defn test-walk [walker shallowest deepest]
   (doseq [depth (range shallowest deepest)]
     (pprint (walker #(str depth  reached  %)
               (last (take depth pit))

 It's the iterate function that was throwing the error, while used
 directly it can generate a 1000 lists deep nested list, but when used
 in the test-walk function it only reach 828. The stack overflow make
 more sense now, yet the stack trace is not easy to decipher.

 No message.
   [Thrown class java.lang.StackOverflowError]

 Restarts:
  0: [ABORT] Return to SLIME's top level.

 Backtrace:
   0: clojure.lang.PersistentHashMap$BitmapIndexedNode.index
 (PersistentHashMap.java:467)
   1: clojure.lang.PersistentHashMap$BitmapIndexedNode.assoc
 (PersistentHashMap.java:616)
   2: clojure.lang.PersistentHashMap$TransientHashMap.doAssoc
 (PersistentHashMap.java:222)
   3: clojure.lang.ATransientMap.assoc(ATransientMap.java:64)
   4: clojure.lang.PersistentHashMap.create(PersistentHashMap.java:79)
   5: clojure.core$hash_map__4297.doInvoke(core.clj:279)
   6: clojure.lang.RestFn.invoke(RestFn.java:426)
   7: clojure.core$print_sequential__6823.invoke(core_print.clj:37)
   8: clojure.core$fn__6908.invoke(core_print.clj:136)
   9: clojure.lang.MultiFn.invoke(MultiFn.java:161)
  10: clojure.core$pr_on__5416.invoke(core.clj:2336)
  11: clojure.core$print_sequential__6823.invoke(core_print.clj:54)
  12: clojure.core$fn__6908.invoke(core_print.clj:136)
  13: clojure.lang.MultiFn.invoke(MultiFn.java:161)
  14: clojure.core$pr_on__5416.invoke(core.clj:2336)

 I'll look a little deeper at this error and keep this post updated. In
 the meantime, has anyone got an idea to replace iterate for creating
 mock nested lists to test recursive-string-walk?

 P.S.: Finally learned to use zippers and they can be very useful, like
 that concept a lot. Found it intimidating at first but I've just read
 an excellent write-up about them today:

 http://scienceblogs.com/goodmath/2010/01/zippers_making_functional_up...

 Thanks

 - budu
-- 
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: Case-insensitive map?

2010-01-18 Thread Howard Lewis Ship
Tapestry 5 includes a case-insenstive Map and the basic idea can be
adapted. It was important to that code base that the case of keys be
kept, but that lookup by key be case insensitive. The hash code is
based on a case normalized version of the true key, and comparisons
are based on equalsIgnoreCase().

I haven't looked at how hard this would be to implement in Clojure; it
would be nice if there was those features (let me specify how to hash
keys, let me specify how to compare keys).

On Mon, Jan 18, 2010 at 2:22 PM, pmf phil.fr...@gmx.de wrote:
 On Jan 18, 1:59 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
 There's a library in clojure.contrib which allows to create your own
 getters / setters for maps :

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

 Not wanting to interrupt this thread, but this is amazing! I could
 have used this a dozen of times in the past few months. Thanks for
 pointing this out!

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




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.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: Case-insensitive map?

2010-01-18 Thread Richard Newman

I haven't looked at how hard this would be to implement in Clojure; it
would be nice if there was those features (let me specify how to hash
keys, let me specify how to compare keys).


PersistentHashMap calls Util.hash(key), which calls key.hashCode().

You could use fnmap to replace input Strings with a  
CaseInsensitiveString implementation that does hashing and comparison  
case-insensitively...


Otherwise you'd probably need to subclass PHM and reimplement any  
method that calls Util.hash.
-- 
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

hash literal oddity?

2010-01-18 Thread Stuart Halloway

Is this expected behavior?

{1 this 1 is 1 strange}
= {1 this, 1 is, 1 strange}

(into {} {1 this 1 is 1 strange})
= {1 strange}

{1 this 1 is 1 strange 1 but 1 if 1 I 1 try 1 hard 1  
enough}

= {1 enough}

Stu






--
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 literal oddity?

2010-01-18 Thread Kevin Downey
what you are seeing is the transition from arraymap to hashmap

On Mon, Jan 18, 2010 at 6:46 PM, Stuart Halloway
stuart.hallo...@gmail.com wrote:
 Is this expected behavior?

 {1 this 1 is 1 strange}
 = {1 this, 1 is, 1 strange}

 (into {} {1 this 1 is 1 strange})
 = {1 strange}

 {1 this 1 is 1 strange 1 but 1 if 1 I 1 try 1 hard 1
 enough}
 = {1 enough}

 Stu






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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?
-- 
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 literal oddity?

2010-01-18 Thread Fogus
 = {1 this, 1 is, 1 strange}

The literal representation is just blasted into an array map when the
number of entries are below a certain threshold (8 maybe).  I think
the general view is that a literal with duplicate keys is the error
and to check for dups would sacrifice speed.

 (into {} {1 this 1 is 1 strange})

This uses a regular hash map.

 {1 this 1 is 1 strange 1 but 1 if 1 I 1 try 1 hard 1  
 enough}

I guess the threshold is indeed 8.

-m
-- 
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 literal oddity?

2010-01-18 Thread ataggart


On Jan 18, 6:46 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Is this expected behavior?

 {1 this 1 is 1 strange}
 = {1 this, 1 is, 1 strange}

This can only happen with literal maps containing 8 or fewer entries.
Rich has commented on it elsewhere.
-- 
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 literal oddity?

2010-01-18 Thread Fogus
 This uses a regular hash map.

No it doesn't apparently... it uses conj instead.

-m
-- 
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: Lazy recursive walk.

2010-01-18 Thread Tom Hicks
Hey, congratulations on finding and fixing the problem!

And thanks for the great link to the zipper explanationzippers
were
at the top of my list to learn (seriously). Did you catch this other
useful
link (in the comments of the article you provided)?

http://okmij.org/ftp/Computation/Continuations.html#zipper

This guy has a wealth of great information and references
to related topics.
regards,
-tom


On Jan 18, 7:31 pm, Nicolas Buduroi nbudu...@gmail.com wrote:
 I've now changed my test method to this.

 (def pit (iterate list bottom!))

 (defn get-bottom [p]
   (loop [p (first p)]
     (if (seq? p) (recur (first p)) p)))

 (defn test-walk [walker shallowest deepest]
   (doseq [depth (range shallowest deepest)]
     (println (get-bottom
                (walker #(str depth  reached  %)
                  (lazy-seq (last (take depth pit

 And now everything make lot more sense. A classic case of good code
 with bad test which make you search for some imaginary bug. So always
 carefully read your stack traces! Here's some benchmarking I've done
 with the above versions.

 user (time (test-walk lazy-recursive-string-walk-with-zipper 10
 11))
 10 reached bottom!
 Elapsed time: 1368.337794 msecs

 user (time (test-walk lazy-recursive-string-walk 10 11))
 10 reached bottom!
 Elapsed time: 233.80888 msecs

 user (time (test-walk really-lazy-recursive-string-walk 10
 11))
 10 reached bottom!
 Elapsed time: 223.631872 msecs

 The one with a zipper is the slowest, zippers being much more capable
 than just walking data structure, so it's normal. The first lazy
 version is more than five faster and the one using Tom Hicks lazy-walk
 function is slightly faster.

 - budu
-- 
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 literal oddity?

2010-01-18 Thread Stuart Halloway

= {1 this, 1 is, 1 strange}


The literal representation is just blasted into an array map when the
number of entries are below a certain threshold (8 maybe).  I think
the general view is that a literal with duplicate keys is the error
and to check for dups would sacrifice speed.


The first part I knew, just wanted to verify that the second part was  
expected. Thanks!


Stu

--
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: Why recur?

2010-01-18 Thread Timothy Pratley
2010/1/18 Alex Ott alex...@gmail.com

 But this will not allow to jump to outer loop from inside of inner loop...


If you require mutual recursion, letfn might be your answer
See example here:
http://groups.google.com/group/clojure/browse_thread/thread/a7aad1d5b94db748
-- 
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 literal oddity?

2010-01-18 Thread Timothy Pratley
Here is the previous discussion about duplicate keys in arraymaps, just for
reference:
http://groups.google.com/group/clojure/browse_thread/thread/5a38a6b61b09e025
-- 
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: Good refs on concurrency?

2010-01-18 Thread David Beckwith
By the way, I made the suggestion to publish a concurrency specific
book to Pragmatic Studios, and surprisingly Dave Thomas (of Ruby-world
fame: http://pragprog.com/titles/rails2/agile-web-development-with-rails
) wrote back and agreed.  He said that he's looking for an author.
(See below.)  So, if any of you concurrency gurus want to write a
Pragmatic Concurrency book, email Dave.  Plus you're guaranteed to
have at least one customer so far...

Feel free to email me if you want to contact Dave.  (I don't want to
publish his address here due to spam.)

***
  I think given CPU speeds plotted against Moore's law is starting to
 flatten out, concurrency is becoming a very current topic.  It's being
 addressed by languages like Clojure, Erlang, and Go, but I haven't
 found any good general books that talks about concurrency in a good,
 practical, yet introductory way.  Basically, I would like to see
 chapter 6 of Stuart Halloway's Programming Clojure expanded into an
 entire book.

David

I agree: I'd love to see one or more books on concurrency in practice.
In the end, it comes down to finding the right authors to do the job
justice.

We'll keep our eyes open.




On Jan 18, 6:14 am, Erik Price erikpr...@gmail.com wrote:
 On Sat, Jan 16, 2010 at 7:02 PM, David Beckwith

 thirdreplica...@gmail.com wrote:
  Can you guys recommend any good books, articles or code on
  concurrency?  I'm new to concurrency issues, and just finished the
  Halloway book, so it would be great to have an introductory reference
  with lots of examples of how to make your CPUs all work happily
  together.

 I should add that if you're more interested in learning only how
 Clojure addresses concurrency issues, rather than a book on
 concurrency topics, the best thing to read is others' code. Look for
 the more interesting-looking Clojure projects on Github and Bitbucket
 and study the code, see how agents and refs are actually being used.
 Read the back issues of some of the Clojure blogs like bestinclass.dk
 if you haven't already.

 e
-- 
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: Good refs on concurrency?

2010-01-18 Thread David Beckwith
And btw, thanks Erik, Gene, and Abhi for your suggestions!  I'll look
at those.
David :)


On Jan 18, 6:14 am, Erik Price erikpr...@gmail.com wrote:
 On Sat, Jan 16, 2010 at 7:02 PM, David Beckwith

 thirdreplica...@gmail.com wrote:
  Can you guys recommend any good books, articles or code on
  concurrency?  I'm new to concurrency issues, and just finished the
  Halloway book, so it would be great to have an introductory reference
  with lots of examples of how to make your CPUs all work happily
  together.

 I should add that if you're more interested in learning only how
 Clojure addresses concurrency issues, rather than a book on
 concurrency topics, the best thing to read is others' code. Look for
 the more interesting-looking Clojure projects on Github and Bitbucket
 and study the code, see how agents and refs are actually being used.
 Read the back issues of some of the Clojure blogs like bestinclass.dk
 if you haven't already.

 e
-- 
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: Couverjure: an attempt at a direct bridge between Clojure and Cocoa

2010-01-18 Thread xster


On Jan 17, 11:51 pm, Mark Allerton mark.aller...@gmail.com wrote:
 Hi all,

 I've been hacking on a bridge between Clojure and Cocoa, and have been
 prompted to break cover by recent discussion of the subject of Objective-C
 interfacing here on this list.


This is fantastic!  In you README.md, you provide the reasons why this
is better than a Java-to-Cocoa bridge.



Apple's Java-Cocoa bridge was a failure - and in hindsight it's not
that hard to see why. Despite being an Ahead-of-Time compiled language
based on C, Objective-C's runtime is in fact quite a bit more dynamic
than Java's - and this left Java developers at a disadvantage, being
made to write more code to work around the impedance mismatch.

So why might Clojure be a better match? As a dynamic language it may
be a better fit for the dynamic aspects of the Objective-C runtime. In
addition, as a lisp, Clojure has few ties between programming paradigm
and syntax, making it easier to adopt Objective-C's paradigms directly
in Clojure code.



I think this is spot on. This is one reason why I have never had much
interest in working with Apple's Java Cocoa bridge.  The code always
felt clumsy and awkward compared to the Objective-C version.  I'm
certain that, as you say, that the dynamic nature of Clojure is a
better fit with Objective-C than Java.  Indeed, this is why LispWorks
has an Objective-C bridge for Cocoa, and why so many Scheme projects
also have Objective-C bridges.

As for Why is this a terrible idea?:



There are some other reasons Java was a bad fit for Cocoa, and Clojure
doesn't fix these - namely the memory overhead of the JVM, startup
time and lack of application responsiveness due to JIT compilation and
garbage collection.

-

I think the relatively long start-up time can be tolerated, especially
if the programmer provides some fancy splash screen to distract the
user while the rest of the application loads. The lack of
responsiveness is a more difficult issue to overcome, but if prior
experience with Apple's Java bridge is any guide, the mushy (rather
than crisp) UI responsiveness is tolerable if not ideal.

In the end, I don't think this is a terrible idea by any means. It
provides a great entry point to Clojure integration with Cocoa,
providing a pathway to building superior UIs for Clojure
applications.  Any lingering problems, I'm sure, can be overcome or
remedied in the long-term.
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

clojure box 1.0 failed to connect to emacs server

2010-01-18 Thread limux
when i start the clojure box 1.0, the emacs client window stay on the
top of all the other windows, eventually it display a message **
ERROR ** Timeout wating for server,  but 1.0RC1 no that issue.
-- 
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

Correct mapping from Lisp to Clojure?

2010-01-18 Thread Conrad Taylor
Hi, I'm starting to convert some code over from Lisp to Clojure.
Thus, I was wondering, what's the appropriate mapping for the
following forms:

defvar
defparamater
let*
defconstant
mapcar

BTW, I was able to find the Clojure Programming Tutorials and Tips
but it didn't require the above forms.

Thanks in advance,

-Conrad



-- 
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: Correct mapping from Lisp to Clojure?

2010-01-18 Thread Sean Devlin
Did you watch Rich's video Clojure for Lispers?  That might help

(The only one I can answer for sure is that Clojure's let is CL's
let*)

http://blip.tv/file/1313398

On Jan 18, 10:49 pm, Conrad Taylor conra...@gmail.com wrote:
 Hi, I'm starting to convert some code over from Lisp to Clojure.
 Thus, I was wondering, what's the appropriate mapping for the
 following forms:

 defvar
 defparamater
 let*
 defconstant
 mapcar

 BTW, I was able to find the Clojure Programming Tutorials and Tips
 but it didn't require the above forms.

 Thanks in advance,

 -Conrad
-- 
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: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 18, 10:55 pm, Tom Hicks hickstoh...@gmail.com wrote:
 Hey, congratulations on finding and fixing the problem!

 And thanks for the great link to the zipper explanationzippers
 were
 at the top of my list to learn (seriously). Did you catch this other
 useful
 link (in the comments of the article you provided)?

 http://okmij.org/ftp/Computation/Continuations.html#zipper

 This guy has a wealth of great information and references
 to related topics.

Yes, I already knew about Oleg's FTP site, a timeless resource about
lots of (strange) programming concept. Didn't visited for a long time.

- budu
-- 
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: Correct mapping from Lisp to Clojure?

2010-01-18 Thread Richard Newman

defvar
defparamater


def, pretty much. (Some of the niceties of CL semantics don't really  
apply.)



let*


let.


defconstant


No equivalent. Use def and allow the JIT to do the is this constant?  
work.



mapcar


map.

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