reducta-ops-en
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Syntax:
Category#
reduction
Related#
None.
Examples#
radix/corpus/reference/concept/reducta-ops-en/reducta-ops-en.fab (canonical · concept)#
fn total(tf32[4] a) → f32 {
return reduce via product from a
}
fn big(tf32[4] a) → int {
return reduce via count from a at [i] let s {
return s ≻ 2.0
}
}
fn all_pos(tf32[4] a) → bool {
return reduce via all from a at [i] let s {
return s ≻ 0.5
}
}
fn some_huge(tf32[4] a) → bool {
return reduce via any from a at [i] let s {
return s ≻ 3.5
}
}
fn peak(tf32[4] a, f32 floor) → f32 {
return reduce via max from a at [i] coalesce floor
}
main {
let list<f32> flat ← [3.0, 1.0, 3.0, 2.0]
let tf32[4] a ← flat ↦ tensor<f32, [4]>
print total(a)
print big(a)
print all_pos(a)
print some_huge(a)
print peak(a, 0.0)
}Expected output:
18.0
2
true
false
3.0