{ {type='rows', default={font={size=21}, line_height=25}, {type='text', font={size=28}, line_height=50, {'Lua@{Lua} > 文', attrs={ Lua={target='--lua'}, }}, }, {type='filler', height=15}, {type='text', '文は処理を行います。関数は文を含みます。文の例:'}, {type='filler', height=15}, {type='text', 'x = 5', font={size=24}}, {type='text', ' 変数に値を格納'}, {type='filler', height=10}, {type='text', 'x, y = 3, 4', font={size=24}}, {type='text', ' 複数の変数に一度に値を格納'}, {type='filler', height=10}, {type='text', 'print("hello")', font={size=24}}, {type='text', ' 関数を呼び出し'}, {type='filler', height=10}, {type='text', 'x = add(3, 4)', font={size=24}}, {type='text', ' 関数の結果を変数に格納'}, {type='filler', height=10}, {type='text', 'return 34'}, {type='text', ' 関数から結果を返す'}, {type='filler', height=10}, {type='text', 'return 34, 35'}, {type='text', ' 関数から複数の結果を返す'}, {type='filler', height=10}, {type='text', 'if x == 3 then print("equal") end', font={size=24}}, {type='text', ' 条件が満たされた場合のみ何かを実行'}, {type='text', ' この文は\'then\'と\'end\'の間に他の文を含むことができます。'}, {type='filler', height=10}, {type='text', 'if x == 3 then print("equal") else print("not equal") end', font={size=24}}, {type='text', ' 条件に応じて二つの(文の集合の)どちらかを選択'}, {type='filler', height=10}, {type='text', 'if x == 3 then print("x is 3")', font={size=24}}, {type='text', 'else print("x is not 3") end', font={size=24}}, {type='text', ' 文はどこでも好きな場所で複数行に分割できます。'}, {type='filler', height=10}, {type='text', 'if x == 3 then print("x is 3")', font={size=24}}, {type='text', 'elseif x > 3 then print("x is greater than 3")', font={size=24}}, {type='text', 'else print("x is less than 3") end', font={size=24}}, {type='text', ' 2つ以上の条件を持つより複雑な条件。いくつでも持つことができます。'}, {type='filler', height=10}, {type='text', 'while x == 3 do print("hello") end', font={size=24}}, {type='text', ' 条件が満たされている限り繰り返し何かを実行'}, {type='filler', height=10}, {type='text', 'repeat print("hello") until x == 3', font={size=24}}, {type='text', {' 条件がem@{満たされていない}限り繰り返し何かを実行', attrs={ em={font={italic=true}}}}}, {type='text', {' この種のem@{ループ}は条件に到達する前に必ず最低一回実行されます。', attrs={ em={font={italic=true}}}}}, {type='filler', height=10}, {type='text', 'for i=1,3 do print(i) end', font={size=24}}, {type='text', ' 3回実行し、iを1、2、3にそれぞれ一回ずつ設定'}, {type='text', ' (キーワード\'for\'は数学者から来ており、「1から3までのすべての数について..」のような言い方をします)'}, {type='filler', height=10}, {type='text', 'for i=0,4,2 do print(i) end', font={size=24}}, {type='text', ' 3回実行し、iを0、2、4にそれぞれ一回ずつ設定'}, {type='filler', height=10}, {type='text', 'for i=10,1,-1 do print(i) end', font={size=24}}, {type='text', ' 10回実行し、iを最初に10に設定し、毎回1ずつ減らす'}, {type='filler', height=10}, {type='text', 'break', font={size=24}}, {type='text', ' この文を囲むループの繰り返し実行を停止'}, } }