List.concat<'T> Function (F#)

Returns a new list that contains the elements of each list in order.

Namespace/Module Path: Microsoft.FSharp.Collections.List

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
List.concat : seq<'T list> -> 'T list

// Usage:
List.concat lists

Parameters

  • lists
    Type: seq<'T list>

    The input sequence of lists.

Return Value

The resulting concatenated list.

Remarks

This function is named Concat in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Example

The following code example illustrates that List.append is used to join two lists together; and List.concat is used to join any number of lists.

let list1to10 = List.append [1; 2; 3] [4; 5; 6; 7; 8; 9; 10]
let listResult = List.concat [ [1; 2; 3]; [4; 5; 6]; [7; 8; 9] ]
List.iter (fun elem -> printf "%d " elem) list1to10
printfn ""
List.iter (fun elem -> printf "%d " elem) listResult

Output

1 2 3 4 5 6 7 8 9 10 
1 2 3 4 5 6 7 8 9

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)