Skip to main content

Record

Library of functions for the record type.

Functions

AddField

Adds a new field to a record.

Syntax:
Record.AddField(record: record, field=value)
Parameters
  • record: The record to add the field to.
  • field=value: Field name mapping to value.
Example:
let r = Record.Build(lat=46.518831258, lon=6.5593310)
in Record.AddField(r, name="EPFL") // { lat: 46.518831258, lon: 6.5593310, name: "EPFL" }

Build

Builds a record value.

Syntax:
Record.Build(field=value, ...)
Parameters
  • field=value, ...: Pairs of field name mapping to value.
Example:
Record.Build(lat=46.518831258, lon=6.5593310) // {lat: 46.518831258, lon: 6.5593310}

Concat

Concatenates two records.

Syntax:
Record.Concat(record1: record, record2: record)
Parameters
  • record1: First record to concatenate into one.
  • record2: Second record to concatenate into one.
Example:
let r1 = Record.Build(x=1, y=2),
r2 = Record.Build(a="1", b="2")
in Record.Concat(r1, r2) // {x: 1, y: 2, a: "1", b: "2"}

Fields

Returns the field names of a record as a list of strings.

Syntax:
Record.Fields(record: record)
Parameters
  • record: The record to obtain the fields from.
Example:
let r = Record.Build(46.518831258, lon=6.5593310)
in Record.Fields(r) // List.Build("lat", "lon")

GetFieldByIndex

Gets a field from a record given an index.

Syntax:
Record.GetFieldByIndex(record: record, index: int)
Parameters
  • record: The record to read the field from.
  • index: The index (aka position) of the field to get from the record.
Example:
let r = Record.Build(x=1, y=2, z=3)
in Record.GetFieldByIndex(r, 1)

RemoveField

Removes a field from a record.

Syntax:
Record.RemoveField(record: record, field: string)
Parameters
  • record: The record to remove the field from.
  • field: The name of the field to remove from the record.
Example:
let r = Record.Build(x=1, y=2, z=3)
in Record.RemoveField(r, "y") // Record.Build(x=1, z=3)