Loop over multiple arrays simultaneously: Difference between revisions

Content added Content deleted
(added Clojure version)
(Added HaXe language)
Line 123: Line 123:


If lists are different lengths, it stops after the shortest one.
If lists are different lengths, it stops after the shortest one.

=={{header|Haxe}}==
<lang HaXe>import neko.Lib;

using Lambda;
using Std;

class Main
{
static function main()
{
var a = ['a', 'b', 'c'];
var b = ['A', 'B', 'C'];
var c = [1, 2, 3];
//Find smallest array
var len = [a, b, c]
.map(function(a) return a.length)
.fold(Math.min, 0x0FFFFFFF)
.int();

for (i in 0...len)
Lib.println(a[i] + b[i] + c[i].string());
}
}</lang>


=={{header|J}}==
=={{header|J}}==