[ prog / sol / mona ]

prog


The Forced Indentation Of Code

77 2022-04-29 10:34

upgrade of >>72 that tracks two levels up the derivation tree, which allows symmetry to be restored in the painter

scheme@(guile-user)> (display ((lambda (rec xjoin firstpred index size chars cell start level) ((lambda (xjoin firstpred lines columns) ((lambda (index expand symbol) ((lambda (chars) ((lambda (symbol) (xjoin lines (lambda (k) (string-append (xjoin columns (lambda (j) (symbol k j)) "") "\n")) "")) (lambda (k j) (apply symbol cell chars (index k j))))) (expand chars (* 2 cell)))) (lambda (k j) (rec index k j lines columns start 0 (not start) 0 start)) (lambda (chars n) (xjoin (* n (string-length chars)) (lambda (x) ((lambda (idx) (substring chars idx (+ 1 idx))) (quotient x n))) "")) ((lambda (preds typetable) (lambda (cell chars pos hv uppos uphv gpos ghv) ((lambda (idx) (substring chars idx (+ idx cell))) (* cell (+ pos (* 2 (vector-ref typetable (firstpred (list hv uppos uphv gpos ghv) preds)))))))) (list (lambda (hv uppos uphv gpos ghv) (and (or (and hv uphv ghv) (and (not hv) (not uphv) (not ghv))) (= uppos gpos))) (lambda (hv uppos uphv gpos ghv) (and (or (and (not hv) (not uphv) ghv) (and hv uphv (not ghv))) (= uppos gpos))) (lambda (hv uppos uphv gpos ghv) (and (or (and hv uphv ghv) (and (not hv) (not uphv) (not ghv))) (not (= uppos gpos)))) (lambda (hv uppos uphv gpos ghv) (and (or (and (not hv) (not uphv) ghv) (and hv uphv (not ghv))) (not (= uppos gpos)))) (lambda (hv uppos uphv gpos ghv) (or (and hv (not uphv) ghv) (and (not hv) uphv (not ghv))))) #(4 4 1 3 0 2)))) (lambda (n fun sep) (rec xjoin n fun sep "")) (lambda (args preds) (rec firstpred 0 args preds)) (size level start #t) (size level start #f))) (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 (self n args preds) (if (null? preds) n (if (apply (car preds) args) n (self self (+ n 1) args (cdr preds))))) (lambda (self k j lin col hv uppos uphv gpos ghv) (if hv (if (= lin 1) `(,j #t ,uppos ,uphv ,gpos ,ghv) ((lambda (c4) ((lambda (jd jm) (if (or (= jd 0) (= jd 3)) (self self k jm lin c4 #f (if (= jd 0) 0 1) #t uppos uphv) ((lambda (l2) (self self (modulo k l2) (- j c4) l2 (ash c4 1) #t (quotient k l2) #t uppos uphv)) (ash lin -1)))) (quotient j c4) (modulo j c4))) (ash col -2))) (if (= col 1) `(,k #f ,uppos ,uphv ,gpos ,ghv) ((lambda (l4) ((lambda (kd km) (if (or (= kd 0) (= kd 3)) (self self km j l4 col #t (if (= kd 0) 0 1) #f uppos uphv) ((lambda (c2) (self self (- k l4) (modulo j c2) (ash l4 1) c2 #f (quotient j c2) #f uppos uphv)) (ash col -1)))) (quotient k l4) (modulo k l4))) (ash lin -2))))) (lambda (level horver lincol) (ash (if (eq? horver lincol) 1 2) level)) "█▓▒░ " 2 #t 4))

separate output for 413

level 6 with colors: http://paste.textboard.org/a5764149/raw

267


VIP:

do not edit these