----- Original Message ----- From: "Stefan Schmiedl" <s / xss.de> Newsgroups: comp.lang.ruby To: "ruby-talk ML" <ruby-talk / ruby-lang.org> Sent: Wednesday, April 24, 2002 2:37 PM Subject: Re: Numberic#prev > Well, then we have two possibilities: > a) there is no String#prev > b) there is a STring#prev with a preference. > > Tell me, folks: How do you feel about the square root? > Useful or not? How would you feel about a String#prev > with a well defined choice at ambiguous places? Clever, Stefan... but let's be honest. The entire set of real numbers is divided into only two pieces, both continuous, with respect to the square root. Actually, I guess you are referring to the fact that a positive number really has two square roots? I see. I thought you were referring to the fact that negatives do not have real square roots. But anyway: I agree with you that a partial implementation of prev might be acceptable. By the way, I prefer the name "pred" (predecessor, to go with "succ" meaning "successor"). This goes back to my Pascal days back in, well, never mind what year. :) Here I'll call it pred since my fingers will try to type it that way anyhow. The people who have looked at it more closely than I, always say that the problem is more tricky than it appears initially. Let me ask these questions: 1. What do we do when we can't figure out a predecessor? Raise an exception? That would be my first guess. 2. Are there cases where String#succ is undefined? What does it do then? 3. What are the major domains where String#succ is defined? "A".."Z", "a".."z", "0".."9", and are there more? 4. Do the rules for concatenation of such strings make things more difficult? For example: Can you guess the value of "Z9".succ ? It is "AA0". Therefore "AA0".pred would have to be "Z9"...