Function lambda_calculus::data::num::scott::pow

source ·
pub fn pow() -> Term
Expand description

Applied to two Scott-encoded numbers it raises the first one to the power of the second one.

POW ≡ Z (λfmn.n ONE (λo. MUL m (f m o))) ≡ Z (λ λ λ 1 ONE (λ MUL 3 (4 3 1)))

Example

use lambda_calculus::data::num::scott::pow;
use lambda_calculus::*;

assert_eq!(beta(app!(pow(), 1.into_scott(), 2.into_scott()), NOR, 0), 1.into_scott());
assert_eq!(beta(app!(pow(), 2.into_scott(), 3.into_scott()), NOR, 0), 8.into_scott());

Errors

This function will overflow the stack if used with an applicative-family (APP or HAP) reduction order.