← 都来码 / Dolaima← 例程索引forth/school/reverse_a_string.fth 原文

forth/school/reverse_a_string.fth · 208 字节 · 下载原文

: exchange ( a1 a2 -- )
  2dup c@ swap c@ rot c! swap c! ;
: reverse ( c-addr u -- )
  1- bounds begin 2dup > while
    2dup exchange
    -1 /string
  repeat 2drop ;

s" testing" 2dup reverse type   \ gnitset