Skip to content

Instantly share code, notes, and snippets.

(format t "~{~A~}" (mapcar (lambda (list) (nth (random (list-length list)) list))
'((肩に 脳内に Cドライブに プププランドに 激安居酒屋に この地球(ほし)の片隅に あからさまに 利用規約の本文中に)
(ちっちゃい ジュレ状の 雲を貫く メタリックな 博士が愛した さっと炒めた 神と称された カレー粉をまぶした)
(ジープ 麻酔医 牛串 手塚治虫 FBI オーパーツ 明朝体 大奥のDBDボックス)
(乗せて 暮らして 突き刺さって くつろいで 支配して が素通りして を派遣して のシールを貼って)
(んのかい! んのよーん! るといいね! みた! いるわけもなく… そうって言われない? 被ってジャンケンポン いただけただろうか))))
(defclass yesql (source-file) ()
(:default-initargs :type "sql"))
(defclass compile-yesql-op (compile-op)
;; NOTE: asdf:input-files is memoised.
;; We could not control return value via special symbols.
;; We need another object (i.e. compile-yesql-op) for another return value.
((op :accessor op)))
(defmethod input-files ((o compile-yesql-op) (c yesql))
(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.
(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)
(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.
(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)))
@hyotang666
hyotang666 / dot.lisp
Created July 16, 2020 07:25
Naive implementation of dot function with numcl.
#| 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])
|#
(ql:quickload :alexandria)
(format t "~A~:*~Aの~A"
#0=(subseq (alexandria:shuffle "ホクイモ") 0 2)
#0#)
(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))
#++
(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*)