smalltalk: SequenceableCollection methods (13) + String at:/copyFrom:to: + 28 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 10:58:08 +00:00
parent 0b5f3c180e
commit 3be722d5b6
4 changed files with 212 additions and 1 deletions

View File

@@ -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)