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 :alpaka-debugger(:use :cl)) | |
(in-package :alpaka-debugger) | |
(defun alpaka-debugger(condition function) | |
(declare(ignore function)) | |
(format t | |
" 「\ /`ヽ | |
| \'゙゙゙\"\"\"\"\"\"\"゙゙; / l | |
レ'´ ィ` ̄ ̄ ̄ `ヽ`く l | |
/〃 〃 \\ / |
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 |$-reader| (s c) | |
(declare(ignore c)) | |
(let((op(read s t t t)) | |
(args(read s t t t))) | |
(cons op args))) | |
(set-macro-character #\$ #'|$-reader|) | |
;; cl-user> (append (list 1 2 3) $list(4 5 6)) | |
;; => (1 2 3 4 5 6) |
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 foo() | |
(with-guards((print "fle closed!!!") | |
(print "pipe closed!!!") | |
(print "socket closed!!!")) | |
(print "using"))) | |
(defmacro with-guards((&rest guard*)&body body) | |
(labels((rec(guard*) | |
(if(endp guard*) |
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 :split-sequence) | |
(defun |#!-reader|(stream char number) | |
(declare(ignore char number)) | |
(let((symbol(read stream t t t))) | |
(check-type symbol symbol) | |
(let((methods(split-sequence:split-sequence #\. (symbol-name symbol)))) | |
(assert(eql 2 (length methods))) | |
`(lambda(&rest args) | |
(apply ',(intern (cadr methods)) |
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 :alexandria) | |
(format t "~A~:*~Aの~A" | |
#0=(subseq (alexandria:shuffle "ホクイモ") 0 2) | |
#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
#| https://numpy.org/doc/stable/reference/generated/numpy.dot.html | |
Dot product of two arrays. Specifically, | |
If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation). | |
If both a and b are 2-D arrays, it is matrix multiplication, but using matmul or a @ b is preferred. | |
If either a or b is 0-D (scalar), it is equivalent to multiply and using numpy.multiply(a, b) or a * b is preferred. | |
If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b. | |
If a is an N-D array and b is an M-D array (where M>=2), it is a sum product over the last axis of a and the second-to-last axis of b: | |
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m]) | |
|# |
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 |#(-reader| (stream character number) | |
(declare (ignore character number)) | |
`(load-time-value (numcl:asarray ',(read-delimited-list #\) stream t)))) | |
(defun |#A-reader| (stream character number) | |
(declare (ignore character)) | |
`(load-time-value (let ((array (numcl:asarray ',(read stream t t t)))) | |
(assert (= (array-rank array) ,number)) | |
array))) |
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-delimited-exps | |
(end-char &optional (stream *standard-input*) recursive-p) | |
(do ((char (peek-char t stream t t recursive-p) | |
(peek-char t stream t t recursive-p)) | |
(acc)) | |
((char= char end-char) | |
(read-char stream) ; discard close paren. | |
(nreverse acc)) | |
(case char | |
(#\. ; dot list. |
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 *logs* (make-hash-table :test #'equal)) | |
(defmacro log! (&rest names) | |
(if (null names) | |
`(progn (maphash (lambda (name function) | |
(setf (fdefinition name) function)) | |
*logs*) | |
(clrhash *logs*)) | |
`(map nil (lambda (name) | |
(if (gethash name *logs*) | |
(warn "Already logging: ~S" name) |
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 '(:with-package :alexandria)) | |
(get-dispatch-macro-character #\# #\@) ; => NIL | |
(progn #.(progn (with-package:enable) ; <--- Modify *READTABLE* | |
(values)) ; <--- return nothing. | |
#@alexandria ; <--- Using new syntax. | |
(iota 5) | |
#.(progn (setq *readtable* (copy-readtable nil)) ; <--- Reset *READTABLE* as the default. | |
(values))) ; <--- return nothing. |