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

View File

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