Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

reducta-ops

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Syntax:

Category#

collection

None.

Examples#

radix/corpus/summa/reducta-ops.fab (canonical · concept)#

fn summa_tot(tensor<f32, [4]> a) → f32 {
    return reduce via sum from a
}

fn factum_tot(tensor<f32, [4]> a) → f32 {
    return reduce via product from a
}

fn maxima_tot(tensor<f32, [4]> a) → f32 {
    return reduce via max from a
}

fn minima_tot(tensor<f32, [4]> a) → f32 {
    return reduce via min from a at [i]
}

fn maxima_vacua() → f32 {
    let tf32[0] v ← empty
    return reduce via max from v at [i] coalesce -∞
}

fn numera_maiora(tensor<f32, [4]> a) → int {
    return reduce via count from a at [i] let s {
        return s ≻ 2.0
    }
}

fn omnes_positivi(tensor<f32, [4]> a) → bool {
    return reduce via all from a at [i] let s {
        return s ≻ 0.5
    }
}

fn omnes_maiores(tensor<f32, [4]> a) → bool {
    return reduce via all from a at [i] let s {
        return s ≻ 1.5
    }
}

fn aliquis_maior(tensor<f32, [4]> a) → bool {
    return reduce via any from a at [i] let s {
        return s ≻ 2.5
    }
}

fn aliquis_maximus(tensor<f32, [4]> a) → bool {
    return reduce via any from a at [i] let s {
        return s ≻ 3.5
    }
}

fn summa_corpus(tensor<f32, [4]> a) → f32 {
    return reduce via sum from a at [i] let s {
        return s + 1.0
    }
}

main {
    let list<f32> flat ← [3.0, 1.0, 3.0, 2.0]
    let tf32[4] a ← flat ↦ tensor<f32, [4]>
    print summa_tot(a)
    print factum_tot(a)
    print maxima_tot(a)
    print minima_tot(a)
    print maxima_vacua()
    print numera_maiora(a)
    print omnes_positivi(a)
    print omnes_maiores(a)
    print aliquis_maior(a)
    print aliquis_maximus(a)
    print summa_corpus(a)
}

Expected output:

9.0
18.0
3.0
1.0
-inf
2
verum
falsum
verum
falsum
13.0