This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defparameter *symbols* '("*" "*" "M" "D" "C" "L" "X" "V" "I")) | |
(defparameter *patterns* '((0) | |
(1 2) | |
(2 2 2) | |
(3 2 2 2) | |
(4 2 1) | |
(5 1) | |
(6 1 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Experimental extensions to Python's re module. | |
import re | |
def int_class_expansion(match): | |
return "(%s)" % \ | |
('|'.join(reversed( [str(x) for x \ | |
in xrange(int(match.group(1)), | |
int(match.group(2))+ 1)] ))) | |
int_class_rule = ( r"\[(\d+)\.\.(\d+)\]", int_class_expansion) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun agenda () | |
"Return the current agenda." | |
(depth (order-by-salience (conflict-set)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Fizzbuzz kata (see http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz) | |
(defpackage :fizzbuzz-test | |
(:use :cl :lisp-unit :fizzbuzz)) | |
(in-package :fizzbuzz-test) | |
(define-test fizzbuzz | |
(let ((seq (fizzbuzz::fizzbuzz-sequence))) | |
(assert-equal 100 (length seq)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CL-USER> (macroexpand-1 '(defrule foo | |
(?o (o (a ?a (evenp ?a)))) | |
(?p (p (a ?a))) | |
=> | |
(print ?a))) | |
(PROGN | |
(COMPILE-LHS FOO FOO-PRODUCTION (?O (O (A ?A (EVENP ?A)))) (?P (P (A ?A)))) | |
(MAKE-OBJECT-TYPE-NODE) | |
(MAKE-PRODUCTION-NODE 'FOO-PRODUCTION) | |
(COMPILE-RHS FOO (PRINT ?A))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; (defrule foo | |
; (?o (o (a ?a (evenp ?a)))) | |
; (?p (p (a ?a))) | |
; => | |
; (print ?a)) | |
(DEFUN FOO1 (KEY FACT TIMESTAMP) | |
(WHEN (AND) | |
(STORE KEY TOKEN 'FOO1-ALPHA-MEMORY) | |
(FOO1-RIGHT KEY TOKEN TIMESTAMP))) |