Skip to content

Instantly share code, notes, and snippets.

@defunkydrummer
Created August 13, 2019 17:25
Show Gist options
  • Save defunkydrummer/71f5b7d20330ef279bc8d64a5de64ad7 to your computer and use it in GitHub Desktop.
Save defunkydrummer/71f5b7d20330ef279bc8d64a5de64ad7 to your computer and use it in GitHub Desktop.
Endless shitposting cube
(defun endless (str pos len)
(if (<= pos len)
(elt str pos)
(if (zerop (mod pos len))
(elt str len)
(elt str (1- (mod pos len))))))
(defun square-val (x y str len)
(cond
((eql y 0) (elt str x))
((eql x 0) (elt str y))
((and (eql x len) (eql y len)) (elt str 0))
((eql y len) (elt str (- len x)))
((eql x len) (elt str (- len y)))
(t (endless str (+ x y) len))))
(defun print-square (str)
(let ((len (1- (length str))))
(loop for y from 0 to len do
(format t " ") ;indent
(loop for x from 0 to len
for chr = (square-val x y str len)
do (format t "~C " chr))
(terpri))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment