Flatten a list: Difference between revisions
Content added Content deleted
(Flatten a list in Chipmunk Basic, GW-BASIC and MSX Basic) |
mNo edit summary |
||
Line 4,162: | Line 4,162: | ||
End Sub |
End Sub |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|V (Vlang)}}== |
|||
{{trans|PL/I}} |
|||
<syntaxhighlight lang="Zig"> |
|||
fn main() { |
|||
arr := "[[1], 2, [[3, 4], 5], [[[]]], [[[6]]], 7, 8, []]" |
|||
println(convert(arr)) |
|||
} |
|||
fn convert(arr string) []int { |
|||
mut new_arr := []int{} |
|||
for value in arr.replace_each(["[","","]",""]).split(", ") {if value !="" {new_arr << value.int()}} |
|||
return new_arr |
|||
} |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[1, 2, 3, 4, 5, 6, 7, 8] |
|||
</pre> |
|||
=={{header|Wart}}== |
=={{header|Wart}}== |