Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min/max operator #66

Closed
satyr opened this issue Jun 14, 2011 · 4 comments
Closed

min/max operator #66

satyr opened this issue Jun 14, 2011 · 4 comments
Milestone

Comments

@satyr
Copy link
Owner

satyr commented Jun 14, 2011

http://perlgeek.de/blog-en/perl-5-to-6/27-common-idioms.html#Numbers

<? for min, >? for max (or inverse?)

a <? b  # if a < b then a else b
a >? b  # if a > b then a else b

inRange = lower >? x <? upper

x >?= 0
x <?= 10
assert 0 <= x <= 10
@troyhen
Copy link

troyhen commented Jun 14, 2011

Why wouldn't you just use more standard, mathematical expressions for in-range comparisons?
in_range = min_exclusive < x < max_exclusive
in_range = min_inclusive <= x < max_exclusive
in_range = min_exclusive < x <= max_inclusive
in_range = min_inclusive <= x <= max_inclusive

@satyr
Copy link
Owner Author

satyr commented Jun 14, 2011

Why wouldn't you just use more standard, mathematical expressions for in-range comparisons?
in_range = min_exclusive < x < max_exclusive
...

Those are already working as chained comparisons.

@troyhen
Copy link

troyhen commented Jun 14, 2011

Good. I thought I read that. I was just commenting on the in-range line.

inRange = lower >? x <? upper

Then what is the purpose of this syntax and how does it differ from this:

inRange = lower < x < upper

@satyr
Copy link
Owner Author

satyr commented Jun 14, 2011

what is the purpose of this syntax

Read the Perl 6 article and/or the rest of sample code above?

@satyr satyr closed this as completed in 6bbde55 Jun 15, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants