# Computes the ackermann function by recursively importing derivations. Evaluate with # # nix-instantiate --eval --read-write-mode ./ack.nix -A result --arg m 3 --arg n 2 { m, n }: let pkgs = import {}; recurse = m': n': '' (import ${toString __curPos.file} { m = ${toString m'}; n = ${toString n'}; }).result ''; text = if m == 0 then toString (n + 1) else if n == 0 then recurse (m - 1) 1 else recurse (m - 1) (recurse m (n - 1)); drv = pkgs.writeText "ack-${toString m}-${toString n}" text; in drv // { result = import drv; }