連鎖性言語/rest パラメータスタック型言語は (Common Lisp の (+ a) (+ a b) (+ a b c) (apply #'+ list) スタック型言語では、 ひとつのアプローチ方法として、1 つの整数を取り、指定された数のスタック上の項目を操作する新しいワードを作成するやり方があります。Factor の "a" 1 narray "a" "b" 2 narray "a" "b" "c" 3 narray よく使われるもうひとつのアプローチとして、値のシーケンスを取るワードを作成するやり方があります。すべての値がリテラルなら、次のようになります。 { 5 } sum { 5 6 } sum { 5 6 7 } sum そうでない場合には、次のようにします。 2 3 + 6 7 3array sum This revision created on Sun, 9 Aug 2009 17:27:14 by mncharity (expanded "takes a sequence" example to clarify { } only works with literals) |
|
|
All content is © 2008 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license. |
|