Flatten a list: Difference between revisions

Add Refal
(Add Refal)
(4 intermediate revisions by 3 users not shown)
Line 1,565:
(t
(append (flatten (car mylist)) (flatten (cdr mylist))))))</syntaxhighlight>
 
The flatten-tree function was added in Emacs 27.1 or earlier.
 
<syntaxhighlight lang="lisp">
(flatten-tree mylist)
</syntaxhighlight>
 
=={{header|Erlang}}==
Line 2,120 ⟶ 2,126:
return
end</syntaxhighlight>
 
=={{header|Insitux}}==
Insitux has a built-in flatten function.
<syntaxhighlight lang="insitux">
(flatten [[1] 2 [[3 4] 5] [[[]]] [[[6]]] 7 8 []])
</syntaxhighlight>
{{out}}
<pre>
[1 2 3 4 5 6 7 8]
</pre>
 
=={{header|Ioke}}==
Line 3,521 ⟶ 3,537:
>> form blk
== "1 2 test a bb 3 4 99"</syntaxhighlight>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
, ((1) 2 ((3 4) 5) ((())) (((6))) 7 8 ()): e.List
= <Prout e.List ' -> ' <Flatten e.List>>
};
 
Flatten {
= ;
s.I e.X = s.I <Flatten e.X>;
(e.X) e.Y = <Flatten e.X> <Flatten e.Y>;
};</syntaxhighlight>
{{out}}
<pre>((1 )2 ((3 4 )5 )((()))(((6 )))7 8 ()) -> 1 2 3 4 5 6 7 8</pre>
 
=={{header|REXX}}==
Line 4,218 ⟶ 4,248:
{{libheader|Wren-seq}}
A method already exists for this operation in the above module.
<syntaxhighlight lang="ecmascriptwren">import "./seq" for Lst
 
var a = [[1], 2, [[3, 4], 5], [[[]]], [[[6]]], 7, 8, []]
2,094

edits