Skip to content

Instantly share code, notes, and snippets.

@kmark
Created April 27, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmark/97e1b4025e8f70b88c4980bcaeee84e1 to your computer and use it in GitHub Desktop.
Save kmark/97e1b4025e8f70b88c4980bcaeee84e1 to your computer and use it in GitHub Desktop.
; https://www.reddit.com/r/programmingcirclejerk/comments/8ebz88/the_major_difference_between_java_and_golang_is/dxuq7l0/
(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 #\Space)))
(defun print-square (str)
(let ((len (1- (length str))))
(loop for y from 0 to len do
(format t " ") ;brutally practical indent
(loop for x from 0 to len
for chr = (square-val x y str len)
do (format t "~C " chr))
(terpri))))
(print-square "BRUTALLY OPTIMIZED")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment