single

There are other concepts named single. See the entire list.

single, selector

def process single(value: any): any

Returns the group value when the group contains exactly one element. Empty groups return the default value for the data type (or a custom default).

Example

table T = with
  [| as Value, as Group |]
  [| "one", "a" |]
  [| "two", "b" |]

table G[g] = with
  [| as g |]
  [| "a" |]
  [| "b" |]
  [| "c" |]

G.Value = single(T.Value) by T.Group at G.g default "missing"

show table "Single" with
  g
  G.Value

This outputs the following table:

g Value
a one
b two
c missing

Errors

Fails when a group contains more than one element.

Remarks

This selector cannot be used with sort.

See also

User Contributed Notes
0 notes + add a note