This file contains 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
(defun fizz-buzz () | |
(loop for i from 1 upto 100 do | |
(when (= 0 (mod i 3)) | |
(princ "Fizz")) | |
(when (= 0 (mod i 5)) | |
(princ "Buzz")) | |
(when (fresh-line) | |
(print i)))) |
This file contains 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
(defun decorate-for-error (fn on-error signalp) | |
(cond | |
(signalp fn) | |
(t (lambda (&rest args) | |
(handler-case (apply fn args) | |
(error () on-error)))))) | |
(defun domain-union (t1 t2) | |
(let ((union (list 'or t1 t2))) |
This file contains 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
(defvar *big* (simulate "06-ex" 9999999)) | |
;; 3.75 min later | |
(defvar *as-str* (format nil "~d" *big*)) | |
(length *as-str*) | |
=> 378346 | |
(subseq *as-str* 0 20) | |
=> "41825991834876534637" |
This file contains 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 :test-macro (:use :cl)) | |
(in-package :test-macro) | |
(define-condition some-info () | |
((data :accessor data :initarg :data))) | |
(defmacro with-metadata (macro-name &body body &environment env) | |
(let (stuff) | |
(handler-bind ((some-info (lambda (c) (push (data c) stuff)))) | |
(sb-cltl2:macroexpand-all |
This file contains 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
type command = | |
| Up of int | |
| Down of int | |
| Forward of int | |
type p1 = { | |
horiz : int; | |
depth : int; | |
} |
This file contains 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 :col (:use :cl)) | |
(in-package :col) | |
(ql:quickload :cl-ansi-text) | |
(defparameter *print-color* t) | |
;; Attach a color attribute to symbols | |
(defun color (symbol) |
This file contains 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
(ql:quickload '(:iolib :cl-charms)) | |
(defpackage :tui (:use :cl :cl-charms :iomux)) | |
(in-package :tui) | |
;;; From http://turtleware.eu/posts/cl-charms-crash-course.html | |
(defun start-color () | |
(when (eql (charms/ll:has-colors) charms/ll:FALSE) | |
(error "Your terminal does not support color.")) | |
(let ((ret-code (charms/ll:start-color))) |
This file contains 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 :map-lines (:use :cl)) | |
(in-package :map-lines) | |
(defparameter *max-line-size* 65536) | |
(defparameter *default-buffer-size* 16384) | |
(declaim (inline map-lines-on-shared-buffer)) | |
(define-condition internal-buffer-overflow (error) | |
((buffer :reader internal-buffer-overflow/buffer :initarg :buffer) |
This file contains 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 :advent.2019.14 | |
(:use :cl :alexandria :cl-ppcre) | |
(:import-from :series #:collect #:map-fn #:scan-stream)) | |
(in-package :advent.2019.14) | |
(defun parse-reactions (stream) | |
(labels ((reaction (line) | |
(destructuring-bind (in out) (split " => " line) | |
(mapcar #'compound (list* out (split ", " in))))) |
This file contains 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
(in-package :advent.2019.intcode) | |
;; utils | |
(defun make-command-queue (size) | |
(assert (plusp size)) | |
(let* ((commands (make-list size)) | |
(head commands)) | |
(lambda (value callback) | |
(setf (car head) value) |
NewerOlder