@@ -238,6 +238,15 @@ module Array =
238238
239239 Array.init ( min a1.Length a2.Length) ( fun i -> f a1.[ i] a2.[ i])
240240
241+ /// <summary>Safely build a new array whose elements are the results of applying the given function
242+ /// to each of the elements of the three arrays pairwise.</summary>
243+ /// <remark>If one array is shorter, excess elements are discarded from the right end of the longer array.</remark>
244+ let map3Shortest f ( a1 : 'T1 []) ( a2 : 'T2 []) ( a3 : 'T3 []) =
245+ raiseIfNull ( nameof a1) a1
246+ raiseIfNull ( nameof a2) a2
247+ raiseIfNull ( nameof a3) a3
248+ Array.init ( min a1.Length a2.Length |> min a3.Length) ( fun i -> f a1.[ i] a2.[ i] a3.[ i])
249+
241250 /// <summary>
242251 /// Zip safely two arrays. If one array is shorter, excess elements are discarded from the right end of the longer array.
243252 /// </summary>
@@ -250,6 +259,19 @@ module Array =
250259
251260 Array.init ( min a1.Length a2.Length) ( fun i -> a1.[ i], a2.[ i])
252261
262+ /// <summary>
263+ /// Zip safely three arrays. If one array is shorter, excess elements are discarded from the right end of the longer array.
264+ /// </summary>
265+ /// <param name="a1">First input array.</param>
266+ /// <param name="a2">Second input array.</param>
267+ /// <param name="a3">Third input array.</param>
268+ /// <returns>Array with corresponding tuple of input arrays.</returns>
269+ let zip3Shortest ( a1 : array < 'T1 >) ( a2 : array < 'T2 >) ( a3 : array < 'T3 >) =
270+ raiseIfNull ( nameof a1) a1
271+ raiseIfNull ( nameof a2) a2
272+ raiseIfNull ( nameof a3) a3
273+ Array.init ( min a1.Length a2.Length |> min a3.Length) ( fun i -> a1.[ i], a2.[ i], a3.[ i])
274+
253275 /// <summary>Same as choose but with access to the index.</summary>
254276 /// <param name="mapping">The mapping function, taking index and element as parameters.</param>
255277 /// <param name="source">The input array.</param>
0 commit comments