Handling data – tuples, lists, record types, and data manipulation

F# supports many data types, for example:

  • Primitive types: bool, int, float, string values.
  • Aggregate typeclass, struct, union, record, and enum 
  • Array: int[], int[ , ], and float[ , , ]
  • Tuple: type1 * type2 * like (a,1,2,true) type is—char * int * int * bool
  • Generic: list<’x>, dictionary < ’key, ’value>

In an F# function, we can pass one tuple instead of multiple parameters of different types. Declaration of a tuple is very simple and we can assign values of a tuple to different variables, for example:

let tuple1 = 1,2,3// assigning values to variables , v1=1, v2= 2, v3=3let v1,v2,v3 = tuple1// if we want to assign only two values out of three, use “_” to skip the value. ...

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.