1251 lines
79 KiB
HTML
1251 lines
79 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link rel="stylesheet" href="../coverage.css"/> <title> beowulf/bootstrap.clj </title>
|
|
</head>
|
|
<body>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
001 (ns beowulf.bootstrap
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
002 "Lisp as defined in Chapter 1 (pages 1-14) of the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
003 `Lisp 1.5 Programmer's Manual`; that is to say, a very simple Lisp language,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
004 which should, I believe, be sufficient in conjunction with the functions
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
005 provided by `beowulf.host`, be sufficient to bootstrap the full Lisp 1.5
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
006 interpreter..
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
007
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
008 The convention is adopted that functions in this file with names in
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
009 ALLUPPERCASE are Lisp 1.5 functions (although written in Clojure) and that
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
010 therefore all arguments must be numbers, symbols or `beowulf.cons_cell.ConsCell`
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
011 objects."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
012 (:require [clojure.string :as s]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
013 [clojure.tools.trace :refer :all]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
014 [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell NIL T F]]))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
015
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
016 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
017 ;;;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
018 ;;; This file is essentially Lisp as defined in Chapter 1 (pages 1-14) of the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
019 ;;; Lisp 1.5 Programmer's Manual; that is to say, a very simple Lisp language,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
020 ;;; which should, I believe, be sufficient in conjunction with the functions
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
021 ;;; provided by `beowulf.host`, be sufficient to bootstrap the full Lisp 1.5
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
022 ;;; interpreter.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
023 ;;;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
024 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
025
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
026 (declare EVAL)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
027
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
028 (def oblist
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
029 "The default environment."
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
030 (atom NIL))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
031
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
032 (def ^:dynamic *options*
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
033 "Command line options from invocation."
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
034 {})
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
035
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 35 forms covered">
|
|
036 (defmacro NULL
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
037 "Returns `T` if and only if the argument `x` is bound to `NIL`; else `F`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
038 [x]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
039 `(if (= ~x NIL) T F))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
040
|
|
</span><br/>
|
|
<span class="covered" title="64 out of 64 forms covered">
|
|
041 (defmacro ATOM
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
042 "Returns `T` if and only is the argument `x` is bound to and atom; else `F`.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
043 It is not clear to me from the documentation whether `(ATOM 7)` should return
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
044 `T` or `F`. I'm going to assume `T`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
045 [x]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
046 `(if (or (symbol? ~x) (number? ~x)) T F))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
047
|
|
</span><br/>
|
|
<span class="partial" title="76 out of 88 forms covered">
|
|
048 (defmacro ATOM?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
049 "The convention of returning `F` from predicates, rather than `NIL`, is going
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
050 to tie me in knots. This is a variant of `ATOM` which returns `NIL`
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
051 on failure."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
052 [x]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
053 `(if (or (symbol? ~x) (number? ~x)) T NIL))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
054
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
055 (defn CAR
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
056 "Return the item indicated by the first pointer of a pair. NIL is treated
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
057 specially: the CAR of NIL is NIL."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
058 [x]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
059 (cond
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 5 forms covered">
|
|
060 (= x NIL) NIL
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
061 (instance? beowulf.cons_cell.ConsCell x) (.CAR x)
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
062 :else
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
063 (throw
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
064 (Exception.
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
065 (str "Cannot take CAR of `" x "` (" (.getName (.getClass x)) ")")))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
066
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
067 (defn CDR
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
068 "Return the item indicated by the second pointer of a pair. NIL is treated
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
069 specially: the CDR of NIL is NIL."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
070 [x]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
071 (cond
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 5 forms covered">
|
|
072 (= x NIL) NIL
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
073 (instance? beowulf.cons_cell.ConsCell x) (.CDR x)
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
074 :else
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
075 (throw
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
076 (Exception.
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
077 (str "Cannot take CDR of `" x "` (" (.getName (.getClass x)) ")")))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
078
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
079 (defn uaf
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
080 "Universal access function; `l` is expected to be an arbitrary list, `path`
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
081 a (clojure) list of the characters `a` and `d`. Intended to make declaring
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
082 all those fiddly `#'c[ad]+r'` functions a bit easier"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
083 [l path]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
084 (cond
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 5 forms covered">
|
|
085 (= l NIL) NIL
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
086 (empty? path) l
|
|
</span><br/>
|
|
<span class="partial" title="5 out of 11 forms covered">
|
|
087 :else (case (last path)
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
088 \a (uaf (CAR l) (butlast path))
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
089 \d (uaf (CDR l) (butlast path)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
090
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
091 (defn CAAR [x] (uaf x (seq "aa")))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
092 (defn CADR [x] (uaf x (seq "ad")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
093 (defn CDDR [x] (uaf x (seq "dd")))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
094 (defn CDAR [x] (uaf x (seq "da")))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
095
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
096 (defn CAAAR [x] (uaf x (seq "aaa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
097 (defn CAADR [x] (uaf x (seq "aad")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
098 (defn CADAR [x] (uaf x (seq "ada")))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
099 (defn CADDR [x] (uaf x (seq "add")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
100 (defn CDDAR [x] (uaf x (seq "dda")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
101 (defn CDDDR [x] (uaf x (seq "ddd")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
102 (defn CDAAR [x] (uaf x (seq "daa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
103 (defn CDADR [x] (uaf x (seq "dad")))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
104
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
105 (defn CAAAAR [x] (uaf x (seq "aaaa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
106 (defn CAADAR [x] (uaf x (seq "aada")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
107 (defn CADAAR [x] (uaf x (seq "adaa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
108 (defn CADDAR [x] (uaf x (seq "adda")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
109 (defn CDDAAR [x] (uaf x (seq "ddaa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
110 (defn CDDDAR [x] (uaf x (seq "ddda")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
111 (defn CDAAAR [x] (uaf x (seq "daaa")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
112 (defn CDADAR [x] (uaf x (seq "dada")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
113 (defn CAAADR [x] (uaf x (seq "aaad")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
114 (defn CAADDR [x] (uaf x (seq "aadd")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
115 (defn CADADR [x] (uaf x (seq "adad")))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
116 (defn CADDDR [x] (uaf x (seq "addd")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
117 (defn CDDADR [x] (uaf x (seq "ddad")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
118 (defn CDDDDR [x] (uaf x (seq "dddd")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
119 (defn CDAADR [x] (uaf x (seq "daad")))
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 7 forms covered">
|
|
120 (defn CDADDR [x] (uaf x (seq "dadd")))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
121
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
122 (defn EQ
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
123 "Returns `T` if and only if both `x` and `y` are bound to the same atom,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
124 else `F`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
125 [x y]
|
|
</span><br/>
|
|
<span class="covered" title="23 out of 23 forms covered">
|
|
126 (if (and (= (ATOM x) T) (= x y)) T F))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
127
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
128 (defn EQUAL
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
129 "This is a predicate that is true if its two arguments are identical
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
130 S-expressions, and false if they are different. (The elementary predicate
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
131 `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
132 an example of a conditional expression inside a conditional expression.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
133
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
134 NOTE: returns `F` on failure, not `NIL`"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
135 [x y]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
136 (cond
|
|
</span><br/>
|
|
<span class="covered" title="16 out of 16 forms covered">
|
|
137 (= (ATOM x) T) (EQ x y)
|
|
</span><br/>
|
|
<span class="covered" title="19 out of 19 forms covered">
|
|
138 (= (EQUAL (CAR x) (CAR y)) T) (EQUAL (CDR x) (CDR y))
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
139 :else F))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
140
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
141 (defn SUBST
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
142 "This function gives the result of substituting the S-expression `x` for
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
143 all occurrences of the atomic symbol `y` in the S-expression `z`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
144 [x y z]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
145 (cond
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
146 (= (EQUAL y z) T) x
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
147 (= (ATOM? z) T) z ;; NIL is a symbol
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
148 :else
|
|
</span><br/>
|
|
<span class="covered" title="15 out of 15 forms covered">
|
|
149 (make-cons-cell (SUBST x y (CAR z)) (SUBST x y (CDR z)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
150
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
151 (defn APPEND
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
152 "Append the the elements of `y` to the elements of `x`.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
153
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
154 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
155 See page 11 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
156 [x y]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
157 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
158 (= x NIL) y
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
159 :else
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
160 (make-cons-cell (CAR x) (APPEND (CDR x) y))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
161
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
162
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
163 (defn MEMBER
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
164 "This predicate is true if the S-expression `x` occurs among the elements
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
165 of the list `y`.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
166
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
167 All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
168 See page 11 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
169 [x y]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
170 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
171 (= y NIL) F ;; NOTE: returns F on falsity, not NIL
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
172 (= (EQUAL x (CAR y)) T) T
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
173 :else (MEMBER x (CDR y))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
174
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
175 (defn PAIRLIS
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
176 "This function gives the list of pairs of corresponding elements of the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
177 lists `x` and `y`, and APPENDs this to the list `a`. The resultant list
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
178 of pairs, which is like a table with two columns, is called an
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
179 association list.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
180
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
181 Eessentially, it builds the environment on the stack, implementing shallow
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
182 binding.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
183
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
184 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
185 See page 12 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
186 [x y a]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
187 (cond
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
188 ;; the original tests only x; testing y as well will be a little more
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
189 ;; robust if `x` and `y` are not the same length.
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
190 (or (= NIL x) (= NIL y)) a
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
191 :else (make-cons-cell
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
192 (make-cons-cell (CAR x) (CAR y))
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
193 (PAIRLIS (CDR x) (CDR y) a))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
194
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
195 (defn ASSOC
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
196 "If a is an association list such as the one formed by PAIRLIS in the above
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
197 example, then assoc will produce the first pair whose first term is x. Thus
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
198 it is a table searching function.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
199
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
200 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
201 See page 12 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
202 [x a]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
203 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
204 (= NIL a) NIL ;; this clause is not present in the original but is added for
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
205 ;; robustness.
|
|
</span><br/>
|
|
<span class="covered" title="12 out of 12 forms covered">
|
|
206 (= (EQUAL (CAAR a) x) T) (CAR a)
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
207 :else
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
208 (ASSOC x (CDR a))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
209
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
210 (defn- SUB2
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
211 "Internal to `SUBLIS`, q.v., which SUBSTitutes into a list from a store.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
212 ? I think this is doing variable binding in the stack frame?"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
213 [a z]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
214 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
215 (= NIL a) z
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
216 (= (CAAR a) z) (CDAR a) ;; TODO: this looks definitely wrong
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
217 :else
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
218 (SUB2 (CDR a) z)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
219
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
220 (defn SUBLIS
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
221 "Here `a` is assumed to be an association list of the form
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
222 `((ul . vl)...(un . vn))`, where the `u`s are atomic, and `y` is any
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
223 S-expression. What `SUBLIS` does, is to treat the `u`s as variables when
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
224 they occur in `y`, and to SUBSTitute the corresponding `v`s from the pair
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
225 list.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
226
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
227 My interpretation is that this is variable binding in the stack frame.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
228
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
229 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
230 See page 12 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
231 [a y]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
232 (cond
|
|
</span><br/>
|
|
<span class="covered" title="16 out of 16 forms covered">
|
|
233 (= (ATOM? y) T) (SUB2 a y)
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
234 :else
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
235 (make-cons-cell (SUBLIS a (CAR y)) (SUBLIS a (CDR y)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
236
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
237 (defn interop-interpret-q-name
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
238 "For interoperation with Clojure, it will often be necessary to pass
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
239 qualified names that are not representable in Lisp 1.5. This function
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
240 takes a sequence in the form `(PART PART PART... NAME)` and returns
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
241 a symbol in the form `PART.PART.PART/NAME`. This symbol will then be
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
242 tried in both that form and lower-cased. Names with hyphens or
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
243 underscores cannot be represented with this scheme."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
244 [l]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
245 (if
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
246 (seq? l)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
247 (symbol
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
248 (s/reverse
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
249 (s/replace-first
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
250 (s/reverse
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
251 (s/join "." (map str l)))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
252 "."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
253 "/")))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
254 l))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
255
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 11 forms covered">
|
|
256 (deftrace INTEROP
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
257 "Clojure (or other host environment) interoperation API. `fn-symbol` is expected
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
258 to be either
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
259
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
260 1. a symbol bound in the host environment to a function; or
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
261 2. a sequence (list) of symbols forming a qualified path name bound to a
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
262 function.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
263
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
264 Lower case characters cannot normally be represented in Lisp 1.5, so both the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
265 upper case and lower case variants of `fn-symbol` will be tried. If the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
266 function you're looking for has a mixed case name, that is not currently
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
267 accessible.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
268
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
269 `args` is expected to be a Lisp 1.5 list of arguments to be passed to that
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
270 function. Return value must be something acceptable to Lisp 1.5, so either
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
271 a symbol, a number, or a Lisp 1.5 list.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
272
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
273 If `fn-symbol` is not found (even when cast to lower case), or is not a function,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
274 or the value returned cannot be represented in Lisp 1.5, an exception is thrown
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
275 with `:cause` bound to `:interop` and `:detail` set to a value representing the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
276 actual problem."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
277 [fn-symbol args]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
278 (let
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
279 [q-name (if
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
280 (seq? fn-symbol)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
281 (interop-interpret-q-name fn-symbol)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
282 fn-symbol)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
283 l-name (symbol (s/lower-case q-name))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
284 f (cond
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
285 (try
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
286 (fn? (eval l-name))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
287 (catch java.lang.ClassNotFoundException e nil)) (eval l-name)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
288 (try
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
289 (fn? (eval q-name))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
290 (catch java.lang.ClassNotFoundException e nil)) (eval q-name)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
291 :else (throw
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
292 (ex-info
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
293 (str "INTEROP: unknown function `" fn-symbol "`")
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
294 {:cause :interop
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
295 :detail :not-found
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
296 :name fn-symbol
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
297 :also-tried l-name})))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
298 result (eval (cons f args))]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
299 (cond
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
300 (instance? beowulf.cons_cell.ConsCell result) result
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
301 (seq? result) (make-beowulf-list result)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
302 (symbol? result) result
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
303 (string? result) (symbol result)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
304 (number? result) result
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
305 :else (throw
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
306 (ex-info
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
307 (str "INTEROP: Cannot return `" result "` to Lisp 1.5.")
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
308 {:cause :interop
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
309 :detail :not-representable
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
310 :result result})))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
311
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
312 (defn APPLY
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
313 "For bootstrapping, at least, a version of APPLY written in Clojure.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
314 All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
315 See page 13 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
316 [function args environment]
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 4 forms covered">
|
|
317 (cond
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
318 (=
|
|
</span><br/>
|
|
<span class="partial" title="7 out of 9 forms covered">
|
|
319 (ATOM? function)
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 7 forms covered">
|
|
320 T)(cond
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
321 ;; TODO: doesn't check whether `function` is bound in the environment;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
322 ;; we'll need that before we can bootstrap.
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 7 forms covered">
|
|
323 (= function 'CAR) (CAAR args)
|
|
</span><br/>
|
|
<span class="partial" title="4 out of 7 forms covered">
|
|
324 (= function 'CDR) (CDAR args)
|
|
</span><br/>
|
|
<span class="covered" title="11 out of 11 forms covered">
|
|
325 (= function 'CONS) (make-cons-cell (CAR args) (CADR args))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 20 forms covered">
|
|
326 (= function 'ATOM) (if (ATOM? (CAR args)) T NIL)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 15 forms covered">
|
|
327 (= function 'EQ) (if (= (CAR args) (CADR args)) T NIL)
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
328 :else
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
329 (APPLY
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
330 (EVAL function environment)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
331 args
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
332 environment))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 8 forms covered">
|
|
333 (= (first function) 'LAMBDA) (EVAL
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
334 (CADDR function)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
335 (PAIRLIS (CADR function) args environment))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 8 forms covered">
|
|
336 (= (first function) 'LABEL) (APPLY
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
337 (CADDR function)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
338 args
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
339 (make-cons-cell
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
340 (make-cons-cell
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
341 (CADR function)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
342 (CADDR function))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
343 environment))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
344
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
345 (defn- EVCON
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
346 "Inner guts of primitive COND. All args are assumed to be
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
347 `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
348 See page 13 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
349 [clauses env]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
350 (if
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 9 forms covered">
|
|
351 (not= (EVAL (CAAR clauses) env) NIL)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
352 (EVAL (CADAR clauses) env)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
353 (EVCON (CDR clauses) env)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
354
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
355 (defn- EVLIS
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
356 "Map `EVAL` across this list of `args` in the context of this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
357 `env`ironment.All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
358 See page 13 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
359 [args env]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
360 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
361 (= NIL args) NIL
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
362 :else
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
363 (make-cons-cell
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
364 (EVAL (CAR args) env)
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
365 (EVLIS (CDR args) env))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
366
|
|
</span><br/>
|
|
<span class="covered" title="11 out of 11 forms covered">
|
|
367 (deftrace traced-eval
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
368 "Essentially, identical to EVAL except traced."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
369 [expr env]
|
|
</span><br/>
|
|
<span class="partial" title="2 out of 3 forms covered">
|
|
370 (cond
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
371 (=
|
|
</span><br/>
|
|
<span class="partial" title="9 out of 10 forms covered">
|
|
372 (ATOM? expr) T)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
373 (CDR (ASSOC expr env))
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
374 (=
|
|
</span><br/>
|
|
<span class="partial" title="9 out of 13 forms covered">
|
|
375 (ATOM? (CAR expr))
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
376 T)(cond
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
377 (= (CAR expr) 'QUOTE) (CADR expr)
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
378 (= (CAR expr) 'COND) (EVCON (CDR expr) env)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
379 :else (APPLY
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
380 (CAR expr)
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
381 (EVLIS (CDR expr) env)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
382 env))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
383 :else (APPLY
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
384 (CAR expr)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
385 (EVLIS (CDR expr) env)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
386 env)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
387
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
388 (defn EVAL
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
389 "For bootstrapping, at least, a version of EVAL written in Clojure.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
390 All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
391 See page 13 of the Lisp 1.5 Programmers Manual."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
392 [expr env]
|
|
</span><br/>
|
|
<span class="partial" title="3 out of 4 forms covered">
|
|
393 (cond
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
394 (true? (:trace *options*))
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
395 (traced-eval expr env)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
396 (=
|
|
</span><br/>
|
|
<span class="partial" title="9 out of 10 forms covered">
|
|
397 (ATOM? expr) T)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
398 (CDR (ASSOC expr env))
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
399 (=
|
|
</span><br/>
|
|
<span class="partial" title="9 out of 13 forms covered">
|
|
400 (ATOM? (CAR expr))
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
401 T)(cond
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
402 (= (CAR expr) 'QUOTE) (CADR expr)
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
403 (= (CAR expr) 'COND) (EVCON (CDR expr) env)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
404 :else (APPLY
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
405 (CAR expr)
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
406 (EVLIS (CDR expr) env)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
407 env))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
408 :else (APPLY
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
409 (CAR expr)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 6 forms covered">
|
|
410 (EVLIS (CDR expr) env)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
411 env)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
412
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
413
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
414
|
|
</span><br/>
|
|
</body>
|
|
</html>
|