Skip to content

Commit

Permalink
use iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Desaulniers committed Jun 12, 2013
1 parent 70d7de8 commit 5005ed3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/test/bench/graph500-bfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,27 @@ mod par {
xs: &[A],
fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool
{
do vec::all(map_slices(xs, || {
let mapped = map_slices(xs, || {
let f = fn_factory();
let result: ~fn(uint, &[A]) -> bool = |base, slice| {
vec::alli(slice, |i, x| {
f(i + base, x)
})
slice.iter().enumerate().all(|(i, x)| f(i + base, x))
};
result
})) |x| { *x }
});
mapped.iter().all(|&x| x)
}

/// Returns true if the function holds for any elements in the vector.
pub fn any<A:Copy + Owned>(
xs: &[A],
fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
do vec::any(map_slices(xs, || {
let mapped = map_slices(xs, || {
let f = fn_factory();
let result: ~fn(uint, &[A]) -> bool =
|_, slice| vec::any(slice, |x| f(x));
|_, slice| slice.iter().any(f);
result
})) |x| { *x }
});
mapped.iter().any(|&x| x)
}
}

Expand Down

3 comments on commit 5005ed3

@bors
Copy link
Contributor

@bors bors commented on 5005ed3 Jun 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at nickdesaulniers@5005ed3

@bors
Copy link
Contributor

@bors bors commented on 5005ed3 Jun 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nickdesaulniers/rust/removePar = 5005ed3 into auto

@bors
Copy link
Contributor

@bors bors commented on 5005ed3 Jun 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nickdesaulniers/rust/removePar = 5005ed3 into auto failed

Please sign in to comment.