R6RS:翻訳:Standard Libraries:18 Mutable strings

R6RS:翻訳:Standard Libraries:18 Mutable strings

変更可能な文字列

(rnrs mutable-strings (6)) ライブラリで提供される string-set! 手続きにより、文字列をその場で変更することができるようになる。

[procedure] (string-set! string k char)

kstring の有効な添字でなければならない。 string-set! 手続きでは stringk 番目の要素に char を格納し、未定義値を返す。

string-set! に変更不可能な文字列を渡すと &assertion 型の例外が発生する。

(define (f) (make-string 3 #\*))
(define (g) "***")
(string-set! (f) 0 #\?)          ⇒  unspecified
(string-set! (g) 0 #\?)          ⇒  unspecified
             ; should raise  &assertion exception
(string-set! (symbol->string ’immutable)
             0
             #\?)          ⇒  unspecified
             ; should raise  &assertion exception

: 実装系は string-set! を定数時間で実行できるようにすべきである。

[procedure] (string-fill! string char)

与えられた string の各要素に char を格納し、未定義値を返す。


Last modified : 2008/03/15 01:05:13 UTC