erlang: lists zip/2 + zipwith/3 + unzip/1 (841/841)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Zip family in lib/erlang/lists-ext.sx; length mismatch and malformed pairs raise badarg. lists_ext suite 62 -> 70. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -238,3 +238,32 @@
|
||||
|
||||
(er-lx-test "min mixed term order"
|
||||
(er-lx-nm "lists:min([a,1,b]) =:= 1") "true")
|
||||
|
||||
;; ── lists:zip/2 ───────────────────────────────────────────────────
|
||||
(er-lx-test "zip pairs"
|
||||
(er-lx-nm "lists:zip([a,b,c],[1,2,3]) =:= [{a,1},{b,2},{c,3}]") "true")
|
||||
|
||||
(er-lx-test "zip empty"
|
||||
(er-lx-nm "lists:zip([],[]) =:= []") "true")
|
||||
|
||||
(er-lx-test "zip length"
|
||||
(erlang-eval-ast "length(lists:zip([1,2],[3,4]))") 2)
|
||||
|
||||
;; ── lists:zipwith/3 ───────────────────────────────────────────────
|
||||
(er-lx-test "zipwith sum"
|
||||
(er-lx-nm
|
||||
"lists:zipwith(fun(X,Y) -> X+Y end, [1,2,3], [10,20,30]) =:= [11,22,33]")
|
||||
"true")
|
||||
|
||||
(er-lx-test "zipwith tuple"
|
||||
(er-lx-nm "lists:zipwith(fun(X,Y) -> {X,Y} end, [a], [1]) =:= [{a,1}]") "true")
|
||||
|
||||
;; ── lists:unzip/1 ─────────────────────────────────────────────────
|
||||
(er-lx-test "unzip"
|
||||
(er-lx-nm "lists:unzip([{a,1},{b,2},{c,3}]) =:= {[a,b,c],[1,2,3]}") "true")
|
||||
|
||||
(er-lx-test "unzip empty"
|
||||
(er-lx-nm "lists:unzip([]) =:= {[],[]}") "true")
|
||||
|
||||
(er-lx-test "zip/unzip roundtrip"
|
||||
(er-lx-nm "lists:unzip(lists:zip([1,2],[3,4])) =:= {[1,2],[3,4]}") "true")
|
||||
|
||||
Reference in New Issue
Block a user