Skip to content

Instantly share code, notes, and snippets.

View destructuring.lisp
;; -*- mode: lisp; package: destructuring; -*-
;;; destructuring-bind.l
;;
;; Copyright (c) 1980, Massachusetts Institute of Technology
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
View named-instance-class.lisp
;;; -*- mode: Lisp; coding: utf-8 -*-
(ql:quickload 'closer-mop)
(defpackage named-instance-class
(:use c2cl))
(in-package named-instance-class)
View shadow.lisp
(progn
#.(set-macro-character #\[ (lambda (srm chr)
(declare (ignore chr))
(read-delimited-list #\] srm T)))
[list 0
1
2
#.(progn
(set-macro-character #\[ (lambda (srm chr)
(declare (ignore chr))
View prog.lisp
;; a la MACLISP
(DEFUN FACTORS (N)
(PROG (FACS SQRTN D)
(SETQ FACS () )
(SETQ D 2)
(GO L1)
L2 (SETQ N (FLOOR N D))
(SETQ FACS (CONS D FACS))
L1 (SETQ SQRTN (ISQRT N))
L (COND ((> D SQRTN) (GO X)))
View comment.lisp
#| foo |#
;;; foo
#;(foo
bar
baz)
foo bar baz
#|
View foo.lisp
(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 Aug 12, 2017
総称関数を高速化してみよう
View gf-foo.lisp
総称関数を高速化してみよう(総称関数でない)
元ネタ
- 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 Jun 28, 2017
Zebra (Common Prolog & PAIProlog)
View run.lisp
(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 Jan 17, 2017
*inferior-lisp* rename
View defrunlisp.el
(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")
View time.lisp
;;; 素の状態
(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))