Filter: Difference between revisions

495 bytes added ,  1 year ago
Jakt
(Jakt)
Line 1,743:
 
(That said, note that in a highly parallel computing environment the destruction either happens after the filtering or you have to repeatedly stall the filtering to ensure that some sort of partially filtered result has coherency.)
 
=={{header|Jakt}}==
<syntaxhighlight lang="jakt">
fn filter<T>(anon array: [T], anon filter_function: fn(anon value: T) -> bool) throws -> [T] {
mut result: [T] = []
for value in array {
if filter_function(value) {
result.push(value)
}
}
return result
}
 
fn main() {
mut numbers: [i64] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let filtered = filter(numbers, fn(anon x: i64) -> bool => x % 2 == 0)
println("{}", filtered)
}
</syntaxhighlight>
 
=={{header|Java}}==
89

edits