pdp11v/usr/src/cmd/m4/m4.test5

dnl	@(#)m4.test5	1.2
define(i0,`ifelse($1,0,1,`i1($1)')')
define(i1,`ifelse($1,1,2,`i2($1)')')
define(i2,`ifelse($1,2,3,`i3($1)')')
define(i3,`ifelse($1,3,4,`i4($1)')')
define(i4,`ifelse($1,4,5,`i5($1)')')
define(i5,`ifelse($1,5,6,`i6($1)')')
define(i6,`ifelse($1,6,7,`i7($1)')')
define(i7,`ifelse($1,7,8,`i8($1)')')
define(i8,`ifelse($1,8,9,C0)')
define(f,`substr($1,0,1)')
define(s,`substr($1,1,1)')
define(r,`substr($1,1)')
define(ir,`ifelse($1,,,`ifelse(f(ir(r($1))),C,`i0(f($1))`'r(ir(r($1)))',`f($1)`'ir(r($1))')')')
define(`inc',`ifelse(f(ir($1C)),C,`1`'r(ir($1C))',`ir($1C)')')
ir(3C) inc(3)
ir(9C) inc(9)
ir(18C) inc(18)
ir(19C) inc(19)
ir(8899C) inc(8899)
ir(99999C) inc(99999)
define(add3,`ifelse($2,$3,$1,`add3(inc($1),$2,inc($3))')')
define(add,`add3($1,$2,0)')

add(17,0)
add(17,1)
add(7,3)
add(18,2)
add(12,13)