Factorial as an infinite
array fact indexed by dimension d

dim d;;
var fact [d is 0] = 1;;
var fact [d : pos] = #.d * (fact @ [d <- #.d - 1]);;
%%
fact @ [d <- 500];;

Factorial as a function fact
reaching into an infinite array F

fun fact.n = F
where
dim d <- n;;
var F [d is 0] = 1;;
var F [d : pos] = #.d * (prev.d F);;
end;;
%%
fact.500;;

Running application over d of
function fn to array X

fun fold.d.fn X = F where
var F [d is 0] = X;;
var F [d : pos] = fn!X!(prev.d F);;
end;;
var M = #.0;;
var N = fby.0 1 (index!0);;
%%
fold.0.plus M @ [0 <- 2];;
fold.0.plus M @ [0 <- 10];;
fold.0.plus (2*M + 1) @ [0 <- 3];;
fold.0.times N @ [0 <- 500];;

Array of functions

Higher-order
function pow returns the n-th–power
function,
i.e., the n-th element of the
array P of power functions

fun pow.n = P where
dim d <- n;;
var P = fby.d (\_ m -> 1) (\_ {d} m -> m * P.m);;
end;;
%%
pow.3.3;;
pow.4.4;;
pow.2.2;;
pow.10.2;;
pow.2.10;;
pow.6.10;;
pow.1000.5001;;