Implement flatten/0 in terms of flatten/1
This commit is contained in:
1 parent
16e8d0b1ab
commit
3d49fc59dd
2 files changed
+12
-4
No files matched your search
+9
-2
@@ -328,9 +328,8 @@ join(",","/")
|
||||
["","","a","aa"]
|
||||
|
||||
# Same check for flatten/1
|
||||
flatten(-1,3,2,1)
|
||||
flatten(3,2,1)
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
[0,[1],[[2]],[[[3]]]]
|
||||
[0,1,2,3]
|
||||
[0,1,2,[3]]
|
||||
[0,1,[2],[[3]]]
|
||||
@@ -1117,6 +1116,10 @@ flatten
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
[0, 1, 2, 3]
|
||||
|
||||
flatten(0)
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
|
||||
flatten(2)
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
[0, 1, 2, [3]]
|
||||
@@ -1125,6 +1128,10 @@ flatten(2)
|
||||
[0, [1, [2]], [1, [[3], 2]]]
|
||||
[0, 1, 2, 1, [3], 2]
|
||||
|
||||
try flatten(-1) catch .
|
||||
[0, [1], [[2]], [[[3]]]]
|
||||
"flatten depth must not be negative"
|
||||
|
||||
transpose
|
||||
[[1], [2,3]]
|
||||
[[1,2],[null,3]]
|
||||
|
||||
Reference in new issue
Block a user