OSDN Git Service

残りの流し込み。10章未翻訳部分途中まで翻訳.
[omake-japanese/omake_trans.git] / base.rst
1 .. 9-base
2
3 .. _label9:
4
5 9. 基本ライブラリ
6 ==================================
7
8 .. index::
9    single: OMAKE_VERSION
10    single: STDLIB
11    single: OMAKEPATH
12    single: OSTYPE
13    single: SYSNAME
14    single: NODENAME
15    single: OS_VERSION
16    single: MACHINE
17    single: HOST
18    single: USER
19    single: HOME
20    single: PID
21    single: TARGETS
22    single: BUILD_SUMMARY
23    single: VERBOSE
24 .. _label9.1:
25
26 9.1 ビルドイン変数
27 ----------------------------------
28
29 * **OMAKE_VERSION** 
30
31   OMakeのバージョンを表します。
32
33 .. Version of OMake.
34
35 * **STDLIB**
36
37   OMakeの基本ライブラリのファイルがあるディレクトリを表します。起動時に、この変数のデフォルトの値は以下のようにして決定されます。
38
39   * OMAKELIB環境変数の値が存在している場合は用いられます。ただし、値は絶対パスでなければなりません。
40   * Windows上では、レジストリのキー ``HKEY_CURRENT_USER\SOFTWARE\MetaPRL\OMake\OMAKELIB`` と ``HKEY_LOCAL_MACHINE\SOFTWARE\MetaPRL\OMake\OMAKELIB`` が調べられ、もし存在している場合にはその値が用いられます。
41   * さもなければコンパイルされた時の値が用いられます。
42
43   現在のデフォルトの値は ``omake --version`` を走らせることによって参照できます。
44
45 .. The directory where the OMake standard library files reside. At startup, the default value is determined as follows. 
46       * The value of the OMAKELIB environment variable, if set (must contain an absolute path, if set), otherwise
47       * On Windows, the registry keys HKEY_CURRENT_USER\SOFTWARE\MetaPRL\OMake\OMAKELIB and HKEY_LOCAL_MACHINE\SOFTWARE\MetaPRL\OMake\OMAKELIB are looked up and the value is used, if exist.
48       * Otherwise a compile-time default it used. 
49   The current default value may be accessed by running omake --version
50
51 * **OMAKEPATH**
52
53   ``include`` と ``open`` 文における検索パスを指定した、ディレクトリの配列です(詳細は ":ref:`label4.7`" を参照してください)。デフォルトの値は ``.`` と ``$(STDLIB)`` の2つの成分を持った配列です。
54
55 .. An array of directories specifying the lookup path for the include and open directives (see Section 4.7). The default value is an array of two elements — . and $(STDLIB).
56
57 * **OSTYPE**
58   
59   omakeを走らせているマシンのアーキテクチャの集合です。考えられる値は ``Unix`` (LinuxやMac OS Xを含む、すべてのUnixのバージョンを表します), ``Win32`` (MS-Windowsでは、OMakeはMSVC++かMingwを用いてコンパイルします), ``Cygwin`` (MS-Windowsでは、OMakeはCygwinを用いてコンパイルします)があります。
60
61 .. Set to the machine architecture omake is running on. Possible values are Unix (for all Unix versions, including Linux and Mac OS X), Win32 (for MS-Windows, OMake compiled with MSVC++ or Mingw), and Cygwin (for MS-Windows, OMake compiled with Cygwin). 
62
63 * **SYSNAME**
64   
65   現在のマシンのOSの名前を表します。
66
67 .. The name of the operating system for the current machine. 
68
69 * **NODENAME**
70
71   現在のマシンのホスト名を表します。
72
73 .. The hostname of the current machine. 
74
75 * **OS_VERSION**
76
77   OSのバージョンを表します。
78
79 .. The operating system release. 
80
81 * **MACHINE**
82
83   マシンのアーキテクチャを表します(例: ``i386`` , ``sparc`` , etc...)。
84
85 .. The machine architecture, e.g. i386, sparc, etc. 
86
87 * **HOST**
88
89   ``NODENAME`` と等価です。
90
91 .. Same as NODENAME. 
92
93 * **USER**
94
95   処理を実行しているユーザのログイン名を表します。
96
97 .. The login name of the user executing the process.
98
99 * **HOME**
100
101   処理を実行しているユーザのホームディレクトリを表します。
102
103 .. The home directory of the user executing the process. 
104
105 * **PID**
106
107   OMakeのプロセスIDを表します。
108
109 .. The OMake process id. 
110
111 * **TARGETS**
112
113   コマンドラインのターゲットを表す文字列です。例えば、もしOMakeが以下のコマンドラインで実行されたとしましょう。 ::
114
115         omake CFLAGS=1 foo bar.c
116
117   この場合、 ``TARGETS`` は ``foo bar.c`` が定義されます。
118
119 .. The command-line target strings. For example, if OMake is invoked with the following command line, 
120    then TARGETS is defined as foo bar.c.
121
122 * **BUILD_SUMMARY**
123
124   ``BUILD_SUMMARY`` 変数は ``omake`` がビルド状況を要約したファイルが定義されています(メッセージはビルドの最後で出力されます)。ビルドが開始されたとき、このファイルは空です。あなたはビルド中にこのファイルを編集したり追加することで、ビルドの要約に何らかのメッセージを追加できます。
125
126   例えば、もしあなたがいくつかのアクションが発生した場所を把握しておきたいとしますと、ビルドの要約に以下を追加することで実現できます。 ::
127
128      foo: boo
129          echo "The file foo was built" >> $(BUILD_SUMMARY)
130          ...build foo...
131
132 .. The BUILD_SUMMARY variable refers to the file that omake uses to summarize a build (the message that is printed at the very end of a build). The file is empty when the build starts. If you wish to add additional messages to the build summary, you can edit/modify this file during the build.
133    For example, if you want to point out that some action was taken, you can append a message to the build summary.
134
135 * **VERBOSE**
136
137   いくつかのコマンドのメッセージが冗長に出力されます。デフォルトの値は ``false`` で、 ``--verbose`` オプションを用いてOMakeが実行された場合、変数の値は ``true`` となります。
138
139 .. Whether certain commands should be verbose. A boolean flag that is false by default and is set to true when OMake is invoked with the --verbose option. 
140
141 .. _label9.2:
142
143 9.2 論理式、真偽関数、コマンドのコントロール
144 -------------------------------------------------
145 .. Boolean values in omake are represented by case-insensitive strings. The false value can be represented by the strings false, no, nil, undefined or 0, and everything else is true.
146
147 omakeのブーリアン型は状況に無反応な(case-insensitive)文字列によって表現されます。『偽』は文字列 ``false`` , ``no`` , ``nil`` , ``undefined`` , ``0`` のいづれかによって表現されます。それ以外はすべて『真』となります。
148
149 .. index::
150    single: not()
151 .. _label9.2.1:
152
153 9.2.1 not
154 ^^^^^^^^^^^^^^^^^^^^^^^^^
155 ::
156
157    $(not e) : String
158       e : String
159
160 .. The not function negates a Boolean value.
161
162 ``not`` 関数は真偽値を反転します。
163
164 .. For example, $(not false) expands to the string true, and $(not hello world) expands to false. 
165
166 例えば、 ``$(not false)`` は ``true`` が返され、 ``$(not hello world)`` は ``false`` が返されます。
167
168 .. index::
169    single: equal()
170 .. _label9.2.2:
171
172 9.2.2 equal
173 ^^^^^^^^^^^^^^^^^^^^^^^^^
174 .. The equal function tests for equality of two values.
175
176 ``equal`` 関数は2つの値が等しいかどうか比較します。
177
178 .. For example $(equal a, b) expands to false, and $(equal hello world, hello world) expands to true. 
179
180 例えば、 ``$(equal a, b)`` は ``false`` が返され、 ``$(equal hello world, hello world)`` は ``true`` が返されます。
181
182 .. index::
183    single: and()
184 .. _label9.2.3:
185
186 9.2.3 and
187 ^^^^^^^^^^^^^^^^^^^^^^^^^
188 ::
189
190     $(and e1, ..., en) : String
191        e1, ..., en: Sequence
192
193 .. The and function evaluates to the conjunction of its arguments.
194
195 ``and`` 関数は引数の論理積を評価します。
196
197 .. For example, in the following code, X is true, and Y is false.
198
199 例えば、以下のコードでは ``X`` は真で、 ``Y`` は偽となります。 ::
200
201     A = a
202     B = b
203     X = $(and $(equal $(A), a) true $(equal $(B), b))
204     Y = $(and $(equal $(A), a) true $(equal $(A), $(B)))
205
206 .. index::
207    single: or()
208 .. _label9.2.4:
209
210 9.2.4 or
211 ^^^^^^^^^^^^^^^^^^^^^^^^^
212 ::
213
214    $(or e1, ..., en) : String
215       e1, ..., en: String Sequence
216
217 .. The or function evaluates to the disjunction of its arguments.
218
219 ``or`` 関数は引数の選言を評価します。
220
221 .. For example, in the following code, X is true, and Y is false.
222
223 例えば、以下のコードでは ``X`` は真で、 ``Y`` は偽となります。 ::
224
225     A = a
226     B = b
227     X = $(or $(equal $(A), a) false $(equal $(A), $(B)))
228     Y = $(or $(equal $(A), $(B)) $(equal $(A), b))
229
230 .. index::
231    single: if()
232 .. _label9.2.5:
233
234 9.2.5 if
235 ^^^^^^^^^^^^^^^^^^^^^^^^^
236 ::
237
238     $(if e1, e2[, e3]) : value
239        e1 : String
240        e2, e3 : value
241
242 .. The if function represents a conditional based on a Boolean value. For example $(if $(equal a, b), c, d) evaluates to d.
243
244 ``if`` 関数は真偽値を基にした条件分岐を行います。例えば、 ``$(if $(equal a, b), c, d)`` は ``d`` と評価されます。
245
246 .. Conditionals may also be declared with an alternate syntax.
247
248 条件分岐は以下のような文を用いても宣言できます。 ::
249
250    if e1
251       body1
252    elseif e2
253       body2
254    ...
255    else
256       bodyn
257
258 .. If the expression e1 is not false, then the expressions in body1 are evaluated and the result is returned as the value of the conditional. Otherwise, if e1 evaluates to false, the evaluation continues with the e2 expression. If none of the conditional expressions is true, then the expressions in bodyn are evaluated and the result is returned as the value of the conditional.
259
260 もし式 ``e1`` が偽でなかったら、 ``body1`` が評価され、結果は条件分岐の値として返されます。もし ``e1`` が偽であるなら、条件分岐は移り変わり ``e2`` の式が用いられます。もしどの条件式も真でなかった場合、 ``bodyn`` が評価され、結果は条件分岐の値として返されます。
261
262 .. There can be any number of elseif clauses; the else clause is optional.
263
264 ``if`` 文は任意の数の ``elseif`` 文を加えることができます。また、 ``else`` 文はなくても構いません。
265
266 .. Note that each branch of the conditional defines its own scope, so variables defined in the branches are normally not visible outside the conditional. The export command may be used to export the variables defined in a scope. For example, the following expression represents a common idiom for defining the C compiler configuration.
267
268 .. note::
269   各々の条件分岐文はそれぞれのスコープを持っているので、条件文中で定義された変数は通常外から見ることができません。 ``export`` コマンドはスコープ中で定義された変数をエクスポートするために用いられます。たとえば、以下の式はCコンパイラの設定を定義するために良く用いられる方法です。 ::
270
271    if $(equal $(OSTYPE), Win32)
272       CC = cl
273       CFLAGS += /DWIN32
274       export
275    else
276       CC = gcc
277       CFLAGS += -g -O2
278       export
279
280 .. index::
281    single: switch()
282    single: match()
283 .. _label9.2.6:
284
285 9.2.6 switch, match
286 ^^^^^^^^^^^^^^^^^^^^^^^^^
287 .. The switch and match functions perform pattern matching.
288
289 ``switch`` , ``match`` 関数はパターンのマッチングに用いられます。
290
291 ``$(switch <arg>, <pattern_1>, <value_1>, ..., <pattern_n>, <value_n>) $(match <arg>, <pattern_1>, <value_1>, ..., <pattern_n>, <value_n>)``
292
293 .. The number of <pattern>/<value> pairs is arbitrary. They strictly alternate; the total number of arguments to <match> must be odd.
294
295 ``<pattern>/<value>`` の数は任意です。ただし、引数の数は必ず奇数でなければなりません。
296
297 .. The <arg> is evaluated to a string, and compared with <pattern_1>. If it matches, the result of the expression is <value_1>. Otherwise evaluation continues with the remaining patterns until a match is found. If no pattern matches, the value is the empty string.
298
299 ``<arg>`` は文字列として評価され、 ``<pattern_1>`` を用いて比較されます。もしマッチしている場合、結果の式は ``<value_1>`` が返されます。そうでない場合、マッチする文が見つかるまで、残りのパターンを用いて評価が行われます。
300
301 .. The switch function uses string comparison to compare the argument with the patterns. For example, the following expression defines the FILE variable to be either foo, bar, or the empty string, depending on the value of the OSTYPE variable.
302
303 ``switch`` 関数はパターンと引数を比較するために用いられます。例えば、以下の表現式では、 ``FILE`` 変数は ``OSTYPE`` 変数の値に依存して、 ``foo`` , ``bar`` , あるいは空の文字列が定義されます。 ::
304
305     FILE = $(switch $(OSTYPE), Win32, foo, Unix, bar)
306
307 .. The match function uses regular expression patterns (see the grep function). If a match is found, the variables $1, $2, ... are bound to the substrings matched between \( and \) delimiters. The $0 variable contains the entire match, and $* is an array of the matched substrings. to the matched substrings.
308
309 ``match`` 関数は正規表現を用います( ":ref:`label10.11.1`" を参照してください)。もしマッチしているパターンが見つかった場合、変数 ``$1, $2, ...`` は ``\(`` と ``\)`` デリミタの間にある文字列が束縛されます。 ``\0`` 変数は全体のマッチ文が定義されており、 ``$*`` はマッチした文字列の配列が定義されます。 ::
310
311     FILE = $(match foo_xyz/bar.a, foo_\\\(.*\\\)/\\\(.*\\\)\.a, foo_$2/$1.o)
312
313 .. The switch and match functions also have an alternate (more usable) form.
314
315 ``switch`` と ``match`` 関数は代わりに(もっと便利な)以下のような形に書くことができます。 ::
316
317    match e
318    case pattern1
319       body1
320    case pattern2
321       body2
322    ...
323    default
324       bodyd
325
326 .. If the value of expression e matches pattern_i and no previous pattern, then body_i is evaluated and returned as the result of the match. The switch function uses string comparison; the match function uses regular expression matching.
327
328 式 ``e`` が前回のパターンでマッチせずに ``pattern_i`` でマッチした場合、 ``body_i`` が評価され、 ``match`` の結果として返されます。 ``switch`` 関数は文字列の比較を行います。 ``match`` 関数は正規表現でのマッチングを行います。 ::
329
330    match $(FILE)
331    case $".*\(\.[^\/.]*\)"
332       println(The string $(FILE) has suffix $1)
333    default
334       println(The string $(FILE) has no suffix)
335
336 .. index::
337    single: try
338 .. _label9.2.7:
339
340 9.2.7 try
341 ^^^^^^^^^^^^^^^^^^^^^^^^^
342 ::
343
344    try
345       try-body
346    catch class1(v1)
347       catch-body
348    when expr
349       when-body
350    ...
351    finally
352       finally-body
353
354 .. The try form is used for exception handling. First, the expressions in the try-body are evaluated.
355
356 ``try`` 文は例外を扱うために用いられます。はじめに、 ``try-body`` の式が評価されます。
357
358 .. If evaluation results in a value v without raising an exception, then the expressions in the finally-body are evaluated and the value v is returned as the result.
359
360 値 ``v`` が例外を出さなかった場合、 ``finally-body`` の式が評価され値 ``v`` が結果として返されます。
361
362 .. If evaluation of the try-body results in a exception object obj, the catch clauses are examined in order. When examining catch clause catch class(v), if the exception object obj is an instance of the class name class, the variable v is bound to the exception object, and the expressions in the catch-body are evaluated.
363
364 ``try-body`` の評価がオブジェクト ``obj`` の例外を送出した場合、 ``catch`` 文が代わりに評価されます。 ``catch`` 文の ``catch class(v)`` を実行している最中、もし例外のオブジェクト ``obj`` がクラス名 ``class`` のインスタンスであったならば、変数 ``v`` が例外のオブジェクトとして束縛され、 ``catch-body`` の式が評価されます。
365
366 .. If a when clause is encountered while a catch body is being evaluated, the predicate expr is evaluated. If the result is true, evaluation continues with the expressions in the when-body. Otherwise, the next catch clause is considered for evaluation.
367
368 ``catch`` 文が評価されている間中 ``when`` 文に遭遇した場合、評価式 ``expr`` が評価されます。もし結果が真であったならば、 ``when-body`` の式が続けて評価されます。さもなければ、次の ``catch`` 文が評価されます。
369
370 .. If evaluation of a catch-body or when-body completes successfully, returning a value v, without encountering another when clause, then the expressions in the finally-body are evaluated and the value v is returned as the result.
371
372 ``catch-body`` か ``when-body`` の評価が完全に終わった場合、別の ``when`` 文を評価することなく ``finally-body`` の式が評価され、値 ``v`` が返されます。
373
374 .. There can be any number of catch clauses; the finally clause is optional. 
375
376 ``try`` 文には任意の数の ``catch`` 文を含めることができます。また、 ``finally`` 文はなくても構いません。
377
378 .. index::
379    single: raise()
380 .. _label9.2.8:
381
382 9.2.8 raise
383 ^^^^^^^^^^^^^^^^^^^^^^^^^
384 .. The raise function raises an exception. The exn object can be any object. However, the normal convention is to raise an Exception object.
385
386 ``raise`` 関数は例外を送出します。 ``exn`` は任意のオブジェクトです。しかしながら、通常は ``Exception`` オブジェクトを送出します。
387
388 .. If the exception is never caught, the whole object will be verbosely printed in the error message. However, if the object is an Exception one and contains a message field, only that field will be included in the error message. 
389
390 例外が捕らえられなかった場合、全体のオブジェクトはエラーメッセージとして詳細に出力されます。しかしながら、もしオブジェクトが ``Exception`` で ``message`` プロパティを含んでいるのなら、エラーメッセージは ``message`` のみが出力されます。
391
392 .. index::
393    single: exit()
394 .. _label9.2.9:
395
396 9.2.9 exit
397 ^^^^^^^^^^^^^^^^^^^^^^^^^
398 ::
399
400    exit(code)
401       code : Int
402
403 .. The exit function terminates omake abnormally.
404
405 ``exit`` 関数はomakeを異常終了させます。
406
407 ``$(exit <code>)``
408
409 .. The exit function takes one integer argument, which is exit code. Non-zero values indicate abnormal termination. 
410
411 ``exit`` 関数は終了コードである整数を引数に指定します。0でない値は異常終了を表します。
412
413 .. index::
414    single: defined()
415 .. _label9.2.10:
416
417 9.2.10 defined
418 ^^^^^^^^^^^^^^^^^^^^^^^^^
419 ::
420
421    $(defined sequence) : String
422       sequence : Sequence
423
424 .. The defined function test whether all the variables in the sequence are currently defined. For example, the following code defines the X variable if it is not already defined.
425
426 ``defined`` 関数はシーケンス中のすべての変数が現在定義されているか試します。例えば、以下のコードでは変数 ``X`` が既に定義されていないかどうかを定義しています。 ::
427
428     if $(not $(defined X))
429        X = a b c
430        export
431
432 .. It is acceptable to use qualified names.
433
434 これは修飾された変数にも用いることができます。 ::
435
436     $(defined X.a.b)
437     $(defined public.X)
438
439 .. index::
440    single: defined-env()
441 .. _label9.2.11:
442
443 9.2.11 defined-env
444 ^^^^^^^^^^^^^^^^^^^^^^^^^
445 ::
446
447    $(defined-env sequence) : String
448       sequence : String
449
450 .. The defined-env function tests whether a variable is defined as part of the process environment.
451
452 ``defined-env`` 関数は処理している環境で、指定された変数が定義されているかどうか試します。
453
454 .. For example, the following code adds the -g compile option if the environment variable DEBUG is defined.
455
456 例えば、以下のコードでは、環境変数 ``DEBUG`` が定義されている場合は ``-g`` コンパイルオプションを追加します。 ::
457
458   if $(defined-env DEBUG)
459       CFLAGS += -g
460       export
461
462 .. index::
463    single: getenv()
464 .. _label9.2.12:
465
466 9.2.12 getenv
467 ^^^^^^^^^^^^^^^^^^^^^^^^^
468 ::
469
470    $(getenv name) : String
471    $(getenv name, default) : String
472
473 .. The getenv function gets the value of a variable from the process environment. The function takes one or two arguments.
474
475 ``getenv`` 関数は現在処理している環境での変数の値を取得します。この関数は一つか二つの引数を指定する必要があります。
476
477 .. In the single argument form, an exception is raised if the variable variable is not defined in the environment. In the two-argument form, the second argument is returned as the result if the value is not defined.
478
479 一つの引数を指定した場合、もし環境中で変数が定義されていなかったならば例外を送出します。二つの引数を指定した場合、もし定義されていなかったならば二番目の引数が返されます。
480
481 .. For example, the following code defines the variable X to be a space-separated list of elements of the PATH environment variable if it is defined, and to /bin /usr/bin otherwise.
482
483 例えば、以下のコードでは、もし環境変数 ``PATH`` が定義されていた場合は、その値を空白で分割したリストとして ``X`` を定義します。さもなければ ``/bin /usr/bin`` が代わりに使われます。 ::
484
485     X = $(split $(PATHSEP), $(getenv PATH, /bin:/usr/bin))
486
487 .. You may also use the alternate form. 
488
489 以下のような形でも定義することができます。 ::
490
491      getenv(NAME)
492          default
493
494 .. index::
495    single: setenv()
496 .. _label9.2.13:
497
498 9.2.13 setenv
499 ^^^^^^^^^^^^^^^^^^^^^^^^^
500 ::
501
502    setenv(name, value)
503       name : String
504       value : String
505
506 .. The setenv function sets the value of a variable in the process environment. Environment variables are scoped like normal variables.
507
508 ``setenv`` 関数は現在処理している環境での変数を定義します。環境変数は通常の変数のようにスコープされます。
509
510 .. index::
511    single: unsetenv()
512 .. _label9.2.14:
513
514 9.2.14 unsetenv
515 ^^^^^^^^^^^^^^^^^^^^^^^^^
516 ::
517
518    unsetenv(names)
519       names : String Array
520
521 .. The unsetenv function removes some variable definitions from the process environment. Environment variables are scoped like normal variables.
522
523 ``unsetenv`` 関数は現在処理している環境からいくつかの変数を削除します。環境変数は通常の変数のようにスコープされます。
524
525 .. index::
526    single: get-registry()
527 .. _label9.2.15:
528
529 9.2.15 get-registry
530 ^^^^^^^^^^^^^^^^^^^^^^^^^
531 ::
532
533    get-registry(hkey, key, field) : String
534    get-registry(hkey, key, field, default) : String
535        hkey : String
536        key : String
537        field : String
538
539 .. The get-registry function retrieves a string value from the system registry on Win32. On other architectures, there is no registry.
540
541 ``get-registry`` 関数はWin32上のシステムレジストリから文字列を取得します。他のアーキテクチャ上では、レジストリの値は返されません。
542
543 .. The hive (I think that is the right word), indicates which part of the registry to use. It should be one of the following values.
544
545 ``hive`` (私はこの呼び方が正しいと思っています)では、使用するレジストリの区分を指定します。これは以下の値である必要があります。(訳注: よく意味がわかりませんがhkeyとfiveをもじったもの?)
546
547 * HKEY_CLASSES_ROOT 
548 * HKEY_CURRENT_CONFIG 
549 * HKEY_CURRENT_USER 
550 * HKEY_LOCAL_MACHINE 
551 * HKEY_USERS 
552
553 .. Refer to the Microsoft documentation if you want to know what these mean.
554
555 もしこれらの意味について知りたい場合はマイクロソフトのドキュメントを参照してください。
556
557 .. The key is the field you want to get from the registry. It should have a form like A\B\C (if you use forward slashes, they will be converted to backslashes). The field is the sub-field of the key.
558
559 ``key`` はレジストリから取得したいフィールドを指定します。これは ``A\B\C`` のような形である必要があります(通常のスラッシュを用いた場合はバックスラッシュに変換されます)。 ``field`` は ``key`` のサブフィールドを指定します。
560
561 .. In the 4-argument form, the default is returned on failure. You may also use the alternate form.
562
563 4つの引数を取る場合、 ``default`` の値が失敗したときに返されます。あなたはこれを別の形で用いることもできます。 ::
564
565     get-registry(hkey, key, field)
566        default
567
568 .. index::
569    single: getvar()
570 .. _label9.2.16:
571
572 9.2.16 getvar
573 ^^^^^^^^^^^^^^^^^^^^^^^^^
574 ::
575
576    $(getvar name) : String
577
578 .. The getvar function gets the value of a variable.
579
580 ``getvar`` 関数は変数の値を取得します。
581
582 .. An exception is raised if the variable variable is not defined.
583
584 変数が定義されていない場合は例外が送出されます。
585
586 .. For example, the following code defines X to be the string abc.
587
588 例えば、以下のコードでは ``X`` を文字列 ``abc`` で定義します。 ::
589
590     NAME = foo
591     foo_1 = abc
592     X = $(getvar $(NAME)_1)
593
594 .. It is acceptable to use qualified names.
595
596 これは修飾された変数にも使うことができます。 ::
597
598     $(getvar X.a.b)
599
600 .. index::
601    single: setvar()
602 .. _label9.2.17:
603
604 9.2.17 setvar
605 ^^^^^^^^^^^^^^^^^^^^^^^^^
606 ::
607
608    setvar(name, value)
609       name : String
610       value : String
611
612 .. The setvar function defines a new variable. For example, the following code defines the variable X to be the string abc.
613
614 ``setvar`` 関数は新しい変数を定義します。例えば、以下のコードでは ``X`` は文字列 ``abc`` で定義されます。 ::
615
616    NAME = X
617    setvar($(NAME), abc)
618
619 .. It is acceptable to use qualified names.
620
621 これは修飾された変数にも使うことができます。 ::
622
623     setvar(public.X, abc)
624
625 9.3 配列とシーケンス
626 ----------------------------------
627
628 .. index::
629    single: array()
630 .. _label9.3.1:
631
632 9.3.1 array
633 ^^^^^^^^^^^^^^^^^^^^^^^^^
634 ::
635
636     $(array elements) : Array
637        elements : Sequence
638
639 .. The array function creates an array from a sequence. If the <arg> is a string, the elements of the array are the whitespace-separated elements of the string, respecting quotes.
640
641 ``array`` 関数はシーケンスから配列を生成します。もし ``<arg>`` が文字列だった場合、配列の成分はホワイトスペースによって区切られた文字列となります。また、クオートによっても区切られます。
642
643 .. In addition, array variables can be declared as follows.
644
645 加えて、配列の変数は以下のように宣言することもできます。 ::
646
647     A[] =
648        <val1>
649        ...
650        <valn>
651
652 .. In this case, the elements of the array are exactly <val1>, ..., <valn>, and whitespace is preserved literally.
653
654 この場合、配列の成分は ``<val1>`` , ... , ``<valn>`` であり、ホワイトスペースは文字通りに取り扱われます。
655
656 .. index::
657    single: split()
658 .. _label9.3.2:
659
660 9.3.2 split
661 ^^^^^^^^^^^^^^^^^^^^^^^^^
662 ::
663
664    $(split sep, elements) : Array
665       sep : String
666       elements : Sequence
667
668 .. The split function takes two arguments, a string of separators, and a string argument. The result is an array of elements determined by splitting the elements by all occurrence of the separator in the elements sequence.
669
670 ``split`` 関数は二つの引数を必要とし、一つめには文字列のデリミタ、二つめには区切りたい文字列を指定します。結果は ``elements`` シーケンスをセパレータによって区切った配列が返されます。
671
672 .. For example, in the following code, the X variable is defined to be the array /bin /usr/bin /usr/local/bin.
673
674 例えば、以下のコードでは、変数 ``X`` は配列 ``/bin /usr/bin /usr/local/bin`` に定義されます。 ::
675
676     PATH = /bin:/usr/bin:/usr/local/bin
677     X = $(split :, $(PATH))
678
679 .. The sep argument may be omitted. In this case split breaks its arguments along the white space. Quotations are not split. 
680
681 ``sep`` は除外することもできます。この場合 ``split`` はホワイトスペースで区切ります。クオーテーションは区切りません。
682
683 .. index::
684    single: concat()
685 .. _label9.3.3:
686
687 9.3.3 concat
688 ^^^^^^^^^^^^^^^^^^^^^^^^^
689 ::
690
691    $(concat sep, elements) : String
692       sep : String
693       elements : Sequence
694
695 .. The concat function takes two arguments, a separator string, and a sequence of elements. The result is a string formed by concatenating the elements, placing the separator between adjacent elements.
696
697 ``concat`` 関数は二つの引数を必要とし、一つめには文字列のセパレータ、二つめにはシーケンスを指定します。結果は隣接した成分の間にセパレータを配置した、結合された文字列が返されます。
698
699 .. For example, in the following code, the X variable is defined to be the string foo_x_bar_x_baz.
700
701 例えば、以下のコードでは、変数 ``X`` は文字列 ``foo_x_bar_x_baz`` に定義されます。 ::
702
703     X = foo  bar     baz
704     Y = $(concat _x_, $(X))
705
706 .. index::
707    single: length()
708 .. _label9.3.4:
709
710 9.3.4 length
711 ^^^^^^^^^^^^^^^^^^^^^^^^^
712 ::
713
714    $(length sequence) : Int
715       sequence : Sequence
716
717 .. The length function returns the number of elements in its argument.
718
719 ``length`` 関数は引数の成分の数を返します。
720
721 .. For example, the expression $(length a b "c d") evaluates to 3. 
722
723 例えば、式 ``$(length a b "c d")`` は3と評価されます。
724
725 .. index::
726    single: nth()
727 .. _label9.3.5:
728
729 9.3.5 nth
730 ^^^^^^^^^^^^^^^^^^^^^^^^^
731 ::
732
733    $(nth i, sequence) : value
734       i : Int
735       sequence : Sequence
736    raises RuntimeException
737
738 .. The nth function returns the nth element of its argument, treated as a list. Counting starts at 0. An exception is raised if the index is not in bounds.
739
740 ``nth`` 関数は引数のi番目の成分を返します。配列のインデックスは0から始まります。もしインデックスが存在しない成分を指定していた場合、例外が送出されます。
741
742 .. For example, the expression $(nth 1, a "b c" d) evaluates to "b c".
743
744 例えば、式 ``$(nth 1, a "b c" d)`` は ``"b c"`` と評価されます。
745
746 .. index::
747    single: replace-nth()
748 .. _label9.3.6:
749
750 9.3.6 replace-nth
751 ^^^^^^^^^^^^^^^^^^^^^^^^^
752 ::
753
754    $(replace-nth i, sequence, x) : value
755       i : Int
756       sequence : Sequence
757       x : value
758    raises RuntimeException
759
760 .. The replace-nth function replaces the nth element of its argument with a new value x. Counting starts at 0. An exception is raised if the index is not in bounds.
761
762 ``replace-nth`` 関数はi番目の成分を新しい値 ``x`` に置き換えます。インデックスは0から始まります。もしインデックスが存在しない成分を指定していた場合、例外が送出されます。
763
764 .. For example, the expression $(replace-nth 1, a "b c" d, x) evaluates to a x d.
765
766 例えば、式 ``$(replace-nth 1, a "b c" d, x)`` は ``a x d`` と評価されます。
767
768 .. index::
769    single: nth-hd()
770 .. _label9.3.7:
771
772 9.3.7 nth-hd
773 ^^^^^^^^^^^^^^^^^^^^^^^^^
774 ::
775
776    $(nth-hd i, sequence) : value
777       i : Int
778       sequence : Sequence
779    raises RuntimeException
780
781 .. The nth-hd function returns the first i elements of the sequence. An exception is raised if the sequence is not at least i elements long.
782
783 ``nth-hd`` 関数は最初から ``i`` 個までの成分をもった配列を返します。もしシーケンスが ``i`` 個より少ない場合は例外が送出されます。
784
785 .. For example, the expression $(nth-hd 2, a "b c" d) evaluates to a "b c".
786
787 例えば、式 ``$(nth-hd 2, a "b c" d)`` は ``a "b c"`` と評価されます。
788
789 .. index::
790    single: nth-tl()
791 .. _label9.3.8:
792
793 9.3.8 nth-tl
794 ^^^^^^^^^^^^^^^^^^^^^^^^^
795 ::
796
797    $(nth-tl i, sequence) : value
798       i : Int
799       sequence : Sequence
800    raises RuntimeException
801
802 .. The nth-tl function skips i elements of the sequence and returns the rest. An exception is raised if the sequence is not at least i elements long.
803
804 ``nth-tl`` 関数は最初から ``i`` 個までの成分を除いた、残りの配列を返します。もしシーケンスが ``i`` 個より少ない場合には例外が送出されます。
805
806 .. For example, the expression $(nth-tl 1, a "b c" d) evaluates to "b c" d.
807
808 例えば、式 ``$(nth-tl 1, a "b c" d)`` は ``"b c" d`` と評価されます。
809
810 .. index::
811    single: subrange()
812 .. _label9.3.9:
813
814 9.3.9 subrange
815 ^^^^^^^^^^^^^^^^^^^^^^^^^
816 ::
817
818    $(subrange off, len, sequent) : value
819       off : Int
820       len : Int
821       sequence : Sequence
822    raises RuntimeException
823
824 .. The subrange function returns a subrange of the sequence. Counting starts at 0. An exception is raised if the specified range is not in bounds.
825
826 ``subrange`` 関数はシーケンスの一部分を返します。インデックスは0から始まります。もし指定された範囲に成分が存在しない場合には例外が送出されます。
827
828 .. For example, the expression $(subrange 1, 2, a "b c" d e) evaluates to "b c" d. 
829
830 例えば、式 ``$(subrange 1, 2, a "b c" d e)`` は ``"b c" d`` と評価されます。
831
832 .. index::
833    single: rev()
834 .. _label9.3.10:
835
836 9.3.10 rev
837 ^^^^^^^^^^^^^^^^^^^^^^^^^
838 ::
839
840     $(rev sequence) : Sequence
841        sequence : Sequence
842
843 .. The rev function returns the elements of a sequence in reverse order. For example, the expression $(rev a "b c" d) evaluates to d "b c" a. 
844
845 ``rev`` 関数は指定された配列の順番を逆にした配列を返します。例えば、式 ``$(rev a "b c" d)`` は ``d "b c" a`` と評価されます。
846
847 .. index::
848    single: join()
849 .. _label9.3.11:
850
851 9.3.11 join
852 ^^^^^^^^^^^^^^^^^^^^^^^^^
853 ::
854
855    $(join sequence1, sequence2) : Sequence
856       sequence1 : Sequence
857       sequence2 : Sequence
858
859 .. The join function joins together the elements of the two sequences. For example, $(join a b c, .c .cpp .h) evaluates to a.c b.cpp c.h. If the two input sequences have different lengths, the remainder of the longer sequence is copied at the end of the output unmodified. 
860
861 ``join`` 関数は二つのシーケンスの成分を互いに結合させます。例えば、 ``$(join a b c, .c .cpp .h)`` は ``a.c b.cpp c.h`` と評価されます。もし二つの入力シーケンスが異なる長さであった場合は、長いシーケンスの残りの成分は、出力先の配列の終わりに修正されない状態でコピーされます。
862
863 .. index::
864    single: string()
865 .. _label9.3.12:
866
867 9.3.12 string
868 ^^^^^^^^^^^^^^^^^^^^^^^^^
869 ::
870
871    $(string sequence) : String
872       sequence : Sequence
873
874 .. The string function flattens a sequence into a single string. This is similar to the concat function, but the elements are separated by whitespace. The result is treated as a unit; whitespace is significant. 
875
876 ``string`` 関数はシーケンスを一つの文字列にまとめます。これは ``concat`` 関数と似ていますが、この成分はホワイトスペースによって分割されています。結果は一つのユニットとして扱われます。ホワイトスペースは重要です。
877
878 .. index::
879    single: string-length()
880 .. _label9.3.13:
881
882 9.3.13 string-length
883 ^^^^^^^^^^^^^^^^^^^^^^^^^
884 ::
885
886    $(string-length sequence) : Int
887       sequence : Sequence
888
889 .. The string-lenght returns a length (number of characters) in its argument. If the argument is a sequence, it flattens it, so $(string-length sequence) is equivalent to $(string-length $(string sequence)).
890
891 ``string-length`` 関数は引数の文字列の長さを返します。もし引数がシーケンスであった場合、まとめられた状態で評価されます。よって、 ``$(string-length sequence)`` は ``$(string-length $(string sequence))`` と等価です。
892
893 .. index::
894    single: string-escaped()
895    single: ocaml-escaped()
896    single: html-escaped()
897    single: html-pre-escaped()
898    single: c-escaped()
899    single: id-escaped()
900 .. _label9.3.14:
901
902 9.3.14 string-escaped, ocaml-escaped, html-escaped, html-pre-escaped, c-escaped, id-escaped
903 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
904 ::
905
906    $(string-escaped sequence) : String Array
907    $(ocaml-escaped sequence) : String Array
908    $(html-escaped sequence) : String Array
909    $(html-pre-escaped sequence) : String Array
910    $(c-escaped sequence) : String Array
911    $(hex-escaped sequence) : StringArray
912       sequence : Array
913
914 .. The string-escaped function converts each element of its argument to a string, escaping it, if it contains symbols that are special to OMake. The special characters include :()\,$'"# and whitespace. This function can be used in scanner rules to escape file names before printing then to stdout.
915
916 .. The ocaml-escaped function converts each element of its argument to a string, escaping characters that are special to OCaml.
917
918 ``string-escaped`` 関数は引数の各々の成分を文字列に変換し、もしその成分がOMakeの特殊文字を含んでいた場合は、その文字をエスケープした状態で返します。特殊文字は ``:()\,$'"#`` とホワイトスペースを含みます。この関数はスキャナルール中で、 ``stdout`` に出力する前にファイル名をエスケープするために使われます。
919
920 .. The c-escaped function converts a string to a form that can be used as a string constant in C.
921
922 ``ocaml-escaped`` 関数はOCamlの特殊文字をエスケープした状態で返します。
923
924 .. The id-escaped function turns a string into an identifier that may be used in OMake.
925
926 ``c-escaped`` 関数はCの文字定数に使われるような形の文字列に変換します。
927
928 .. The id-escaped function turns a string into an identifier that may be used in OMake.
929
930 ``id-escaped`` 関数はOMakeで使われるような識別子に変換します。
931
932 .. The html-escaped function turns a literal string into a form acceptable as HTML. The html-pre-escaped function is similar, but it does not translate newlines into <br>.
933
934 ``html-escaped`` 関数はHTMLで文字通りに読み込まれるような形の文字列に変換します。 ``html-pre-escaped`` 関数と似ていますが、この関数では改行は ``<br>`` に変換されません。 ::
935
936     println($(string $(string-escaped $"a b" $"y:z")))
937     a\ b y\:z
938
939 .. index::
940    single: decode-uri()
941    single: encode-uri()
942 .. _label9.3.15:
943
944 9.3.15 decode-uri, encode-uri
945 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
946 ::
947
948     $(decode-uri sequence) : sequence
949         sequence : Sequence
950
951 .. These two functions perform URI encoding, where special characters are represented by hexadecimal characters.
952
953 これら二つの関数はURIのエンコーディングに用いられ、特殊文字を16進数の文字に置き換えます。 ::
954
955     osh> s = $(encode-uri $'a b~c')
956     "a+b%7ec"
957     osh> decode-uri($s)
958     "a b~c"
959
960 .. index::
961    single: quote()
962 .. _label9.3.16:
963
964 9.3.16 quote
965 ^^^^^^^^^^^^^^^^^^^^^^^^^
966 ::
967
968    $(quote sequence) : String
969       sequence : Sequence
970
971 .. The quote function flattens a sequence into a single string and adds quotes around the string. Inner quotation symbols are escaped.
972
973 ``quote`` 関数はシーケンスを一つの文字列にまとめ、さらに文字列にクオートを付与します。内部のクオーテーションはエスケープされます。
974
975 .. For example, the expression $(quote a "b c" d) evaluates to "a \"b c\" d", and $(quote abc) evaluates to "abc". 
976
977 例えば、式 ``$(quote a "b c" d)`` は ``"a \"b c\" d"`` に、 ``$(quote abc)`` は ``"abc"`` に評価されます。
978
979 .. index::
980    single: quote-argv()
981 .. _label9.3.17:
982
983 9.3.17 quote-argv
984 ^^^^^^^^^^^^^^^^^^^^^^^^^
985 ::
986
987    $(quote-argv sequence) : String
988       sequence : Sequence
989
990 .. The quote-argv function flattens a sequence into a single string, and adds quotes around the string. The quotation is formed so that a command-line parse can separate the string back into its components.
991
992 ``quote-argv`` 関数はシーケンスを一つの文字列にまとめ、さらに文字列にクオートを付与します。クオーテーションは変換されるため、コマンドラインのパーサは、正常に文字列をその構成要素へと戻すことができます。
993
994 .. index::
995    single: html-string()
996 .. _label9.3.18:
997
998 9.3.18 html-string
999 ^^^^^^^^^^^^^^^^^^^^^^^^^
1000 ::
1001
1002    $(html-string sequence) : String
1003       sequence : Sequence
1004
1005 .. The html-string function flattens a sequence into a single string, and escaped special HTML characters. This is similar to the concat function, but the elements are separated by whitespace. The result is treated as a unit; whitespace is significant. 
1006
1007 ``html-string`` 関数はシーケンスを一つの文字列にまとめ、さらに特殊なHTML文字にエスケープします。 ``concat`` 関数と似ていますが、この関数はホワイトスペースで分割を行います。結果は一つの文字列として返されます。
1008
1009 .. index::
1010    single: addsuffix()
1011 .. _label9.3.19:
1012
1013 9.3.19 addsuffix
1014 ^^^^^^^^^^^^^^^^^^^^^^^^^
1015 ::
1016
1017    $(addsuffix suffix, sequence) : Array
1018       suffix : String
1019       sequence : Sequence
1020
1021 .. The addsuffix function adds a suffix to each component of sequence. The number of elements in the array is exactly the same as the number of elements in the sequence.
1022
1023 ``addsuffix`` 関数はシーケンスの各々の成分に接尾辞を付与します。返される配列の長さは、指定されたシーケンスの配列の長さと全く同じです。
1024
1025 .. For example, $(addsuffix .c, a b "c d") evaluates to a.c b.c "c d".c. 
1026
1027 例えば、 ``$(addsuffix .c, a b "c d")`` は ``a.c b.c "c d".c`` と評価されます。
1028
1029 .. index::
1030    single: mapsuffix()
1031 .. _label9.3.20:
1032
1033 9.3.20 mapsuffix
1034 ^^^^^^^^^^^^^^^^^^^^^^^^^
1035 ::
1036
1037    $(mapsuffix suffix, sequence) : Array
1038       suffix : value
1039       sequence : Sequence
1040
1041 .. The mapsuffix function adds a suffix to each component of sequence. It is similar to addsuffix, but uses array concatenation instead of string concatenation. The number of elements in the array is twice the number of elements in the sequence.
1042
1043 ``mapsuffix`` 関数はシーケンスの各々の成分に接尾辞を付与します。これは ``addsuffix`` 関数と似ていますが、この関数は文字列をくっ付ける代わりに新しく成分を追加します。よって、返される配列の長さは、指定されたシーケンスの配列の長さの2倍です。
1044
1045 .. For example, $(mapsuffix .c, a b "c d") evaluates to a .c b .c "c d" .c. 
1046
1047 例えば、 ``$(mapsuffix .c, a b "c d")`` は ``a .c b .c "c d" .c`` と評価されます。
1048
1049 .. index::
1050    single: addsuffixes()
1051 .. _label9.3.21:
1052
1053 9.3.21 addsuffixes
1054 ^^^^^^^^^^^^^^^^^^^^^^^^^
1055 ::
1056
1057    $(addsuffixes suffixes, sequence) : Array
1058       suffixes : Sequence
1059       sequence : Sequence
1060
1061 .. The addsuffixes function adds all suffixes in its first argument to each component of a sequence. If suffixes has n elements, and sequence has m elements, the the result has n * m elements.
1062
1063 ``addsuffixes`` 関数は最初の引数に指定されたすべての接尾辞をシーケンスの各々の成分に付与します。もし ``suffixes`` が ``n`` 個の成分を、 ``sequence`` が ``m`` 個の成分を持っていた場合、結果は ``n * m`` 個の成分を持ったシーケンスが返されます。
1064
1065 .. For example, the $(addsuffixes .c .o, a b c) expressions evaluates to a.c a.o b.c b.o c.o c.a. 
1066
1067 例えば、 ``$(addsuffixes .c .o, a b c)`` は ``a.c a.o b.c b.o c.c c.o`` と評価されます。
1068
1069 .. index::
1070    single: removeprefix()
1071 .. _label9.3.22:
1072
1073 9.3.22 removeprefix
1074 ^^^^^^^^^^^^^^^^^^^^^^^^^
1075 ::
1076
1077    $(removeprefix prefix, sequence) : Array
1078       prefix : String
1079       sequence : Array
1080
1081 .. The removeprefix function removes a prefix from each component of a sequence. 
1082
1083 ``removeprefix`` 関数はシーケンスの各々の成分から接頭辞を取り除きます。
1084
1085 .. index::
1086    single: removesuffix()
1087 .. _label9.3.23:
1088
1089 9.3.23 removesuffix
1090 ^^^^^^^^^^^^^^^^^^^^^^^^^
1091 ::
1092
1093    $(removesuffix sequence) : Array
1094       sequence : String
1095
1096 .. The removesuffix function removes the suffixes from each component of a sequence.
1097
1098 ``removesuffix`` 関数はシーケンスの各々の成分から接尾辞を取り除きます。
1099
1100 .. For example, $(removesuffix a.c b.foo "c d") expands to a b "c d". 
1101
1102 例えば、 ``$(removesuffix a.c b.foo "c d")`` の結果は ``a b "c d"`` となります。
1103
1104 .. index::
1105    single: replacesuffixes()
1106 .. _label9.3.24:
1107
1108 9.3.24 replacesuffixes
1109 ^^^^^^^^^^^^^^^^^^^^^^^^^
1110 ::
1111
1112    $(replacesuffixes old-suffixes, new-suffixes, sequence) : Array
1113       old-suffixes : Sequence
1114       new-suffixes : Sequence
1115       sequence : Sequence
1116
1117 .. The replacesuffixes function modifies the suffix of each component in sequence. The old-suffixes and new-suffixes sequences should have the same length.
1118
1119 ``replacesuffixes`` 関数はシーケンスの各々の成分の接尾辞を置き換えます。 ``old-suffixes`` と ``new-suffixes`` シーケンスは同じ長さである必要があります。
1120
1121 .. For example, $(replacesuffixes .h .c, .o .o, a.c b.h c.z) expands to a.o b.o c.z. 
1122
1123 例えば、 ``$(replacesuffixes .h .c, .o .o, a.c b.h c.z)`` の結果は ``a.o b.o c.z`` となります。
1124
1125 .. index::
1126    single: addprefix()
1127 .. _label9.3.25:
1128
1129 9.3.25 addprefix
1130 ^^^^^^^^^^^^^^^^^^^^^^^^^
1131 ::
1132
1133    $(addprefix prefix, sequence) : Array
1134       prefix : String
1135       sequence : Sequence
1136
1137 .. The addprefix function adds a prefix to each component of a sequence. The number of element in the result array is exactly the same as the number of elements in the argument sequence.
1138
1139 ``addprefix`` 関数はシーケンスの各々の成分に接頭辞を付与します。返される配列の長さは、指定されたシーケンスの配列の長さと全く同じです。
1140
1141 .. For example, $(addprefix foo/, a b "c d") evaluates to foo/a foo/b foo/"c d". 
1142
1143 例えば、 ``$(addprefix foo/, a b "c d")`` は ``foo/a foo/b foo/"c d"`` と評価されます。
1144
1145 .. index::
1146    single: mapprefix()
1147 .. _label9.3.26:
1148
1149 9.3.26 mapprefix
1150 ^^^^^^^^^^^^^^^^^^^^^^^^^
1151 ::
1152
1153    $(mapprefix prefix, sequence) : Array
1154       prefix : String
1155       sequence : Sequence
1156
1157 .. The mapprefix function adds a prefix to each component of a sequence. It is similar to addprefix, but array concatenation is used instead of string concatenation. The result array contains twice as many elements as the argument sequence.
1158
1159 ``mapprefix`` 関数はシーケンスの各々の成分に接頭辞を付与します。これは ``addprefix`` 関数と似ていますが、この関数は文字列をくっ付ける代わりに新しく成分を追加します。よって、返される配列の長さは、指定されたシーケンスの配列の長さの2倍です。
1160
1161 .. For example, $(mapprefix foo, a b "c d") expands to foo a foo b foo "c d".
1162
1163 例えば、 ``$(mapprefix foo, a b "c d")`` の結果は ``foo a foo b foo "c d"`` となります。
1164
1165 .. index::
1166    single: add-wrapper()
1167 .. _label9.3.27:
1168
1169 9.3.27 add-wrapper
1170 ^^^^^^^^^^^^^^^^^^^^^^^^^
1171 ::
1172
1173    $(add-wrapper prefix, suffix, sequence) : Array
1174       prefix : String
1175       suffix : String
1176       sequence : Sequence
1177
1178 .. The add-wrapper functions adds both a prefix and a suffix to each component of a sequence. For example, the expression $(add-wrapper dir/, .c, a b) evaluates to dir/a.c dir/b.c. String concatenation is used. The array result has the same number of elements as the argument sequence. 
1179
1180 ``add-wrapper`` 関数はシーケンスの各々の成分に接頭辞と接尾辞の両方を付与します。例えば、 ``$(add-wrapper dir/, .c, a b)`` は ``dir/a.c dir/b.c`` と評価されます。文字列は結合されるため、返される配列の長さは、指定されたシーケンスの長さと全く同じです。
1181
1182 .. index::
1183    single: set()
1184 .. _label9.3.28:
1185
1186 9.3.28 set
1187 ^^^^^^^^^^^^^^^^^^^^^^^^^
1188 ::
1189
1190    $(set sequence) : Array
1191       sequence : Sequence
1192
1193 .. The set function sorts a set of string components, eliminating duplicates.
1194
1195 ``set`` 関数は文字列の集合をソートします。さらに、重複した成分を除去します。
1196
1197 .. For example, $(set z y z "m n" w a) expands to "m n" a w y z. 
1198
1199 例えば、 ``$(set z y z "m n" w a)`` の結果は ``"m n" a w y z`` となります。
1200
1201 .. index::
1202    single: mem()
1203 .. _label9.3.29:
1204
1205 9.3.29 mem
1206 ^^^^^^^^^^^^^^^^^^^^^^^^^
1207 ::
1208
1209    $(mem elem, sequence) : Boolean
1210       elem : String
1211       sequence : Sequence
1212
1213 .. The mem function tests for membership in a sequence.
1214
1215 ``mem`` 関数はシーケンス中に指定した成分が含まれているかどうか調べます。
1216
1217 .. For example, $(mem "m n", y z "m n" w a) evaluates to true, while $(mem m n, y z "m n" w a) evaluates to false. 
1218
1219 例えば、 ``$(mem "m n", y z "m n" w a)`` は ``true`` と評価され、一方で ``$(mem m n, y z "m n" w a)`` は ``false`` と評価されます。
1220
1221 .. index::
1222    single: intersection()
1223 .. _label9.3.30:
1224
1225 9.3.30 intersection
1226 ^^^^^^^^^^^^^^^^^^^^^^^^^
1227 ::
1228
1229    $(intersection sequence1, sequence2) : Array
1230       sequence1 : Sequence
1231       sequence2 : Sequence
1232
1233 .. The intersection function takes two arguments, treats them as sets of strings, and computes their intersection. The order of the result is undefined, and it may contain duplicates. Use the set function to sort the result and eliminate duplicates in the result if desired.
1234
1235 ``intersection`` 関数は指定された二つの集合の和をとります。返される配列の長さは不定であり、重複があればそれを含みます。もし結果をソートし、さらに重複を除きたい場合は ``set`` 関数を使ってください。
1236
1237 .. For example, the expression $(intersection c a b a, b a) evaluates to a b a. 
1238
1239 例えば、 ``$(intersection c a b a, b a)`` は ``a b a`` と評価されます。
1240
1241 .. index::
1242    single: intersects()
1243 .. _label9.3.31:
1244
1245 9.3.31 intersects
1246 ^^^^^^^^^^^^^^^^^^^^^^^^^
1247 ::
1248
1249    $(intersects sequence1, sequence2) : Boolean
1250       sequence1 : Sequence
1251       sequence2 : Sequence
1252
1253 .. The intersects function tests whether two sets have a non-empty intersection. This is slightly more efficient than computing the intersection and testing whether it is empty.
1254
1255 ``intersects`` 関数は二つの集合の和が空集合でないかどうか調べます。これは集合の和を計算し、空であるかどうか調べるよりも少しだけ効率的です。
1256
1257 .. For example, the expression $(intersects a b c, d c e) evaluates to true, and $(intersects a b c a, d e f) evaluates to false. 
1258
1259 例えば、 ``$(intersects a b c, d c e)`` は ``true`` と評価され、 ``$(intersects a b c a, d e f)`` は ``false`` と評価されます。
1260
1261 .. index::
1262    single: set-diff()
1263 .. _label9.3.32:
1264
1265 9.3.32 set-diff
1266 ^^^^^^^^^^^^^^^^^^^^^^^^^
1267 ::
1268
1269    $(set-diff sequence1, sequence2) : Array
1270       sequence1 : Sequence
1271       sequence2 : Sequence
1272
1273 .. The set-diff function takes two arguments, treats them as sets of strings, and computes their difference (all the elements of the first set that are not present in the second one). The order of the result is undefined and it may contain duplicates. Use the set function to sort the result and eliminate duplicates in the result if desired.
1274
1275 ``set-diff`` 関数は二つの集合の差異を計算します。結果は ``sequence1`` には含まれるが ``sequence2`` には含まれていない成分からなる配列です。返される配列の長さは不定であり、重複があればそれを含みます。もし結果をソートし、さらに重複を除きたい場合は ``set`` 関数を使ってください。
1276 (訳注: この関数は集合論における ``f(A,B) = A - B`` と等価です。)
1277
1278 .. For example, the expression $(set-diff c a b a e, b a) evaluates to c e. 
1279
1280 例えば、 ``$(set-diff c a b a e, b a)`` は ``c e`` と評価されます。
1281
1282 .. index::
1283    single: filter()
1284 .. _label9.3.33:
1285
1286 9.3.33 filter
1287 ^^^^^^^^^^^^^^^^^^^^^^^^^
1288 ::
1289
1290    $(set-diff sequence1, sequence2) : Array
1291       sequence1 : Sequence
1292       sequence2 : Sequence
1293
1294 .. The filter function picks elements from a sequence. The patterns is a non-empty sequence of patterns, each may contain one occurrence of the wildcard % character.
1295
1296 ``filter`` 関数はシーケンスから特定の成分を抜き出します。 ``patterns`` にはパターンを定義した、空でないシーケンスを指定します。また、パターンにはワイルドカード ``%`` を含めることができます。
1297
1298 .. For example $(filter %.h %.o, a.c x.o b.h y.o "hello world".c) evaluates to x.o b.h y.o. 
1299
1300 例えば、 ``$(filter %.h %.o, a.c x.o b.h y.o "hello world".c)`` は ``x.o b.h y.o`` と評価されます。
1301
1302 .. index::
1303    single: filter-out()
1304 .. _label9.3.34:
1305
1306 9.3.34 filter-out
1307 ^^^^^^^^^^^^^^^^^^^^^^^^^
1308 ::
1309
1310    $(filter-out patterns, sequence) : Array
1311       patterns : Sequence
1312       sequence : Sequence
1313
1314 .. The filter-out function removes elements from a sequence. The patterns is a non-empty sequence of patterns, each may contain one occurrence of the wildcard % character.
1315
1316 ``filter-out`` 関数はシーケンスから特定の成分を除去します。 ``patterns`` にはパターンを定義した、空でないシーケンスを指定します。また、パターンにはワイルドカード ``%`` を含めることができます。
1317
1318 .. For example $(filter-out %.c %.h, a.c x.o b.h y.o "hello world".c) evaluates to x.o y.o. 
1319
1320 例えば、 ``$(filter-out %.c %.h, a.c x.o b.h y.o "hello world".c)`` は ``x.o y.o`` と評価されます。
1321
1322 .. index::
1323    single: capitalize()
1324 .. _label9.3.35:
1325
1326 9.3.35 capitalize
1327 ^^^^^^^^^^^^^^^^^^^^^^^^^
1328 ::
1329
1330    $(capitalize sequence) : Array
1331       sequence : Sequence
1332
1333 .. The capitalize function capitalizes each word in a sequence. For example, $(capitalize through the looking Glass) evaluates to Through The Looking Glass. 
1334
1335 ``capitalize`` 関数はシーケンスの各々の成分の単語を大文字化します。例えば、 ``$(capitalize through the looking Glass)`` は ``Through The Looking Glass`` と評価されます。
1336
1337 .. index::
1338    single: uncapitalize()
1339 .. _label9.3.36:
1340
1341 9.3.36 uncapitalize
1342 ^^^^^^^^^^^^^^^^^^^^^^^^^
1343 ::
1344
1345    $(uncapitalize sequence) : Array
1346       sequence : Sequence
1347
1348 .. The uncapitalize function uncapitalizes each word in its argument.
1349
1350 ``uncapitalize`` 関数は引数に指定された各々の単語を小文字化します。
1351
1352 .. For example, $(uncapitalize through the looking Glass) evaluates to through the looking glass. 
1353
1354 例えば、 ``$(uncapitalize through the looking Glass)`` は ``through the looking glass`` と評価されます。
1355
1356 .. index::
1357    single: uppercase()
1358 .. _label9.3.37:
1359
1360 9.3.37 uppercase
1361 ^^^^^^^^^^^^^^^^^^^^^^^^^
1362 ::
1363
1364    $(uppercase sequence) : Array
1365       sequence : Sequence
1366
1367 .. The uppercase function converts each word in a sequence to uppercase. For example, $(uppercase through the looking Glass) evaluates to THROUGH THE LOOKING GLASS. 
1368
1369 ``uppercase`` 関数はシーケンス中の文字すべてを大文字化します。例えば、 ``$(uppercase through the looking Glass)`` は ``THROUGH THE LOOKING GLASS`` と評価されます。
1370
1371 .. index::
1372    single: lowercase()
1373 .. _label9.3.38:
1374
1375 9.3.38 lowercase
1376 ^^^^^^^^^^^^^^^^^^^^^^^^^
1377 ::
1378
1379    $(lowercase sequence) : Array
1380       sequence : Sequence
1381
1382 .. The lowercase function reduces each word in its argument to lowercase.
1383
1384 ``lowercase`` 関数はシーケンス中の文字すべてを小文字化します。
1385
1386 .. For example, $(lowercase through tHe looking Glass) evaluates to through the looking glass. 
1387
1388 例えば、 ``$(lowercase through tHe looking Glass)`` は ``through the looking glass`` と評価されます。
1389
1390 .. index::
1391    single: system()
1392 .. _label9.3.39:
1393
1394 9.3.39 system
1395 ^^^^^^^^^^^^^^^^^^^^^^^^^
1396 ::
1397
1398    system(s)
1399       s : Sequence
1400
1401 .. The system function is used to evaluate a shell expression. This function is used internally by omake to evaluate shell commands.
1402
1403 ``system`` 関数はシェル上のコマンドを評価するために用いられます。シェルコマンドを評価するため、omakeは内部でこの関数を使用しています。
1404
1405 .. For example, the following program is equivalent to the expression system(ls foo).
1406
1407 例えば、以下のプログラムは式 ``system(ls foo)`` と等価です。 ::
1408
1409    ls foo
1410
1411 .. index::
1412    single: shell()
1413 .. _label9.3.40:
1414
1415 9.3.40 shell
1416 ^^^^^^^^^^^^^^^^^^^^^^^^^
1417 ::
1418
1419    $(shell command) : Array
1420    $(shella command) : Array
1421    $(shell-code command) : Int
1422       command : Sequence
1423
1424 .. The shell function evaluates a command using the command shell, and returns the whitespace-separated words of the standard output as the result.
1425
1426 ``shell`` 関数はシェルコマンドを用いてコマンドを評価し、さらに標準出力先に出力された、ホワイトスペースで区切ってある出力結果を返します。
1427
1428 .. The shella function acts similarly, but it returns the lines as separate items in the array.
1429
1430 ``shella`` 関数は同様に振る舞いますが、この関数では改行をそのまま出力するのではなく、分割された配列として返します。
1431
1432 .. The shell-code function returns the exit code. The output is not diverted.
1433
1434 ``shell-code`` は結果として終了コードを返します。出力は返されません。
1435
1436 .. For example, if the current directory contains the files OMakeroot, OMakefile, and hello.c, then $(shell ls) evaluates to hello.c OMakefile OMakeroot (on a Unix system). 
1437
1438 例えば、もしカレントディレクトリがファイル ``OMakeroot`` , ``OMakefile`` , ``hello.c`` を含んでいる場合、 ``$(shell ls)`` はUnixシステム上では ``hello.c OMakefile OMakeroot`` と評価されます。
1439
1440 .. index::
1441    single: export()
1442 .. _label9.3.41:
1443
1444 9.3.41 export
1445 ^^^^^^^^^^^^^^^^^^^^^^^^^
1446 .. The export function allows one to capture the current environment in a variable.
1447
1448 ``export`` 関数は現在の環境中の変数の値を保存します。
1449
1450 .. For example, the following code will print 1 1 2.
1451
1452 例えば、以下のコードは ``1 1 2`` と出力されます。 ::
1453
1454     A = 1
1455     B = 1
1456     C = 1
1457     SAVE_ENV = $(export A B)
1458     A = 2
1459     B = 2
1460     C = 2
1461     export($(SAVE_ENV))
1462     println($A $B $C)
1463
1464 .. The arguments to this function are interpreted the exact same way as the arguments to the export special form (see Section 6.3). 
1465
1466 この関数に引数を指定することは、 ``export`` 文を用いて引数を指定するのと全く等価なものとして解釈されます(詳細は ":ref:`label6.3`" を参照してください)。
1467
1468 .. index::
1469    single: while
1470 .. _label9.3.42:
1471
1472 9.3.42 while
1473 ^^^^^^^^^^^^^^^^^^^^^^^^^
1474 ::
1475
1476    while <test>
1477       <body>
1478
1479 あるいは ::
1480
1481     while <test>
1482     case <test1>
1483        <body1>
1484     ...
1485     case <testn>
1486        <bodyn>
1487     default
1488        <bodyd>
1489
1490 .. The loop is executed while the test is true. In the first form, the <body> is executed on every loop iteration. In the second form, the body <bodyI> is selected, as the first case where the test <testI> is true. If none apply, the optional default case is evaluated. If no cases are true, the loop exits. The environment is automatically exported.
1491
1492 ``<test>`` が真である間はずっとループの式が実行されます。最初の形では、 ``<body>`` はすべてのループにおいて実行されます。二番目の形では、もし ``<testI>`` が真であった場合は ``<bodyI>`` が実行されます。もしなにも当てはまらない場合には ``<bodyd>`` が実行されます。もしすべての場合において真でなかったならば、ループは終了します。なお、ループ中の環境は自動的にエクスポートされます。
1493
1494 .. Examples. Iterate for i from 0 to 9.
1495
1496 例えば、 ``i`` を ``0`` から ``9`` まで繰り返します。 ::
1497
1498     i = 0
1499     while $(lt $i, 10)
1500        echo $i
1501        i = $(add $i, 1)
1502
1503 .. The following example is equivalent.
1504
1505 上の例は以下の例と等価です。 ::
1506
1507    i = 0
1508    while true
1509    case $(lt $i, 10)
1510       echo $i
1511       i = $(add $i, 1)
1512
1513 .. The following example is similar, but some special cases are printed. value is printed.
1514
1515 以下の例は似ていますが、いくつかの特殊な場合においてある文字が出力されます。その他は値が出力されます。 ::
1516
1517     i = 0
1518     while $(lt $i, 10)
1519     case $(equal $i, 0)
1520        echo zero
1521     case $(equal $i, 1)
1522        echo one
1523     default
1524        echo $i
1525
1526 .. The break function can be used to break out of the while loop early.
1527
1528 ``break`` 関数は ``while`` ループを早期に抜けたい場合に用いられます。
1529
1530 .. index::
1531    single: break
1532 .. _label9.3.43:
1533
1534 9.3.43 break
1535 ^^^^^^^^^^^^^^^^^^^^^^^^^
1536 ::
1537
1538    break
1539
1540 .. Terminate execution of the innermost loop, returning the current state. 
1541
1542 最も近いループから抜け出し、現在の状態を返します。
1543
1544 .. index::
1545    single: random()
1546    single: random-init()
1547 .. _label9.3.44:
1548
1549 9.3.44 random, random-init
1550 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1551 ::
1552
1553     random-init(i)
1554         i : Int
1555     random() : Int
1556
1557 .. Produce a random number. The numbers are pseudo-random, and are not cryptographically secure.
1558
1559 乱数を生成します。値は疑似乱数で、暗号として用いられるほどセキュアではありません。
1560
1561 .. The generator is initialized form semi-random system data. Subsequent runs should produce different results. The rando-init function can be used to return the generator to a known state.
1562
1563 乱数生成器はシステムの乱数器を用いて初期化します。よって、次にプログラムを走らせたときの乱数の値は前回と異なります。 ``ramdom-init`` 関数は特定の値を用いて乱数生成器を初期化します。
1564
1565 .. _label9.4:
1566
1567 9.4 演算
1568 ----------------------------------
1569
1570 .. index::
1571    single: int()
1572 .. _label9.4.1:
1573
1574 9.4.1 int
1575 ^^^^^^^^^^^^^^^^^^^^^^^^^
1576 .. The int function can be used to create integers. It returns an Int object.
1577
1578 ``int`` 関数は整数値を作るために用いられ、 ``Int`` オブジェクトを返します。 ::
1579
1580         $(int 17)
1581
1582 .. index::
1583    single: float()
1584 .. _label9.4.2:
1585
1586 9.4.2 float
1587 ^^^^^^^^^^^^^^^^^^^^^^^^^
1588 .. The float function can be used to create floating-point numbers. It returns a Float object.
1589
1590 ``float`` 関数は浮動小数点値を作るために用いられ、 ``Float`` オブジェクトを返します。 ::
1591
1592         $(float 3.1415926)
1593
1594 .. index::
1595    single: neg()
1596    single: add()
1597    single: sub()
1598    single: mul()
1599    single: div()
1600    single: mod()
1601    single: lnot()
1602    single: land()
1603    single: lor()
1604    single: lxor()
1605    single: lsl()
1606    single: lsr()
1607    single: asr()
1608    single: min()
1609    single: max()
1610 .. _label9.4.3:
1611
1612 9.4.3 基本的な演算
1613 ^^^^^^^^^^^^^^^^^^^^^^^^^
1614 .. The following functions can be used to perform basic arithmetic.
1615
1616 以下の関数は基本的な数学の演算を行います。
1617
1618 ..  * $(neg <numbers>): arithmetic inverse
1619     * $(add <numbers>): addition.
1620     * $(sub <numbers>): subtraction.
1621     * $(mul <numbers>): multiplication.
1622     * $(div <numbers>): division.
1623     * $(mod <numbers>): remainder.
1624     * $(lnot <numbers>): bitwise inverse.
1625     * $(land <numbers>): bitwise and.
1626     * $(lor <numbers>): bitwise or.
1627     * $(lxor <numbers>): bitwise exclusive-or.
1628     * $(lsl <numbers>): logical shift left.
1629     * $(lsr <numbers>): logical shift right.
1630     * $(asr <numbers>): arithmetic shift right.
1631     * $(min <numbers>): smallest element.
1632     * $(max <numbers>): largest element. 
1633
1634 * ``$(neg <numbers>)`` : 数学的な反転
1635 * ``$(add <numbers>)`` : 加算
1636 * ``$(sub <numbers>)`` : 減算
1637 * ``$(mul <numbers>)`` : 乗算
1638 * ``$(div <numbers>)`` : 除算
1639 * ``$(mod <numbers>)`` : 余り
1640 * ``$(lnot <numbers>)`` : ビット単位NOT
1641 * ``$(land <numbers>)`` : ビット単位AND
1642 * ``$(lor <numbers>)`` : ビット単位OR
1643 * ``$(lxor <numbers>)`` : ビット単位XOR
1644 * ``$(lsl <numbers>)`` : 論理左シフト
1645 * ``$(lsr <numbers>)`` : 論理右シフト
1646 * ``$(asr <numbers>)`` : 算術右シフト
1647 * ``$(min <numbers>)`` : 最も小さい成分
1648 * ``$(max <numbers>)`` : 最も大きい成分
1649
1650
1651 .. index::
1652    single: lt()
1653    single: le()
1654    single: eq()
1655    single: ge()
1656    single: gt()
1657    single: ult()
1658    single: ule()
1659    single: uge()
1660    single: ugt()
1661 .. _label9.4.4:
1662
1663 9.4.4 評価
1664 ^^^^^^^^^^^^^^^^^^^^^^^^^
1665 .. The following functions can be used to perform numerical comparisons.
1666
1667 以下の関数は数学的な評価を行います。
1668
1669 ..  * $(lt <numbers>): less then.
1670     * $(le <numbers>): no more than.
1671     * $(eq <numbers>): equal.
1672     * $(ge <numbers>): no less than.
1673     * $(gt <numbers>): greater than.
1674     * $(ult <numbers>): unsigned less than.
1675     * $(ule <numbers>): unsigned greater than.
1676     * $(uge <numbers>): unsigned greater than or equal.
1677     * $(ugt <numbers>): unsigned greater than. 
1678
1679 * ``$(lt <numbers>)`` : ~より少ない (A < B)
1680 * ``$(le <numbers>)`` : ~以下 (A <= B)
1681 * ``$(eq <numbers>)`` : 等しい (A == B)
1682 * ``$(ge <numbers>)`` : ~以上 (A >= B)
1683 * ``$(gt <numbers>)`` : ~より多い (A > B)
1684 * ``$(ult <numbers>)`` : ~より少ない(符号なし)
1685 * ``$(ule <numbers>)`` : ~以下(符号なし)
1686 * ``$(uge <numbers>)`` : ~以上(符号なし)
1687 * ``$(ugt <numbers>)`` : ~より多い(符号なし)
1688
1689 (訳注: ここでいう(符号なし)とは符号ビットを考慮しないで評価を行うことを表しています。例えば、int型とunsigned int型では同じビット数に対してそれぞれ表している数値が異なります。(符号なし)の演算子はこのような場合に用いられます。)
1690
1691 .. _label9.5:
1692
1693 9.5 基本的な関数群
1694 ----------------------------------
1695
1696 .. index::
1697    single: fun()
1698 .. _label9.5.1:
1699
1700 9.5.1 fun
1701 ^^^^^^^^^^^^^^^^^^^^^^^^^
1702 .. The fun form introduces anonymous functions.
1703
1704 ``fun`` 関数は匿名関数を生成します。 ::
1705
1706 $(fun <v1>, ..., <vn>, <body>)
1707
1708 .. The last argument is the body of the function. The other arguments are the parameter names.
1709
1710 最後の引数には関数の内容を記述します。他の引数はパラメータ名を指定します。
1711
1712 .. The three following definitions are equivalent.
1713
1714 例えば、以下の3つの関数定義は等価です。 ::
1715
1716     F(X, Y) =
1717        return($(addsuffix $(Y), $(X)))
1718
1719     F = $(fun X, Y, $(addsuffix $(Y), $(X)))
1720
1721     F =
1722        fun(X, Y)
1723           value $(addsuffix $(Y), $(X))
1724
1725 .. index::
1726    single: apply()
1727 .. _label9.5.2:
1728
1729 9.5.2 apply
1730 ^^^^^^^^^^^^^^^^^^^^^^^^^
1731 .. The apply operator is used to apply a function.
1732
1733 ``apply`` 関数は関数に値を適用します。 ::
1734
1735         $(apply <fun>, <args>)
1736
1737 .. Suppose we have the following function definition.
1738
1739 以下の関数定義を行った場合について考えてみましょう。 ::
1740
1741     F(X, Y) =
1742        return($(addsuffix $(Y), $(X)))
1743
1744 .. The the two expressions below are equivalent.
1745
1746 以下の2つの式は等価です。 ::
1747
1748     X = F(a b c, .c)
1749     X = $(apply $(F), a b c, .c)
1750
1751 .. index::
1752    single: applya()
1753 .. _label9.5.3:
1754
1755 9.5.3 applya
1756 ^^^^^^^^^^^^^^^^^^^^^^^^^
1757 .. The applya operator is used to apply a function to an array of arguments.
1758
1759 ``applya`` 関数は引数の配列を関数に適用します。 ::
1760
1761         $(applya <fun>, <args>)
1762
1763 .. For example, in the following program, the value of Z is file.c.
1764
1765 例えば、以下のプログラムでは ``Z`` の値は ``file.c`` となります。 ::
1766
1767     F(X, Y) =
1768        return($(addsuffix $(Y), $(X)))
1769     args[] =
1770        file
1771        .c
1772     Z = $(applya $(F), $(args))
1773
1774 .. index::
1775    single: create-map()
1776    single: create-lazy-map()
1777 .. _label9.5.4:
1778
1779 9.5.4 create-map, create-lazy-map
1780 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1781 .. The create-map is a simplified form for creating Map objects. The create-map function takes an even number of arguments that specify key/value pairs. For example, the following values are equivalent.
1782
1783 ``create-map`` 関数は簡単に ``Map`` オブジェクトを作る関数です。 ``create-map`` 関数はキー/値のペアを引数によって指定するので、引数の数は等しくなければなりません。例えば、以下の2つの式は等価です。 ::
1784
1785     X = $(create-map name1, xxx, name2, yyy)
1786
1787     X. =
1788         extends $(Map)
1789         $|name1| = xxx
1790         $|name2| = yyy
1791
1792 .. The create-lazy-map function is similar, but the values are computed lazily. The following two definitions are equivalent.
1793
1794 ``create-lazy-map`` 関数は ``create-map`` と似ていますが、この関数は値が遅延評価されます。例えば、以下の2つの式は等価です。 ::
1795
1796     Y = $(create-lazy-map name1, $(xxx), name2, $(yyy))
1797
1798     Y. =
1799         extends $(Map)
1800         $|name1| = $`(xxx)
1801         $|name2| = $`(yyy)
1802
1803 .. The create-lazy-map function is used in rule construction. 
1804
1805 ``create-lazy-map`` 関数はルールを生成する際に用いられます。
1806
1807 .. _label9.6:
1808
1809 9.6 イテレーションとマッピング
1810 ----------------------------------
1811
1812 .. index::
1813    single: foreach()
1814 .. _label9.6.1:
1815
1816 9.6.1 foreach
1817 ^^^^^^^^^^^^^^^^^^^^^^^^^
1818 .. The foreach function maps a function over a sequence.
1819
1820 ``foreach`` 関数はシーケンスすべての成分にわたって関数を適用します。 ::
1821
1822     $(foreach <fun>, <args>)
1823
1824     foreach(<var>, <args>)
1825        <body>
1826
1827 .. For example, the following program defines the variable X as an array a.c b.c c.c.
1828
1829 例えば、以下のプログラムでは変数 ``X`` は配列 ``a.c b.c c.c`` と定義されます。 ::
1830
1831     X =
1832        foreach(x, a b c)
1833           value $(x).c
1834
1835     # 等価な式
1836     X = $(foreach $(fun x, $(x).c), abc)
1837
1838 .. There is also an abbreviated syntax.
1839
1840 これらの表現を省略することもできます。
1841
1842 .. The export form can also be used in a foreach body. The final value of X is a.c b.c c.c.
1843
1844 ``export`` 文は ``foreach`` の内容に使うこともできます。例えば、以下の式の ``X`` は最終的に ``a.c b.c c.c`` となります。 ::
1845
1846     X =
1847     foreach(x, a b c)
1848        X += $(x).c
1849        export
1850
1851 .. The break function can be used to break out of the loop early. 
1852
1853 ``break`` 関数はこのようなループを早期に抜けたい場合に用いられます。
1854
1855 .. _label9.7:
1856
1857 9.7 ブーリアン関数群
1858 ----------------------------------
1859
1860 .. index::
1861    single: sequence-forall()
1862 .. _label9.7.1:
1863
1864 9.7.1 sequence-forall
1865 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1866 .. The forall function tests whether a predicate halds for each element of a sequence.
1867
1868 ``forall`` 関数は ``<body>`` がシーケンスのすべての成分に当てはまっているかどうか調べます。 ::
1869
1870     $(sequence-forall <fun>, <args>)
1871
1872     sequence-forall(<var> => ..., <args>)
1873        <body>
1874
1875 .. index::
1876    single: sequence-forall()
1877 .. _label9.7.2:
1878
1879 9.7.2 sequence-exists
1880 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1881 .. The exists function tests whether a predicate holds for some element of a sequence.
1882
1883 ``exists`` 関数は ``<body>`` がシーケンスのいくつかの成分に当てはまっているかどうか調べます。 ::
1884
1885     $(sequence-exists <fun>, <args>)
1886
1887     sequence-exists(<var> => ..., <args>)
1888        <body>
1889
1890 .. index::
1891    single: sequence-sort()
1892 .. _label9.7.3:
1893
1894 9.7.3 sequence-sort
1895 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1896 .. The sort function sorts the elements in an array, given a comparison function. Given two elements (x, y), the comparison should return a negative number if x < y; a positive number if x > y; and 0 if x = y.
1897
1898 ``sort`` 関数は配列の成分を与えられた評価関数を元にソートします。評価関数は二つの引数(x, y)を取ります。もしx < yであった場合、評価関数は負の値を返す必要があります。同様に、x > yの場合は正の値、x = yの場合は0を返します。 ::
1899
1900     $(sequence-sort <fun>, <args>)
1901
1902     sort(<var>, <var> => ..., <args>)
1903        <body>
1904
1905 .. index::
1906    single: compare()
1907 .. _label9.7.4:
1908
1909 9.7.4 compare
1910 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1911 .. The compare function compares two values (x, y) generically returning a negative number if x < y; a positive number if x > y; and 0 if x = y.
1912
1913 ``compare`` 関数は二つの値(x, y)を比較します。もしx < yであった場合、この関数は負の値を返します。同様に、x > yの場合は正の値、x = yの場合は0を返します。 ::
1914
1915     $(compare x, y) : Int