Permalink
Browse files

Initial commmit.

  • Loading branch information...
0 parents commit 05b9c816d3638c76e5a2ad9d7bfe1530f83dc29d @stassats committed Mar 4, 2012
Showing with 78 additions and 0 deletions.
  1. +7 −0 closer-apl.asd
  2. +62 −0 closer-apl.lisp
  3. +9 −0 packages.lisp
7 closer-apl.asd
@@ -0,0 +1,7 @@
+;;; -*- Mode: Lisp -*-
+
+(defsystem closer-apl
+ :serial t
+ :depends-on (named-readtables)
+ :components ((:file "packages")
+ (:file "closer-apl")))
62 closer-apl.lisp
@@ -0,0 +1,62 @@
+;;; -*- Mode: Lisp -*-
+
+;;; This software is in the public domain and is
+;;; provided with absolutely no warranty.
+
+(in-package #:closer-apl)
+
+(named-readtables:in-readtable :apl)
+
+(set-macro-character #\⌋ (get-macro-character #\)))
+(set-macro-character #\
+ (lambda (stream char)
+ (declare (ignore char))
+ (prog1 `(floor ,(read stream t nil t))
+ (let ((char (peek-char t stream t nil t)))
+ (if (char= char #\⌋)
+ (read-char stream t nil t)
+ (error 'reader-error :stream stream))))))
+
+(set-macro-character #\⌉ (get-macro-character #\)))
+(set-macro-character #\
+ (lambda (stream char)
+ (declare (ignore char))
+ (prog1 `(ceiling ,(read stream t nil t))
+ (let ((char (peek-char t stream t nil t)))
+ (if (char= char #\⌉)
+ (read-char stream t nil t)
+ (error 'reader-error :stream stream))))))
+
+(set-macro-character #\
+ (lambda (stream char)
+ (declare (ignore char))
+ `(sqrt ,(read stream t nil t))))
+(set-macro-character #\¬
+ (lambda (stream char)
+ (declare (ignore char))
+ `(not ,(read stream t nil t))))
+
+(set-macro-character #\≠ (constantly '/=))
+(set-macro-character #\≤ (constantly '<=))
+(set-macro-character #\≥ (constantly '>=))
+(set-macro-character #\∅ (constantly ()))
+
+;;;
+;;; ∃ n ∈ (1 2 3 4 5): (evenp n) => T
+
+(set-macro-character #\
+ (lambda (stream char)
+ (declare (ignore char))
+ (let ((variable (read stream t nil t))
+ (list
+ (progn
+ (assert (char= #\∈ (peek-char t stream t nil t)))
+ (read-char stream t nil t)
+ (read stream t nil t)))
+ (expression
+ (progn
+ (assert (char= #\: (peek-char t stream t nil t)))
+ (read-char stream t nil t)
+ (read stream t nil t))))
+ `(some (lambda (,variable) ,expression) ',list))))
+
9 packages.lisp
@@ -0,0 +1,9 @@
+;;; -*- Mode: Lisp -*-
+
+(defpackage #:closer-apl
+ (:nicknames #:apl)
+ (:use #:cl)
+ (:export ))
+
+(named-readtables:defreadtable :apl
+ (:merge :standard))

0 comments on commit 05b9c81

Please sign in to comment.