Tidy up predicate names in libcore. Should close #1431.

This commit is contained in:
Graydon Hoare 2012-04-04 18:01:55 -07:00
parent 4baf2ceae1
commit 2577e3eafc
8 changed files with 35 additions and 35 deletions

View File

@ -19,10 +19,10 @@ pure fn ne(x: i16, y: i16) -> bool { x != y }
pure fn ge(x: i16, y: i16) -> bool { x >= y }
pure fn gt(x: i16, y: i16) -> bool { x > y }
pure fn positive(x: i16) -> bool { x > 0i16 }
pure fn negative(x: i16) -> bool { x < 0i16 }
pure fn nonpositive(x: i16) -> bool { x <= 0i16 }
pure fn nonnegative(x: i16) -> bool { x >= 0i16 }
pure fn is_positive(x: i16) -> bool { x > 0i16 }
pure fn is_negative(x: i16) -> bool { x < 0i16 }
pure fn is_nonpositive(x: i16) -> bool { x <= 0i16 }
pure fn is_nonnegative(x: i16) -> bool { x >= 0i16 }
#[doc = "Iterate over the range [`lo`..`hi`)"]
fn range(lo: i16, hi: i16, it: fn(i16)) {
@ -37,5 +37,5 @@ pure fn compl(i: i16) -> i16 {
#[doc = "Computes the absolute value"]
pure fn abs(i: i16) -> i16 {
if negative(i) { -i } else { i }
if is_negative(i) { -i } else { i }
}

View File

@ -19,10 +19,10 @@ pure fn ne(x: i32, y: i32) -> bool { x != y }
pure fn ge(x: i32, y: i32) -> bool { x >= y }
pure fn gt(x: i32, y: i32) -> bool { x > y }
pure fn positive(x: i32) -> bool { x > 0i32 }
pure fn negative(x: i32) -> bool { x < 0i32 }
pure fn nonpositive(x: i32) -> bool { x <= 0i32 }
pure fn nonnegative(x: i32) -> bool { x >= 0i32 }
pure fn is_positive(x: i32) -> bool { x > 0i32 }
pure fn is_negative(x: i32) -> bool { x < 0i32 }
pure fn is_nonpositive(x: i32) -> bool { x <= 0i32 }
pure fn is_nonnegative(x: i32) -> bool { x >= 0i32 }
#[doc = "Iterate over the range [`lo`..`hi`)"]
fn range(lo: i32, hi: i32, it: fn(i32)) {
@ -37,5 +37,5 @@ pure fn compl(i: i32) -> i32 {
#[doc = "Computes the absolute value"]
pure fn abs(i: i32) -> i32 {
if negative(i) { -i } else { i }
if is_negative(i) { -i } else { i }
}

View File

@ -19,10 +19,10 @@ pure fn ne(x: i64, y: i64) -> bool { x != y }
pure fn ge(x: i64, y: i64) -> bool { x >= y }
pure fn gt(x: i64, y: i64) -> bool { x > y }
pure fn positive(x: i64) -> bool { x > 0i64 }
pure fn negative(x: i64) -> bool { x < 0i64 }
pure fn nonpositive(x: i64) -> bool { x <= 0i64 }
pure fn nonnegative(x: i64) -> bool { x >= 0i64 }
pure fn is_positive(x: i64) -> bool { x > 0i64 }
pure fn is_negative(x: i64) -> bool { x < 0i64 }
pure fn is_nonpositive(x: i64) -> bool { x <= 0i64 }
pure fn is_nonnegative(x: i64) -> bool { x >= 0i64 }
#[doc = "Iterate over the range [`lo`..`hi`)"]
fn range(lo: i64, hi: i64, it: fn(i64)) {
@ -37,5 +37,5 @@ pure fn compl(i: i64) -> i64 {
#[doc = "Computes the absolute value"]
pure fn abs(i: i64) -> i64 {
if negative(i) { -i } else { i }
if is_negative(i) { -i } else { i }
}

View File

@ -19,10 +19,10 @@ pure fn ne(x: i8, y: i8) -> bool { x != y }
pure fn ge(x: i8, y: i8) -> bool { x >= y }
pure fn gt(x: i8, y: i8) -> bool { x > y }
pure fn positive(x: i8) -> bool { x > 0i8 }
pure fn negative(x: i8) -> bool { x < 0i8 }
pure fn nonpositive(x: i8) -> bool { x <= 0i8 }
pure fn nonnegative(x: i8) -> bool { x >= 0i8 }
pure fn is_positive(x: i8) -> bool { x > 0i8 }
pure fn is_negative(x: i8) -> bool { x < 0i8 }
pure fn is_nonpositive(x: i8) -> bool { x <= 0i8 }
pure fn is_nonnegative(x: i8) -> bool { x >= 0i8 }
#[doc = "Iterate over the range [`lo`..`hi`)"]
fn range(lo: i8, hi: i8, it: fn(i8)) {
@ -37,5 +37,5 @@ pure fn compl(i: i8) -> i8 {
#[doc = "Computes the absolute value"]
pure fn abs(i: i8) -> i8 {
if negative(i) { -i } else { i }
if is_negative(i) { -i } else { i }
}

View File

@ -30,10 +30,10 @@ pure fn ne(x: int, y: int) -> bool { ret x != y; }
pure fn ge(x: int, y: int) -> bool { ret x >= y; }
pure fn gt(x: int, y: int) -> bool { ret x > y; }
pure fn positive(x: int) -> bool { ret x > 0; }
pure fn negative(x: int) -> bool { ret x < 0; }
pure fn nonpositive(x: int) -> bool { ret x <= 0; }
pure fn nonnegative(x: int) -> bool { ret x >= 0; }
pure fn is_positive(x: int) -> bool { ret x > 0; }
pure fn is_negative(x: int) -> bool { ret x < 0; }
pure fn is_nonpositive(x: int) -> bool { ret x <= 0; }
pure fn is_nonnegative(x: int) -> bool { ret x >= 0; }
#[doc = "Produce a uint suitable for use in a hash table"]
pure fn hash(x: int) -> uint { ret x as uint; }
@ -112,7 +112,7 @@ pure fn compl(i: int) -> int {
#[doc = "Computes the absolute value"]
fn abs(i: int) -> int {
if negative(i) { -i } else { i }
if is_negative(i) { -i } else { i }
}
#[test]

View File

@ -44,7 +44,7 @@ pure fn get_err<T, U: copy>(res: result<T, U>) -> U {
}
#[doc = "Returns true if the result is `ok`"]
pure fn success<T, U>(res: result<T, U>) -> bool {
pure fn is_success<T, U>(res: result<T, U>) -> bool {
alt res {
ok(_) { true }
err(_) { false }
@ -52,8 +52,8 @@ pure fn success<T, U>(res: result<T, U>) -> bool {
}
#[doc = "Returns true if the result is `error`"]
pure fn failure<T, U>(res: result<T, U>) -> bool {
!success(res)
pure fn is_failure<T, U>(res: result<T, U>) -> bool {
!is_success(res)
}
#[doc = "
@ -113,9 +113,9 @@ impl extensions<T:copy, E:copy> for result<T,E> {
fn get_err() -> E { get_err(self) }
fn success() -> bool { success(self) }
fn is_success() -> bool { is_success(self) }
fn failure() -> bool { failure(self) }
fn is_failure() -> bool { is_failure(self) }
fn chain<U:copy>(op: fn(T) -> result<U,E>) -> result<U,E> {
chain(self, op)

View File

@ -19,10 +19,10 @@ pure fn ne(x: u16, y: u16) -> bool { x != y }
pure fn ge(x: u16, y: u16) -> bool { x >= y }
pure fn gt(x: u16, y: u16) -> bool { x > y }
pure fn positive(x: u16) -> bool { x > 0u16 }
pure fn negative(x: u16) -> bool { x < 0u16 }
pure fn nonpositive(x: u16) -> bool { x <= 0u16 }
pure fn nonnegative(x: u16) -> bool { x >= 0u16 }
pure fn is_positive(x: u16) -> bool { x > 0u16 }
pure fn is_negative(x: u16) -> bool { x < 0u16 }
pure fn is_nonpositive(x: u16) -> bool { x <= 0u16 }
pure fn is_nonnegative(x: u16) -> bool { x >= 0u16 }
#[doc = "Iterate over the range [`lo`..`hi`)"]
fn range(lo: u16, hi: u16, it: fn(u16)) {

View File

@ -2,7 +2,7 @@
fn adder(+x: @int, +y: @int) -> int { ret *x + *y; }
fn failer() -> @int { fail; }
fn main() {
assert(result::failure(task::try {||
assert(result::is_failure(task::try {||
adder(@2, failer()); ()
}));
}