[ prog / sol / mona ]

prog


The Forced Indentation Of Code

184 2022-09-04 11:59

Sierpinski carpet >>17 on the tile mesh >>182

scheme@(guile-user)> (display ((lambda (rec xjoin extract carpet toquadrants exists overlaps spec chars n) ((lambda (xjoin lines columns carpet) ((lambda (quadcarpet) ((lambda (exists) ((lambda (grid) ((lambda (symbol) (xjoin lines (lambda (k) (string-append (xjoin columns (lambda (j) (symbol k j)) "") "\n")) "")) (lambda (k j) (extract chars (grid k j) 1)))) ((lambda (cell split) ((lambda (corner) (lambda (k j) (apply (lambda (kd km jd jm) (if (= jm 3) (if (or (= km 1) (= km 2)) 0 (if (exists (+ (* 2 kd) 1) jd) 1 0)) (if (= jm 7) (if (= km 1) (if (exists (* 2 kd) (+ jd 1)) 1 0) (if (= km 2) (if (exists (+ (* 2 kd) 2) (+ jd 1)) 1 0) 0)) (apply (lambda (up k left j) (corner (if (eq? up left) 2 3) (+ (* 2 kd) (if up 0 1)) (+ jd (if (and up (not left)) 1 0)) (+ (* 2 kd) (if up 1 2)) (+ jd (if (not (or up left)) 1 0)) (not (eq? up left)) k j)) `(,@(split km 2) ,@(split jm 4)))))) `(,(quotient k 4) ,(modulo k 4) ,(quotient j 8) ,(modulo j 8))))) (lambda (id firstk firstj secondk secondj left k j) (if (exists firstk firstj) (if (exists secondk secondj) (cell (if (overlaps firstk firstj left) id (- 3 id)) 1 k j) (cell id 0 k j)) (if (exists secondk secondj) (cell (- 3 id) 0 k j) 0))))) (lambda (corner double k j) (vector-ref (vector-ref (vector-ref spec corner) double) (+ (* 3 k) j))) (lambda (k limit) (if (< k limit) `(#t ,k) `(#f ,(- k limit))))))) (lambda (k j) (exists quadcarpet k j)))) (toquadrants carpet))) (lambda (n fun sep) (rec xjoin n fun sep "")) (* 4 n) (* 8 n) (lambda (k j) (rec carpet k j)))) (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 (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 (basequad) (lambda (k j) (if (>= k 0) (if (>= j 0) (basequad k j) (basequad k (- -1 j))) (if (>= j 0) (basequad (- -1 k) j) (basequad (- -1 k) (- -1 j)))))) ((lambda (div) (lambda (oncoords k j) ((lambda (x) (oncoords x (+ k x))) (- j (div k 2))))) (lambda (a b) (quotient (- a (modulo a b)) b))) (lambda (k j left) (eq? (even? k) left)) #(#(#(1 1 4 0 0 2) #(8 1 4 0 0 10)) #(#(3 1 1 2 0 0) #(3 1 8 9 0 0)) #(#(0 0 2 1 1 6) #(0 0 10 7 1 6)) #(#(2 0 0 5 1 1) #(9 0 0 5 1 7))) " ─│┌┐└┘┬┴┤├" 5))
┌─┴───┐ ┌───┤   ┌─┴───┐                 
┤     │ │   └─┬─┤     │                 
┴─┐   ├─┴─┐   ├─┴─┐   ├───┐         ┌───
  ├─┬─┘   ├─┬─┘   ├─┬─┘   │         │   
┌─┴─┤   ┌─┴─┤     │ │   ┌─┴───┐ ┌───┤   
┤   └─┬─┤   └─┬───┘ └───┤     │ │   └─┬─
┴─┐   ├─┴─┐   ├───┐ ┌───┴─┐   ├─┴─┐   ├─
  ├─┬─┘   ├─┬─┘   │ │     ├─┬─┘   ├─┬─┘ 
┌─┴─┤   ┌─┴─┤   ┌─┴─┤   ┌─┴─┤   ┌─┴─┤   
┤   └─┬─┤   └─┬─┤   └─┬─┤   └─┬─┤   └─┬─
┴─┐   │ │     ├─┴─┐   ├─┴─┐   │ │     ├─
  ├───┘ └───┬─┘   ├─┬─┘   ├───┘ └───┬─┘ 
┌─┴───┐ ┌───┤   ┌─┴─┤   ┌─┴───┐ ┌───┤   
┤     │ │   └─┬─┤   └─┬─┤     │ │   └─┬─
│     ├─┴─┐   ├─┴─┐   ├─┴─┐   ├─┴─┐   ├─
└───┬─┘   ├─┬─┘   ├─┬─┘   ├─┬─┘   ├─┬─┘ 
    │   ┌─┴─┤     │ │   ┌─┴─┤   ┌─┴─┤   
    └───┤   └─┬───┘ └───┤   └─┬─┤   └─┬─
    ┌───┴─┐   ├───┐ ┌───┴─┐   ├─┴─┐   ├─
    │     ├─┬─┘   │ │     ├─┬─┘   ├─┬─┘ 
scheme@(guile-user)> 

larger version to see the pattern: http://0x0.st/opn7.txt https://wirechan.org/b/res/2162.html#3865 http://0x0.st/opnh.png

267


VIP:

do not edit these