Skip to content

Instantly share code, notes, and snippets.

@g000001
g000001 / lw.lisp
Last active September 20, 2015 20:49
(lw:set-default-character-element-type 'base-char)
lw:*default-character-element-type*
;=> base-char
(apply #'= (loop :repeat 10 :collect (system:object-address (intern "ああああ"))))
;=> t
(lw:set-default-character-element-type 'character)
lw:*default-character-element-type*
;=> character
lsof /l |clisp -q -norc -x "(progn (map nil #'print (cdr (loop :for line := (read-line *terminal-io* nil) :while line :collect (with-input-from-string (in line) (read in)(read in)))))(values))"|xargs kill
;; ☆コード例に記載のない事前準備☆
;; シンボルの属性にサブリストを登録する
#|||
(a
(b (e (i)
(j))
(f))
(c)
(d (g (k)
(l))
@g000001
g000001 / gist:a453234c17ce07aea249
Created June 5, 2015 23:06
Common Lisp 15分問題 #1: 総称関数の定義をエディタのバッファに挿入する: g000001回答
(cl:in-package :cl-user)
(defun collect-gf (pkg &aux (pkg (find-package pkg)))
(sb-int:collect ((gfs '() ))
(do-symbols (s pkg)
(when (eq pkg (symbol-package s))
(dolist (op (list s `(setf ,s)))
(when (and (fboundp op)
(typep (fdefinition op) 'generic-function))
@g000001
g000001 / gist:f3072dd08e8768f10ddd
Last active August 29, 2015 14:22
(setf a x b x) vs (setf a (setf b x))
(defun foo (ob)
(declare (type ob ob))
(with-slots (a b c d) ob
(setf a (setf b (setf c (setf d 0))))))
; disassembly for foo (assembled 35 bytes)
mov rdx, [r12+96] ; thread.binding-stack-pointer
mov [rbp-8], rdx
xor edx, edx
mov [rcx+37], rdx
(defun foo (x) (bar x))
; STYLE-WARNING: redefining CL-USER::FOO in DEFUN
; in: DEFUN FOO
; (BAR X)
;
; caught STYLE-WARNING:
; undefined function: BAR
;
; compilation unit finished
(declaim (ftype (function (list) string)
cat-with-stream ))
(defun cat-with-stream (list)
(declare (optimize (speed 3) (space 0) (safety 0) (debug 0)))
(with-output-to-string (sstream)
(loop for str in list do (princ str sstream)) ))
(defun tao-sconc (&rest strings)
(ql:quickload :hu.dwim.walker)
(Defpackage :walker-test
(:use :cl :hu.dwim.walker))
(cl:in-package :walker-test)
(defun preserved-symbol-p (sym)
(and (slime-eval `(cl:let ((sym (cl:find-symbol
(cl:format nil "~A" (cl:read-from-string ',sym))
:cl)))
(cl:and sym
(cl:eq sym
(cl:find-symbol
(cl:format nil "~A" (cl:read-from-string ',sym))
(cl:read-from-string ,(slime-current-package))))))
(slime-current-package))
(progn
(set-face-foreground 'sldb-topline-face "orange")
;; (set-face-attribute 'sldb-topline-face nil :underline nil)
(set-face-attribute 'sldb-topline-face nil :inverse-video t)
(set-face-attribute 'sldb-topline-face nil :bold t)
(set-face-foreground 'sldb-condition-face "#8888aa")
(set-face-foreground 'sldb-section-face "green"))