Here is a variation of >>100 that replaces the plain meme combinator with the memestar combinator. The plain meme combinator is then expressed as a special case of the memestar combinator. The memestar combinator can be used to obtain letrec-like functionality for a group of mutually recursive functions, without resorting to hidden assignment. In this case two mutually recursive functions bounce the task of displaying the next line between each other, alternately displaying even and odd lines as in the >>104 coroutine demo.
>>> (lambda Ystar, maketask, xjoin, size, half, cell, boot, pred, n, E, L, R, C: (lambda Y, n: (lambda xjoin, half, cell, pred: (lambda symbol: (lambda oneline: (lambda even, odd: even (0)) (* Ystar (maketask (oneline, n, 0), maketask (oneline, n, 1)))) (lambda k: xjoin (2 * n, lambda j: symbol (k, j), ''))) (lambda k, j: (lambda c: L if c < 0 else R if c > 0 else C if pred (k, j // 2) else E) (boot (half, cell, n, k, j)))) (Y (xjoin), Y (half), Y (cell), Y (pred))) (lambda f: next (Ystar (f)), size (n))) (lambda *funs: (lambda x: x (x)) (lambda y: map (lambda onefun: lambda *args: onefun (* y (y)) (* args), funs)), lambda task, limit, id: lambda even, odd: lambda k: None if k >= limit else (lambda dis: (even, odd) [1 - id] (k + 1)) (print (task (k))), lambda f: lambda n, g, s: '' if n <= 0 else g (0) if n == 1 else f (n - 1, g, s) + s + g (n - 1), lambda n: 3 ** n, lambda f: lambda n, p: p >> 1 if p > n else f (n, p << 1), lambda f: lambda half, lr, k, j: 0 if j > k else lr if k == 0 else (lambda h: f (half, -lr, k - h, h - 1 - j) if j < h else f (half, lr, k - h, j - h)) (half (k, 2)), lambda half, cell, n, k, j: cell (half, -1, k, n - 1 - j) if j < n else cell (half, 1, k, j - n), lambda f: lambda k, j: ((k == 0) or (j == 0)) or (not ((k % 3 == 1) and (j % 3 == 1)) and f (k // 3, j // 3)), 3, " ", "◢", "◣", "░")
separate output for 413
if your browser adds useless vertical scrollbars to code boxes after >>28 getting rid of vertical gaps:
dd pre {
line-height: 1em;
padding: 0.5em 0;
}