Clean up whitespace

This commit is contained in:
Kodi Arfer 2019-07-02 12:10:01 -04:00
parent 308bedbebe
commit 6bc9e842e1
5 changed files with 72 additions and 63 deletions

View File

@ -3,11 +3,13 @@
;; license. See the LICENSE.
(defclass Sequence []
(defn --init-- [self func]
"initialize a new sequence with a function to compute values"
(setv (. self func) func)
(setv (. self cache) [])
(setv (. self high-water) -1))
(defn --getitem-- [self n]
"get nth item of sequence"
(if (hasattr n "start")
@ -23,6 +25,7 @@
(setv (. self high-water) (inc (. self high-water)))
(.append (. self cache) (.func self (. self high-water))))
(get self n))))))
(defn --iter-- [self]
"create iterator for this sequence"
(setv index 0)
@ -31,6 +34,7 @@
(setv index (inc index)))
(except [IndexError]
(return))))
(defn --len-- [self]
"length of the sequence, dangerous for infinite sequences"
(setv index (. self high-water))
@ -39,7 +43,9 @@
(setv index (inc index)))
(except [IndexError]
(len (. self cache)))))
(setv max-items-in-repr 10)
(defn --str-- [self]
"string representation of this sequence"
(setv items (list (take (inc self.max-items-in-repr) self)))
@ -47,6 +53,7 @@
"[{0}, ...]"
"[{0}]")
(.join ", " (map str items))))
(defn --repr-- [self]
"string representation of this sequence"
(.--str-- self)))

View File

@ -1773,7 +1773,8 @@ macros()
(defn test-pep-3115 []
(defclass member-table [dict]
(defn --init-- [self] (setv self.member-names []))
(defn --init-- [self]
(setv self.member-names []))
(defn --setitem-- [self key value]
(if (not-in key self)
@ -1781,7 +1782,8 @@ macros()
(dict.--setitem-- self key value)))
(defclass OrderedClass [type]
(setv --prepare-- (classmethod (fn [metacls name bases] (member-table))))
(setv --prepare-- (classmethod (fn [metacls name bases]
(member-table))))
(defn --new-- [cls name bases classdict]
(setv result (type.--new-- cls name bases (dict classdict)))