Skip to content

Instantly share code, notes, and snippets.

@g000001
g000001 / comment.lisp
Created November 3, 2019 12:50
comment
#| foo |#
;;; foo
#;(foo
bar
baz)
foo bar baz
#|
@g000001
g000001 / foo.lisp
Created November 2, 2018 14:55
concat
(let* ((a+b (make-string 10 :initial-element #\_))
(a (make-array 5 :displaced-to a+b :element-type 'character))
(b (make-array 5 :displaced-to a+b :displaced-index-offset 5 :element-type 'character)))
(setf (subseq a 0 2) "ab"
(subseq b 0 2) "cd")
(list a b a+b))
;=> ("ab___" "cd___" "ab___cd___")
@g000001
g000001 / gf-foo.lisp
Created August 12, 2017 23:08
総称関数を高速化してみよう
総称関数を高速化してみよう(総称関数でない)
元ネタ
- http://www.doc.gold.ac.uk/~mas01cr/talks/
- http://www.doc.gold.ac.uk/~mas01cr/talks/2009-05-28%20Milan/string=-specializers.lisp
MOPでコード生成して高速化を図るらしい。
面白そうなので真似してみよう。
@g000001
g000001 / run.lisp
Created June 28, 2017 03:38
Zebra (Common Prolog & PAIProlog)
(flet ((run (name)
(with-standard-io-syntax
(format T "~&==== ~S ====~%" name))
(funcall name)))
(run 'paiprolog-zebra::zebra-benchmark)
(run 'clog-zebra::zebra-benchmark)
(run 'clog-zebra::zebra-benchmark/))
@g000001
g000001 / defrunlisp.el
Last active January 17, 2017 16:04
*inferior-lisp* rename
(defmacro defrunlisp (name &optional lisp-exe-path)
(let ((sname (symbol-name name)))
`(defun ,(intern (concat "run-" sname)) ()
(interactive)
(run-lisp ,(or lisp-exe-path sname))
(rename-buffer ,(concat "*inferior-" sname "*")))))
(defrunlisp sbcl "sbcl.wrapper")
@g000001
g000001 / time.lisp
Last active January 3, 2017 19:36
time
;;; 素の状態
(loop :for cnt :from 0
:do (sb-ext:call-with-timing (lambda (&key bytes-consed &allow-other-keys)
(unless (zerop bytes-consed)
(return (print (list bytes-consed cnt)))))
(lambda ()
(let ((a #*10000000000000000000000000000000000000000000000)
(b #*10000000000000000000000000000000000000000000000))
(declare (optimize (speed 3) (safety 0))
(simple-bit-vector a b))
(define (printfoobar)
(define place (zowie))
(place)
(values))
(define (printfoo)
(define place (zowie))
(values))
(define (zowie)
!~Filename~:! !Moon's -*-TECO-*- Library!
LUNAR
!& Load Airless Environment:! !S This is my init file
It's here so that comments will get compressed.
Argument is a string which is the user name!
!* process job command line !
hk fj 0,0a-3"E -d' !* remove ^C at end if any!
0,-1a-15."E -2d' !* remove crlf at end if any.!
@g000001
g000001 / prolog.teco
Created November 5, 2016 14:17
Library for PROLOG Editing System by T.Chikayama
!* -*-TECO-*- Library for PROLOG Editing System by T.Chikayama!
!~FILENAME~:! !Package for programming in PROLOG!
PROLOG
!& Setup PROLOG Library:! !& Set up environment for editing PROLOG codes.
Make *PROLOG* buffer for later use.!
F[D File◊ !* Save Teco Default Filename. !
1,:I**PROLOG*◊M(M.M &_Find_Buffer◊)"L !* If no *PROLOG* buffer yet,!
(defclass symbolic-object-class (standard-class)
())
(defmethod allocate-instance
((class symbolic-object-class) &rest args &key)
(let ((inst (gensym "SYMBOLIC-OBJECT-")))
(setf (get inst :class) class)
(dolist (slot (class-slots class) inst)
(setf (get inst (clos:slot-definition-name slot)) :unbound))))