Flatten a list: Difference between revisions

Line 1,065:
}
</lang>
 
=={{header|Forth}}==
{{works with|Forth}}
Works with any ANS Forth.
Needs the FMS-SI (single inheritance) library code located here:
http://soton.mpeforth.com/flag/fms/index.html
<lang forth>include FMS-SI.f
include FMS-SILib.f
include FMS-SILib-extras.f
 
: flatten \ { list1 list2 -- }
locals| list2 list1 |
list1 size: 0 ?do i list1 at:
dup [is-a] object-list2 0=
if list2 addobj: else list2 recurse then loop ;
object-list2 list
o{ o{ 1 } 2 o{ o{ 3 4 } 5 } o{ o{ o{ } } } o{ o{ o{ 6 } } } 7 8 o{ } }
list flatten
list p: \ o{ 1 2 3 4 5 6 7 8 } ok</lang>
 
 
=={{header|Fortran}}==