Last active
December 26, 2016 20:33
-
-
Save svetlyak40wt/ced04d88d0c39edfa2e17805716d071f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage heart | |
(:use :cl)) | |
(in-package :heart) | |
;; Usage: | |
;; sbcl -l heart.lisp -e '(uiop:quit 0)' | |
;; | |
(defun print-line (&rest args) | |
(loop | |
:for type :in args :by #'cddr | |
:for num :in (cdr args) :by #'cddr | |
:do (loop :repeat num | |
:do (princ (ecase type | |
(:s " ") | |
(:h "❤️"))))) | |
(format t "~%")) | |
(defun print-lines (data) | |
;; ensure there is a new line | |
(format t "~&") | |
(dolist (line data) | |
(apply #'print-line line))) | |
(defvar *data* | |
'((:s 8 :h 8 :s 8 :h 8) | |
(:s 3 :h 15 :s 4 :h 15) | |
(:s 1 :h 18 :s 2 :h 18) | |
(:s 0 :h 40) | |
(:s 0 :h 40) | |
(:s 0 :h 40) | |
(:s 1 :h 38) | |
(:s 2 :h 36) | |
(:s 4 :h 32) | |
(:s 6 :h 28) | |
(:s 8 :h 24) | |
(:s 11 :h 18) | |
(:s 13 :h 14) | |
(:s 15 :h 10) | |
(:s 17 :h 6) | |
(:s 19 :h 2))) | |
(print-lines *data*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is example output:
