[ prog / sol / mona ]

prog


The Forced Indentation Of Code

161 2022-08-11 10:50

Since m4 was linked in https://textboard.org/prog/538#t538p18 here is the Sierpinski carpet >>17 in m4:

$ cat carpet.m4 
divert(-1)
define(`carpet_level',3)
define(`carpet_empty',`  ')
define(`carpet_full',`m4')
define(`carpet_size',eval(3**carpet_level))
define(`carpet_pred',`ifelse(eval(($1==0)||($2==0)),1,1,`ifelse(eval((($1%3)==1)&&(($2%3)==1)),1,0,`carpet_pred(eval($1/3),eval($2/3))')')')
define(`carpet_symbol',`ifelse(carpet_pred($1,$2),1,carpet_full,carpet_empty)')
define(`carpet_xjoin',`ifelse($1,1,`$2(0)`$4'',`carpet_xjoin(decr($1),`$2',`$3',`$3'$2(decr($1))`$4')')')
define(`carpet_linesymbol',`carpet_symbol(carpet_currentline,$1)')
define(`carpet_line',`pushdef(`carpet_currentline',$1)carpet_xjoin(carpet_size,`carpet_linesymbol',,)popdef(`carpet_currentline')')
define(`carpet_carpet',`carpet_xjoin(carpet_size,`carpet_line',`
',)')
divert(0)carpet_carpet
$ m4 carpet.m4 
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4m4m4      m4m4m4m4m4m4      m4m4m4m4m4m4      m4m4m4
m4  m4      m4  m4m4  m4      m4  m4m4  m4      m4  m4
m4m4m4      m4m4m4m4m4m4      m4m4m4m4m4m4      m4m4m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4m4m4m4m4m4m4m4m4                  m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4                  m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4                  m4m4m4m4m4m4m4m4m4
m4m4m4      m4m4m4                  m4m4m4      m4m4m4
m4  m4      m4  m4                  m4  m4      m4  m4
m4m4m4      m4m4m4                  m4m4m4      m4m4m4
m4m4m4m4m4m4m4m4m4                  m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4                  m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4                  m4m4m4m4m4m4m4m4m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4m4m4      m4m4m4m4m4m4      m4m4m4m4m4m4      m4m4m4
m4  m4      m4  m4m4  m4      m4  m4m4  m4      m4  m4
m4m4m4      m4m4m4m4m4m4      m4m4m4m4m4m4      m4m4m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4m4  m4
m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4m4
267


VIP:

do not edit these