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))) |
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
(defvar *oblique-strategy-list* | |
'("Remove specifics and convert to ambiguities" | |
"Don't be frightened of cliches" | |
"What is the reality of the situation?" | |
"Are there sections? Consider transitions " | |
"Turn it upside down " | |
"Think of the radio " | |
"Allow an easement (an easement is the abandonment of a stricture) " | |
"Simple subtraction " | |
"Go slowly all the way round the outside " |
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) | |
(use-package :petalisp) | |
(defvar x (as-matrix #2a((5.1 3.5 1.4 0.2) | |
(4.9 3.0 1.4 0.2) | |
(6.2 3.4 5.4 2.3) | |
(5.9 3.0 5.1 1.9)))) | |
(defvar y (as-matrix #(0 0 1 1))) | |
(defvar w (as-matrix #(0.5 0.5 0.5 0.5))) |
NewerOlder