mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
This commit is contained in:
parent
4c736914d4
commit
2f640fdc68
9 changed files with 29 additions and 3 deletions
|
|
@ -84,6 +84,21 @@ public fun flatten (l) {
|
|||
curr [0] := new
|
||||
}
|
||||
|
||||
iter (fun (x) {iter (append, x)}, l);
|
||||
|
||||
res [1]
|
||||
}
|
||||
|
||||
public fun deepFlatten (l) {
|
||||
local res = [0, {}], curr = [res];
|
||||
|
||||
fun append (x) {
|
||||
local new = x : {};
|
||||
|
||||
curr [0][1] := new;
|
||||
curr [0] := new
|
||||
}
|
||||
|
||||
fun traverse (l) {
|
||||
case l of
|
||||
_ : _ -> iter (traverse, l)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue