Skip to content

Instantly share code, notes, and snippets.

@kurohuku
kurohuku / cl-package-symbols.txt
Created October 19, 2010 07:41
Common Lisp Symbols in CL Package
;; Common Lisp (CCLのCommon Lispパッケージ) のシンボル名一覧 計 978 個 (シンボルの長さ順)
* (length = 1, fboundp => T, boundp => T)
+ (length = 1, fboundp => T, boundp => T)
- (length = 1, fboundp => T, boundp => T)
/ (length = 1, fboundp => T, boundp => T)
< (length = 1, fboundp => T, boundp => NIL)
= (length = 1, fboundp => T, boundp => NIL)
> (length = 1, fboundp => T, boundp => NIL)
T (length = 1, fboundp => NIL, boundp => T)
;;;; SRFI-42 Eager Comprehensions ( 先行評価的内包表記 ) in Common Lisp
(defpackage srfi-42
(:use :cl)
(:export ))
(in-package :srfi-42)
;;; Qualifiers
(defun eratosthenes (n)
(loop
:for lst = (loop :for i from 2 to n :collect i) then lst
:for x = (car lst)
:while lst
:collect x
:do
(setf lst
(delete-if
#'(lambda (n) (zerop (mod n x)))
(defun compile-and-load (path)
(compile-file path)
(load path))
;;; clozure common lisp
(setf ccl:*compile-code-coverage* t)
(compile-and-load "path/to/source")
;;(run-test)
(defclass promise ()
((action :initarg :action :initform (error "Required :action"))
(is-called-p :initform nil)
(result :initform nil)))
(defmacro delay (action)
`(make-instance 'promise :action (lambda () ,action)))
(defun force (promise)
@kurohuku
kurohuku / generic.lisp
Created November 1, 2010 04:35
ref , size
(defun defmethods-args-expander (args specifiers)
(when (< (length args) (length specifiers))
(error "Too many specifiers"))
(labels
((inner (ar sr acc)
(if (null ar)
(nreverse acc)
(inner (cdr ar)
(cdr sr)
@kurohuku
kurohuku / test.lsip
Created November 2, 2010 01:41
test
(defpackage net.phorni.unit-test
(:use :cl)
(:shadow cl:assert)
(:nicknames :utest)
(:export test-error
assert
define-condition
do-as-test
*unit-test-error-port*
*default-assert-error-message*
(defparameter *self* nil)
;; `class-name` property list -> { :metaclass-symbol, :member-variables, :class-variables, :attributes}
(defmacro class (name super &body body)
(let ((member-vars (collect-member-vars name body))
(class-vars (collect-class-vars name body))
(metaclass-name (get-metaclass-symbol name)))
(multiple-value-bind (methods inits attributes) (parse-body body)
;; method -> (def name (args) body)
@kurohuku
kurohuku / jni_test.c
Created November 10, 2010 03:00
jni from c
#include <stdio.h>
#include <jni.h>
int main(){
JNIEnv *env;
JavaVM *jvm;
int res;
jclass clazz;
jmethodID mid;
jmethodID mid_to_str;
@kurohuku
kurohuku / named-let.lisp
Created November 16, 2010 07:45
named-let
(defmacro named-let (name binds &body body)
`(labels
((,name ,(mapcar #'car binds)
,@body))
(,name ,@(mapcar #'second binds))))