[ prog / sol / mona ]

prog


The Forced Indentation Of Code

236 2022-11-28 11:05

Black-and-white cell renderer in five shades with an inversion switch, generalizing >>53.

scheme@(guile-user)> (display ((lambda (rec xjoin extract index chars m n cell invert) ((lambda (xjoin cycle) ((lambda (expand) ((lambda (chars) ((lambda (symbol) (xjoin m (lambda (k) (string-append (xjoin n (lambda (j) (symbol k j)) "") "\n")) "")) ((lambda (ifinvert) (lambda (k j) (extract chars (* cell (ifinvert (index m n k j cycle))) cell))) (if invert (lambda (x) (- cycle 1 x)) (lambda (x) x))))) (expand chars cell))) (lambda (chars n) (xjoin (* n (string-length chars)) (lambda (k) (extract chars (quotient k n) 1)) "")))) (lambda (n fun sep) (rec xjoin n fun sep "")) (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 (m n k j cycle) (abs (- (modulo (* k j) (* 2 (- cycle 1))) cycle -1))) " ░▒▓█" 17 33 2 #f))

A modulo multiplication table >>234 and its inverse >>235 as demos.

267


VIP:

do not edit these