Skip to content

Instantly share code, notes, and snippets.

(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)
(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)))
;;;; SRFI-42 Eager Comprehensions ( 先行評価的内包表記 ) in Common Lisp
(defpackage srfi-42
(:use :cl)
(:export ))
(in-package :srfi-42)
;;; Qualifiers
@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)
(defmacro dynamic-labels
((&rest definitions) &body body)
(let ((olds (mapcar #'(lambda (x)
(declare (ignore x))
(gensym))
definitions)))
`(let ,(mapcar
#'(lambda (sym def)
`(,sym ,(and (fboundp (car def)) (symbol-function (car def)))))
olds
class String
def tokenize()
return self.gsub(/(\(|\))/){|s| " " + s + " " }.split(' ');
end
end
def parse(tokens)
if(tokens.length == 0)
(defun normalize-curr (curr)
(let ((curr (member-if-not
(lambda (obj)
(= obj ?\ ))
curr)))
(if (every #'characterp curr)
(concatenate 'string (nreverse curr))
(if (stringp (car curr))
(car curr)
(error "Invalid element")))))
(asdf:oos 'asdf:load-op :cl-ppcre)
(defpackage expect
(:use :cl :cl-ppcre)
(:export expect expect-strings))
(in-package expect)
(defmacro expect (port (&rest options) &body clauses)
(let ((ch (gensym "ch"))
(str (gensym "str"))
@kurohuku
kurohuku / ps.el
Created September 22, 2010 04:12
(defun postscript-process ()
(get-buffer-process (get-buffer "*postscript*")))
(defun run-postscript ()
(interactive)
(require 'comint)
(switch-to-buffer (make-comint "postscript" "gs")))
(push '("postscript" . utf-8) process-coding-system-alist)
;;;; PAIP 2.2
(defparameter *simple-grammar*
`((sentence -> (noun-phrase verb-phrase))
(noun-phrase -> (Article Noun))
(verb-phrase -> (Verb noun-phrase))
(Article -> the a)
(Noun -> man ball woman table)
(Verb -> hit took saw liked)))