diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
| commit | f1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch) | |
| tree | 37131187f4218dd3ebec049101c28a161e7ca289 /spec/outputs/comprehension_nested.lua | |
| parent | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'spec/outputs/comprehension_nested.lua')
| -rw-r--r-- | spec/outputs/comprehension_nested.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/outputs/comprehension_nested.lua b/spec/outputs/comprehension_nested.lua new file mode 100644 index 0000000..abd5792 --- /dev/null +++ b/spec/outputs/comprehension_nested.lua | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | local list = { | ||
| 2 | 1, | ||
| 3 | 2, | ||
| 4 | 3 | ||
| 5 | } | ||
| 6 | local pairs | ||
| 7 | do | ||
| 8 | local _accum_0 = { } | ||
| 9 | local _len_0 = 1 | ||
| 10 | for _index_0 = 1, #list do | ||
| 11 | local i = list[_index_0] | ||
| 12 | if i % 2 == 1 then | ||
| 13 | for _index_1 = 1, #list do | ||
| 14 | local j = list[_index_1] | ||
| 15 | if j > i then | ||
| 16 | _accum_0[_len_0] = tostring(i) .. "-" .. tostring(j) | ||
| 17 | _len_0 = _len_0 + 1 | ||
| 18 | end | ||
| 19 | end | ||
| 20 | end | ||
| 21 | end | ||
| 22 | pairs = _accum_0 | ||
| 23 | end | ||
| 24 | return print(table.concat(pairs, ",")) | ||
