lua: unpack treats explicit nil i/j as missing (defaults to 1 and #t)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -1552,23 +1552,25 @@
|
||||
(define
|
||||
lua-unpack
|
||||
(fn (&rest args)
|
||||
(let ((t (first args))
|
||||
(i (if (> (len args) 1) (nth args 1) 1))
|
||||
(j (if (> (len args) 2) (nth args 2) (lua-len (first args)))))
|
||||
(cond
|
||||
((> i j) nil)
|
||||
(else
|
||||
(let ((out (list (quote lua-multi))))
|
||||
(begin
|
||||
(define
|
||||
loop
|
||||
(fn (k)
|
||||
(when (<= k j)
|
||||
(begin
|
||||
(set! out (append out (list (get t (str k)))))
|
||||
(loop (+ k 1))))))
|
||||
(loop i)
|
||||
out)))))))
|
||||
(let ((t (first args)))
|
||||
(let ((i-raw (if (> (len args) 1) (nth args 1) nil))
|
||||
(j-raw (if (> (len args) 2) (nth args 2) nil)))
|
||||
(let ((i (if (= i-raw nil) 1 i-raw))
|
||||
(j (if (= j-raw nil) (lua-len t) j-raw)))
|
||||
(cond
|
||||
((> i j) nil)
|
||||
(else
|
||||
(let ((out (list (quote lua-multi))))
|
||||
(begin
|
||||
(define
|
||||
loop
|
||||
(fn (k)
|
||||
(when (<= k j)
|
||||
(begin
|
||||
(set! out (append out (list (get t (str k)))))
|
||||
(loop (+ k 1))))))
|
||||
(loop i)
|
||||
out)))))))))
|
||||
|
||||
(define
|
||||
lua-table-maxn
|
||||
|
||||
Reference in New Issue
Block a user