Draw fences by yuki

main=interact$ \c->unlines$w$g`map`lines c
g x='|':h x++"|"
h(a:b:c)=a:(if a==b then ' ' else '|'):h(b:c)
h x=x
v(a:b:c)=a:k(zipWith f a b):v(b:c) where
 f a b|or[a=='|',b=='|']='|'
 f a b|a/=b='-'
 f a b=' '
 k('-':'|':s)="-+"++k s
 k('-':' ':s)="--"++k s
 k(' ':'-':s)='-':k('-':s)
 k(x:s)=x:k s
 k x=x
v x=x
w x=[map t(head x)]++v x++[map t(last x)]
t '|'='+'
t x='-'

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)


return to the top page