Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-27 Thread Christian Vest Hansen
On Fri, Feb 27, 2009 at 12:47 AM, Allen Rohner wrote: > > >> I agree regarding concatenation as well, but I think the case for >> comparison of non-numerics is still pretty strong. >> >> -Phil > > Are you referring to using <, >, =, with objects that implement > java.lang.Comparable? > > i.e. giv

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 20:18, Phil Hagelberg wrote: > One approach that's been proposed in #clojure is to make these > functions > more capable by default, but then provide a fast-math library that > could > redefine them in terms of numerics-only. I'm a big fan of functions > doing the most helpf

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Eric Tschetter
> I'm not sure of the details since I don't know much about Java, but that > sounds about right. I'm working on a date library, and having to use > functions like earlier? and later? rather than >, <, <=, and >= feels > awkward. You are probably thinking of dates as numerical longs rather than ac

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Phil Hagelberg
Allen Rohner writes: >> I agree regarding concatenation as well, but I think the case for >> comparison of non-numerics is still pretty strong. > > Are you referring to using <, >, =, with objects that implement > java.lang.Comparable? > > i.e. given x.compareTo(y) == -1 > (< x y) > => true > >

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Allen Rohner
If we wrote (add 2 3), there would be no confusion at > all about what (add "foo" 2) should do, because you'd be writing (conj > "foo" (str 2)) I wrote this too hastily. This could more easily be written (str "foo" 2) --Allen --~--~-~--~~~---~--~~ You received th

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Allen Rohner
> I agree regarding concatenation as well, but I think the case for > comparison of non-numerics is still pretty strong. > > -Phil Are you referring to using <, >, =, with objects that implement java.lang.Comparable? i.e. given x.compareTo(y) == -1 (< x y) => true I would find that useful. Al

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Mike Benfield
On Feb 26, 4:56 pm, Peter Wolf wrote: > > So my vote is that String are atomic built in objects, and at least +, < > and > should work with Strings.  The behavior should be just like Java, > so (+ "foo" 2) --> "foo2" I have an HP calculator. (I may get some of the details wrong here, I haven

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Phil Hagelberg
Laurent PETIT writes: > > Concatenation is not addition. I'm almost opposed to numeric operators > > all together. If we wrote (add 2 3), there would be no confusion at > > all about what (add "foo" 2) should do, because you'd be writing (conj > > "foo" (str 2)) > > Agree I agre

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Laurent PETIT
Agree, I even think there *could* be some utility in having the opposite behavior (but I'm not even sure about that) : (+ "1" 2) --> 3 by + trying to cast its non numeric arguments before throwing an exception ... -- Laurent 2009/2/26 Allen Rohner > > > > > > So my vote is that String are at

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Allen Rohner
> > So my vote is that String are atomic built in objects, and at least +, < > and > should work with Strings.  The behavior should be just like Java, > so (+ "foo" 2) --> "foo2" > -1 Concatenation is not addition. I'm almost opposed to numeric operators all together. If we wrote (add 2 3), the

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Peter Wolf
OK had my coffee, and had several thoughts... 1 -- What are Strings? How should the Clojure programmer think about them? Are they sequences, in which case all the sequence functions should work. Or are they atomic built-in types like Integers and Floats? 2 -- There is already some type chec

Re: "Adding" strings

2009-02-26 Thread opus111
Doh! *engage brain BEFORE emailing* Sorry to be not thinking... Coffee now! :-P Sent via BlackBerry from T-Mobile -Original Message- From: Perry Trolard Date: Thu, 26 Feb 2009 11:13:49 To: Clojure Subject: Re: "Adding" strings > Is there any reason that str is

Re: Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Cosmin Stejerean
On Thu, Feb 26, 2009 at 1:18 PM, Phil Hagelberg wrote: > > Peter Wolf writes: > > > Is there a good reason that + can't do the right thing as with other > > Java and scripting languages? I think this would be popular with > > non-LISPers. > > Putting a type check in + would slow down basic math

Mathy operations on non-numerics (was "Adding" strings)

2009-02-26 Thread Phil Hagelberg
Peter Wolf writes: > Is there a good reason that + can't do the right thing as with other > Java and scripting languages? I think this would be popular with > non-LISPers. Putting a type check in + would slow down basic math, and there is a class of user who will complain loudly if basic mat

Re: "Adding" strings

2009-02-26 Thread Perry Trolard
> Is there any reason that str is limited to 2 arguments? It would be > nice to do (str "foo" "bar" "baz") --> "foobarbaz". Try it! (Hint: "With more than one arg, returns the concatenation of the str values of the args.") > Is there a good reason that + can't do the right thing as with other >

Re: "Adding" strings

2009-02-26 Thread Matt Revelle
On Feb 26, 2009, at 2:01 PM, Peter Wolf wrote: > > Thanks all. > > I think appending a bunch of strings is a pretty common operation. > > Is there any reason that str is limited to 2 arguments? It would be > nice to do (str "foo" "bar" "baz") --> "foobarbaz". It does. Try it out. =) > > > Is

Re: "Adding" strings

2009-02-26 Thread Peter Wolf
Thanks all. I think appending a bunch of strings is a pretty common operation. Is there any reason that str is limited to 2 arguments? It would be nice to do (str "foo" "bar" "baz") --> "foobarbaz". Is there a good reason that + can't do the right thing as with other Java and scripting lang

Re: "Adding" strings

2009-02-26 Thread Shawn Hoover
On Thu, Feb 26, 2009 at 11:11 AM, Peter Wolf wrote: > > Hey all, > > What is the idiomatic way to concatenate strings? Here are some things > that I expected to work, but didn't > >(+ "foo" "bah") >(conj "foo" "bah") >(into "foo" "bah") > > For the moment I am doing > >(.concat "

Re: "Adding" strings

2009-02-26 Thread pmf
On Feb 26, 5:11 pm, Peter Wolf wrote: > What is the idiomatic way to concatenate strings?  Here are some things > that I expected to work, but didn't > >     (+ "foo" "bah") >     (conj "foo" "bah") >     (into "foo" "bah") > > For the moment I am doing > >     (.concat "foo" "bah") (str "foo" "

Re: "Adding" strings

2009-02-26 Thread Laurent PETIT
(str "foo" "bah") and if you have a collection you can (apply str coll) HTH, -- Laurent 2009/2/26 Peter Wolf > > Hey all, > > What is the idiomatic way to concatenate strings? Here are some things > that I expected to work, but didn't > >(+ "foo" "bah") >(conj "foo" "bah") >(int

"Adding" strings

2009-02-26 Thread Peter Wolf
Hey all, What is the idiomatic way to concatenate strings? Here are some things that I expected to work, but didn't (+ "foo" "bah") (conj "foo" "bah") (into "foo" "bah") For the moment I am doing (.concat "foo" "bah") But it seems wrong Thanks P --~--~-~--~~-