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
| #!/bin/bash | |
| PROJECTS=${1:-~/quicklisp/local-projects} | |
| clone() { | |
| TARGET=$PROJECTS/$(basename $1) | |
| if [[ -d $TARGET ]]; then | |
| (cd $TARGET; git pull) | |
| else | |
| git clone $1 $TARGET |
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
| (declaim (optimize (speed 3) (safety 1))) | |
| (defconstant +pearl-probability+ (float 20/423)) | |
| (declaim (inline trade)) | |
| (defun trade () | |
| (if (< (random 1.0) +pearl-probability+) | |
| ;; Note that RANDOM returns a value in [0, maximum), i.e. | |
| ;; it will only produce numbers below the maximum given. | |
| (+ 4 (random 5)) | |
| 0)) |
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
| (ql:quickload :the-cost-of-nothing) | |
| (in-package :cl-user) | |
| (defun foo (x) | |
| (declare (integer x) | |
| (optimize (speed 3))) | |
| (< (- (expt 2 256)) x (expt 2 256))) | |
| (the-cost-of-nothing:bench (foo 7)) | |
| (in-package :sb-c) |
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
| CL-USER> (defun true? (p) | |
| "Is P the universal set, i.e. is our statement P true?" | |
| (subtypep 't p)) | |
| TRUE? | |
| CL-USER> (deftype implies (p q) | |
| "Are all elements of P elements of Q? (This is basically SUBTYPEP again.)" | |
| `(or (not ,p) ,q)) | |
| IMPLIES | |
| CL-USER> (true? '(implies cons list)) ; Does CONS imply LIST? | |
| ;; Note that SUBTYPEP returns: |
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
| data NFAState = Match Char NFAState | | |
| MatchAll NFAState | | |
| Amb NFAState NFAState | Halt | |
| deriving Show | |
| data Automaton = Running [Char] NFAState | Finished deriving Show | |
| finished :: Automaton -> Bool | |
| finished (Running _ _) = False | |
| finished Finished = True |
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
| (use-package :petalisp) | |
| (defun fft (x) | |
| (let ((n (shape-size (shape x)))) | |
| (assert (= (shape-rank (shape x)) 1)) | |
| (assert (zerop (logand n (1- n))) () | |
| "The length is not a power of 2") | |
| (if (<= n 1) | |
| x | |
| (let* ((even (fft (reshape x (~ 0 2 (1- n)) |
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
| (ql:quickload '(:concrete-syntax-tree :trucler-native | |
| :cleavir2-cst-to-ast :sicl-ast-to-hir | |
| :sicl-hir-to-mir :sicl-mir-to-lir)) | |
| (defvar *environment*) | |
| (defvar *client*) | |
| (defun expression-to-ir (expression &key (type :lir)) | |
| (let* ((cst (concrete-syntax-tree:cst-from-expression expression)) | |
| (ast (cleavir-cst-to-ast:cst-to-ast *client* cst *environment*)) | |
| (hir (sicl-ast-to-hir:ast-to-hir *client* ast))) |
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
| (ql:quickload :petalisp.examples) | |
| (use-package '(:petalisp :petalisp.examples.linear-algebra)) | |
| ;; we use this internal function in our hack over transpose and matmul. | |
| (import 'petalisp.examples.linear-algebra::coerce-to-matrix) | |
| (declaim (optimize (speed 3) (safety 1) (debug 3))) | |
| ;; i use these modified function definitions to produce the ranges | |
| ;; [0, n - 1] instead of [1, n], which makes handling them aside already | |
| ;; computed arrays much easier. | |
| (defun transpose (x) |
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
| (ql:quickload :petalisp.examples) | |
| (use-package '(:petalisp :petalisp.examples.linear-algebra)) | |
| ;; We use this internal function in our hack over transpose and matmul. | |
| (import 'petalisp.examples.linear-algebra::coerce-to-matrix) | |
| (declaim (optimize (speed 3) (safety 1) (debug 0))) | |
| ;; I use these modified function definitions to produce the ranges | |
| ;; [0, n - 1] instead of [1, n], which makes handling them aside already | |
| ;; computed arrays much easier. | |
| (defun transpose (x) |
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
| (defun read-list (stream) | |
| (if (char= (peek-char t stream) #\)) | |
| (progn | |
| (read-char stream) | |
| nil) | |
| (cons (read-sexp stream) | |
| (read-list stream)))) | |
| (defun read-atom (stream &optional (collected nil)) | |
| (let ((char (peek-char (null collected) stream nil :eof))) |