Columnal Documentation: Table of Contents

core functions

as typetype ofconvert unit
as type(type, value)value Type: For any types t(@apply Type(t), t) -> t

Clarifies the type of a value.

No processing is done on the value; this function is only for specifying a type when it is ambiguous and you get a type error. For conversions, see functions like conversion:from text(..).

ExamplesClick an example to insert it
as type(type{Boolean}, from text("True"))trueSpecifies that the destination type of the conversion from text is Boolean.
as type(type{[Date]}, [])[]Specifies that the given empty list is a list of dates.
type of(value)type Type: For any types t(t) -> @apply Type(t)

Gets the type of the given value.

ExamplesClick an example to insert it
as type(type of([3]), from text("[1, 2, 5]"))[1, 2, 5]
type of([(a:true, b:6)])type{[(a:Boolean, b:Number)]}
type of((t: time{00:00}, s: 21{s}))type{(t: Time, s: Number{s})}
convert unit(target unit, source number)target number Type: For any units u, v(@apply Unit(u), Number{v}) -> Number{u}

Converts a number from one unit to another (if possible).

Unit conversion is only available for exact conversions (e.g. metres to centimetres), not for approximate or changing conversions (e.g. euros to dollars).

Attempting to convert between unrelated units (e.g. metres to seconds) will result in an error. This includes converting to/from plain numbers. If you want to add a unit to a number multiply by 1 of that unit (for example, duration * 1{s}), if you want to remove a unit then divide by 1 of that unit (for example, distance / 1{m}).

ExamplesClick an example to insert it
convert unit(unit{cm}, 1{inch})2.54{cm}Convert one inch into centimetres
convert unit(unit{l}, 30{cm} * 20{cm} * 10{cm})6{l}Convert a volume in cubic centimetres into litres
convert unit(unit{mile/hour}, (100{m} / 9.58{s}))23.350{mile/hour} ± 0.001{mile/hour}Convert speed running 100 metres in 9.58 seconds into miles per hour
convert unit(unit{m^2}, 10{m})errorTry to convert between unrelated or impossible units (here: length and area) gives an error.