Jump to content

Exclusive Range for a Case Structure


Recommended Posts

I looked around and was surprised to find this hasn't been mentioned anywhere. By default, you can create numeric ranges by setting the case to be, say, "..0" to include zero and any number less than zero. I think it'd be handy to have exclusive ranges as well. Yes, there was always alternate ways to implement the logic, but that can get messy. Can't come up with any good notation for it, though. Maybe "1.,10" is the same as [1,10)?

Link to comment

QUOTE (asbo @ Apr 24 2009, 11:35 AM)

You mean like this:

post-11268-1240591236.png?width=400

Already in there. Darren had a nugget about these case structures here. Check it out. There's lots of good info in it.

EDIT: I just figured out that you didn't want to include the 10 in that case :headbang: . That would be interesting. But the case structure can't handle floating points, so therefore you would have to use "1..9".

Link to comment

I see what you mean about the floating point; I suppose it would only really be useful for cases involving zero and having a floating point input. For example, (-inf,0] and (0,inf) - the second case would exclude zero - with an input of 0.01. Since it has to be typecast to be used by the case statement, will it be coerced to 0 or to 1? Obviously, my intention would be that it be coerced to 1.

Maybe I should just change the suggestion to be "Use floating point in Case Statements" :P

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.