templates lexicalPermutations when <=1> do [1] ! otherwise def n: $; def p: [ $n - 1 -> lexicalPermutations ]; 1..$n -> \(def k: $; $p... -> [ $k, $... -> \(when <$k..> do $+1! otherwise $!\)] !\) ! end lexicalPermutations def alpha: ['ABCD'...]; [ $alpha::length -> lexicalPermutations -> '$alpha($)...;' ] -> !OUT::write