Template repo for tiny cross-platform apps that can be modified on phone, tablet or computer.
at main 69 lines 4.1 kB view raw
1{ 2 {type='rows', default={font={size=21}, line_height=25}, 3 {type='text', font={size=28}, line_height=50, 4 {'Lua@{Lua} > テーブル', 5 attrs={ 6 Lua={target='--lua'}, 7 }}, 8 }, 9 {type='filler', height=15}, 10 {type='text', 'Luaのテーブルは、データを簡単にスライスしたり分割したりできるようにグループ化する多様な方法です。'}, 11 {type='filler', height=15}, 12 {type='text', '{}は空のテーブル値/式です。'}, 13 {type='filler', height=10}, 14 {type='text', 15 {'h = {11, 12, 13}はem@{配列}、数値em@{キー}で検索できるテーブルを作成します。', 16 attrs={ 17 em={font={italic=true}}}}}, 18 {type='text', ' h[1]は11、h[2]は12になります。'}, 19 {type='filler', height=10}, 20 {type='text', 'h = {a=34}は文字列キーで検索できるテーブルを作成します。'}, 21 {type='text', " h['a']は34、h['b']は35になります。"}, 22 {type='text', ' 定数文字列キーはピリオドを使って短縮できます。h.aは34、h.bは35。'}, 23 {type='filler', height=10}, 24 {type='text', 'hが配列の場合、#hはhの長さを返す式です'}, 25 {type='text', ' 文字列キーは配列の長さにカウントされません。'}, 26 {type='text', ' 配列は最初の欠損/nilスロットで停止します。{1, 2, nil, 4}の長さは2です。'}, 27 {type='filler', height=15}, 28 {type='text', 'テーブルを操作する便利な関数:', font_size=28}, 29 {type='filler', height=15}, 30 {type='text', 'pairs(h)', font={size=24}}, 31 {type='text', 32 {' テーブルのすべてのキーを便利にループできるem@{イテレータ}という関数の一種を返します。', 33 attrs={ 34 em={font={italic=true}}}}}, 35 {type='text', ' 例:このプログラムはテーブルの内容を印刷します:for key, value in pairs(h) do print(key, value) end'}, 36 {type='filler', height=15}, 37 {type='text', '配列を操作する便利な関数:', font_size=28}, 38 {type='filler', height=15}, 39 {type='text', 'ipairs(h)', font={size=24}}, 40 {type='text', ' 配列のインデックスと要素を便利にループできるイテレータを返します。'}, 41 {type='text', ' 例:このプログラムは配列の内容を印刷します:for _, x in ipairs(h) do print(x) end'}, 42 {type='filler', height=10}, 43 {type='text', 'table.insert(h, value)', font={size=24}}, 44 {type='text', ' 配列hの最後に値を追加します。'}, 45 {type='filler', height=10}, 46 {type='text', 'table.insert(h, index, value)', font={size=24}}, 47 {type='text', ' 配列hの中間のインデックスに値を挿入します。'}, 48 {type='filler', height=10}, 49 {type='text', 'table.remove(h)', font={size=24}}, 50 {type='text', ' 配列hの最後のインデックスの値を削除します。'}, 51 {type='filler', height=10}, 52 {type='text', 'table.remove(h, index)', font={size=24}}, 53 {type='text', ' 配列hの中間のインデックスの値を削除し、後の値を前に詰めます。'}, 54 {type='filler', height=10}, 55 {type='text', 'table.sort(h)', font={size=24}}, 56 {type='text', ' 配列hの要素をソートします。'}, 57 {type='filler', height=10}, 58 {type='text', 'table.sort(h, f)', font={size=24}}, 59 {type='text', ' カスタム比較関数fによって配列hの要素をソートします。'}, 60 {type='text', ' fは2つの引数を受け取り、最初が2番目より小さい場合trueを返す必要があります。'}, 61 {type='filler', height=10}, 62 {type='text', 'table.reverse(h)', font={size=24}}, 63 {type='text', ' 配列hの要素の順序を反転し、最後の要素が最初になります。'}, 64 {type='filler', height=10}, 65 {type='text', 'table.concat(h)', font={size=24}}, 66 {type='text', ' 配列hのすべての要素を単一の文字列に結合して返します。'}, 67 {type='text', ' すべての要素は文字列である必要があります。'}, 68 } 69}