Sierpinski triangle over Sierpinski carpet >>100 >>109 on the flower garden >>153
scheme@(guile-user)> (display ((lambda (rec xjoin extract twolevels half cell carpet index patch1 patch2 chars band columnfactor n) ((lambda (xjoin half carpet lines columns cycle) ((lambda (cell) ((lambda (patch1 patch2) ((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)))) (twolevels patch1 patch2))) (patch1 cell) (patch2 carpet))) (lambda (lr k j) (rec cell half lr k j)))) (lambda (n fun sep) (rec xjoin n fun sep "")) (lambda (n) (rec half n 2)) (lambda (x y dx dy band) (rec carpet x y)) (+ (* 2 n) 1) (+ (* 2 columnfactor n) 1) (string-length chars))) (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 (first second) (lambda (cycle x y dx dy band) ((lambda (f) (if (zero? f) (second cycle x y dx dy band) (+ f 1))) (first cycle x y dx dy band)))) (lambda (self n p) (if (> p n) (quotient p 2) (self self n (* 2 p)))) (lambda (self half lr k j) (if (> j k) 0 (if (zero? k) lr ((lambda (h) (if (< j h) (self self half (- lr) (- k h) (- h 1 j)) (self self half lr (- k h) (- j h)))) (half k))))) (lambda (self k j) (if (or (= k 0) (= j 0)) #t (if (and (= (modulo k 3) 1) (= (modulo j 3) 1)) #f (self self (quotient k 3) (quotient j 3))))) (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 (cell) ((lambda (halfcell) ((lambda (quadrant) (lambda (cycle x y dx dy band) (if (and (>= x 1) (<= (- x) y (- x 1))) (if (quadrant (if (>= y 0) (- -1 y) (- y)) (- x 1) (- band dy) dx band) 1 0) (if (and (<= y -2) (<= (+ y 1) x (- -2 y))) (if (quadrant (if (>= x 0) (- -1 x) (- x)) (- -2 y) (- band dx) (- band dy) band) 2 0) (if (and (<= x -2) (<= (+ x 1) y (- -2 x))) (if (quadrant (if (>= y 0) (+ y 1) y) (- -2 x) dy (- band dx) band) 3 0) (if (and (>= y 1) (<= (- y) x (- y 1))) (if (quadrant (if (>= x 0) (+ x 1) x) (- y 1) dx dy band) 4 0) 0)))))) (lambda (x y dx dy band) (halfcell dx dy band (apply cell (if (< x 0) `(-1 ,y ,(- -1 x)) `(1 ,y ,(- x 1)))))))) (lambda (dx dy band lr) (if (< lr 0) (<= (- band dx) dy) (if (> lr 0) (<= dx dy) #f))))) (lambda (quad) ((lambda (reflect) (lambda (cycle x y dx dy band) (if (reflect quad x y dx dy band) 0 1))) (lambda (quad x y dx dy band) (if (>= x 0) (if (>= y 0) (quad x y dx dy band) (quad x (- -1 y) dx (- band dy) band)) (if (>= y 0) (quad (- -1 x) y (- band dx) dy band) (quad (- -1 x) (- -1 y) (- band dx) (- band dy) band)))))) "🌵🌹🦋🌺🌼🌸🌻🌷💮" 6 2 9))
separate output >>156 for 413 >>127
As promised in >>125 the half-empty cells of the triangle show either roses or butterflies as appropriate for the carpet at that location.
larger version: https://endchan.net/art/res/2.html#71 http://0x0.st/oenp.txt http://0x0.st/oenV.png