smalltalk: SequenceableCollection methods (13) + String at:/copyFrom:to: + 28 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -757,6 +757,25 @@
|
||||
((= selector "printString") (str "'" s "'"))
|
||||
((= selector "asString") s)
|
||||
((= selector "asSymbol") (make-symbol (if (symbol? s) (str s) s)))
|
||||
;; 1-indexed character access; returns the character (a 1-char string).
|
||||
((= selector "at:") (nth s (- (nth args 0) 1)))
|
||||
((= selector "do:")
|
||||
(let ((i 0) (n (len s)) (block (nth args 0)))
|
||||
(begin
|
||||
(define
|
||||
sd-loop
|
||||
(fn ()
|
||||
(when (< i n)
|
||||
(begin
|
||||
(st-block-apply block (list (nth s i)))
|
||||
(set! i (+ i 1))
|
||||
(sd-loop)))))
|
||||
(sd-loop)
|
||||
s)))
|
||||
((= selector "first") (nth s 0))
|
||||
((= selector "last") (nth s (- (len s) 1)))
|
||||
((= selector "copyFrom:to:")
|
||||
(slice s (- (nth args 0) 1) (nth args 1)))
|
||||
((= selector "class") (st-class-ref (st-class-of s)))
|
||||
((= selector "isNil") false)
|
||||
((= selector "notNil") true)
|
||||
|
||||
Reference in New Issue
Block a user