Home

F# Collections: Appending an Array

 

Fundamentalsof Arrays

 

Introduction

Appending an array consists of adding one array to another array and getting the resulting group as a new array. This operation is available through the append() method of the Array class. Its signature is:

Array.append : 'T [] -> 'T [] -> 'T []

This function takes two arguments, each is an array. The values of the second array will be added to the right side of the values of the first array. The result is a new array. Here is an example of calling the method:

let week1 = [| 8.00; 8.50;  8.00; 9.00; 8.00; 0.00; 0.00; |]
let week2 = [| 8.50; 9.50; 10.00; 8.50; 9.50; 0.00; 0.00; |]

let payrollTimes = Array.append week1 week2

This would produce:

[|8.0; 8.5; 8.0; 9.0; 8.0; 0.0; 0.0; 8.5; 9.5; 10.0; 8.5; 9.5; 0.0; 0.0|]

 

     
     
 

Home Copyright © 2012-2015, FunctionX Home