Columnal Documentation: Table of Contents

lookup functions

lookuplookup all
lookup(keys, key, values)value Type: For any types a, b where Equatable a([a], a, [b]) -> b

Given a list, finds a matching item, and returns the corresponding value from the other list.

This is useful for looking up one column via the value of another, e.g. lookup(Column A, value in A, Column B)

Gives an error if there are zero or multiple matches in the left side.

ExamplesClick an example to insert it
lookup([4, 5, 6], 6, ["a", "b", "c"])"c"
lookup([1, 1, 2, 3], 1, ["a", "b", "c", "d"])error
lookup all(keys, key, values)matching values Type: For any types a, b where Equatable a([a], a, [b]) -> [b]

Given two lists, finds all the items with a matching value in left list, and returns the right list values for each.

This is useful for looking up one column via the value of another, e.g. lookup all(Column A, value in A, Column B)

ExamplesClick an example to insert it
lookup all([1, 2, 1, 3], 1, ["a", "b", "c", "d"])["a", "c"]