[ prog / sol / mona ]

prog


The Forced Indentation Of Code

214 2022-10-31 10:48

Sierpinski space-filling curve on the connector flower garden >>208. The 3π/4 connectors that would enable it to be drawn symmetrically in plain text mode seem to be missing from Unicode.

scheme@(guile-user)> (display ((lambda (rec xjoin extract windowtopleft derive expandsize cell index connector connectors cellspec cellrows cellcols expansions expandx expandy levels chars band columnfactor n) ((lambda (xjoin derive cell connector lines columns cycle size) ((lambda (sizex sizey) ((lambda (derive) ((lambda (derivecell) ((lambda (window) ((lambda (patch) ((lambda (symbol) (xjoin lines (lambda (k) (string-append (xjoin columns (lambda (j) (symbol k j)) "") "\n")) "")) (lambda (k j) (extract chars (index patch band cycle columnfactor n k j) 1)))) (lambda (cycle x y dx dy band) (if (connector (window x y) dx dy) 1 0)))) (windowtopleft sizex sizey derivecell))) (lambda (y x) ((lambda (qx mx qy my) (cell (derive qx qy) mx my)) (quotient x cellcols) (modulo x cellcols) (quotient y cellrows) (modulo y cellrows))))) ((lambda (sizex sizey) (lambda (x y) (rec derive 0 x y sizex sizey))) (quotient sizex cellcols) (quotient sizey cellrows)))) (car size) (cadr size))) (lambda (n fun sep) (rec xjoin n fun sep "")) (derive expansions expandx expandy) (cell cellspec cellcols) (connector connectors band) (+ (* 2 n) 1) (+ (* 2 columnfactor n) 1) (string-length chars) (expandsize cellcols cellrows expandx expandy levels))) (lambda (f . args) (apply f (cons f args))) (lambda (self n fun sep acc) (if (<= n 0) "" (if (= n 1) (string-append (fun 0) acc) (self self (- n 1) fun sep (string-append sep (fun (- n 1)) acc))))) (lambda (str pos len) (substring str pos (+ pos len))) (lambda (width height fun) ((lambda (w2 h2) ((lambda (x1 x2 y1 y2) (lambda (x y) (if (and (<= x1 x x2) (<= y1 y y2)) (fun (- y y1) (- x x1)) 0))) (- w2) (- width w2 1) (- h2) (- height h2 1))) (quotient width 2) (quotient height 2))) (lambda (spec expandx expandy) (lambda (self var x y sizex sizey) (if (= sizex 1) var ((lambda (subx suby) ((lambda (qx mx qy my) (self self (vector-ref (vector-ref spec var) (+ (* qy expandx) qx)) mx my subx suby)) (quotient x subx) (modulo x subx) (quotient y suby) (modulo y suby))) (quotient sizex expandx) (quotient sizey expandy))))) ((lambda (size) (lambda (cellx celly expandx expandy levels) (list (size cellx expandx levels) (size celly expandy levels)))) (lambda (start expand levels) (* start (expt expand levels)))) (lambda (spec columns) (lambda (index dx dy) (vector-ref (vector-ref spec index) (+ (* dy columns) dx)))) (lambda (patch band cycle columnfactor n k j) ((lambda (k j) ((lambda (dx dy) (if (or (= dx 0) (= dy 0)) 0 (+ (patch (- cycle 1) (quotient (- (+ k j) dx) band) (quotient (- (- k j) dy) band) dx dy band) 1))) (modulo (+ k j) band) (modulo (- k j) band))) (- k n) (- j (* columnfactor n)))) (lambda (spec band) ((lambda (b2 on) (lambda (index dx dy) (if (zero? index) #f ((lambda (bits) (or (and (= dy b2) (or (= dx b2) (on 0 bits) (and (< dx b2) (on 1 bits)) (and (> dx b2) (on 2 bits)))) (and (= dx b2) (or (on 3 bits) (and (< dy b2) (on 4 bits)) (and (> dy b2) (on 5 bits)))) (and (= dx dy) (or (on 6 bits) (and (< dx b2) (on 7 bits)) (and (> dx b2) (on 8 bits)))) (and (= (+ dx dy) band) (or (on 9 bits) (and (< dx b2) (on 10 bits)) (and (> dx b2) (on 11 bits)))))) (vector-ref spec index))))) (quotient band 2) logbit?)) #(#f 1 8 36 34 20 18 33 17 10 12 64 512 132 1028 2050 258 160 2080 1040 272 2304 1152 1280 2176) #(#(0 23 0 21 0 22 0 24 0) #(0 23 0 15 0 22 0 18 0) #(0 23 0 21 0 13 0 17 0) #(0 19 0 21 0 14 0 24 0) #(0 20 0 16 0 22 0 24 0) #(0 19 0 15 0 14 0 18 0) #(0 20 0 16 0 13 0 17 0)) 3 3 #(#(2 1 3 4) #(2 1 5 4) #(2 1 3 6) #(2 5 3 4) #(6 1 3 4) #(2 5 5 4) #(6 1 3 6)) 2 2 2 "🌵🌹🌺🌼🌸🌻🌷💮🦋" 8 2 9))

separate output >>213 for renewed 413 >>127

larger version: https://wirechan.org/b/res/2162.html#4271 http://paste.textboard.org/e398a285/raw

267


VIP:

do not edit these