Documentation Menu · Library Functions & Units
Library Functions & Units
Complete reference for Hector's 66 intrinsic functions and 52 exact dimensional units, extracted directly from sens/world.
All Built-in Functions (66, from world::INTRINSICS) #
| Function | Kind | Returns |
|---|---|---|
memory | fixed | Size |
p99 | fixed | Duration |
round | fixed | First |
dir | fixed | Direction |
dist | fixed | Magnitude |
unit | fixed | Direction |
norm | fixed | Magnitude |
abs | each | Magnitude |
dot | each | DotProduct |
cross | each | CrossProduct |
min | open | Common |
max | open | Common |
clamp | each | Common |
mod | each | First |
uniform | each | First |
normal | each | First |
past | open | First |
sqrt | each | Root |
exp | each | Pure |
log | each | Pure |
pow | each | Pure |
sine | each | Pure |
cosine | each | Pure |
inside | open | Truth |
crosses | open | Truth |
visible | open | Truth |
unique | open | Truth |
acyclic | open | Truth |
decreasing | open | Truth |
idempotent | open | Truth |
stable | open | Truth |
repeats | open | Truth |
bernoulli | open | Truth |
letter | open | Truth |
digit | open | Truth |
space | open | Truth |
empty | open | Truth |
age | open | Duration |
delay | open | Duration |
now | open | Instant |
born | open | Instant |
key | open | Count |
entered | open | Instant |
instant | open | Instant |
day | open | Period |
month | open | Period |
year | open | Period |
first | open | Element |
second | open | Element |
third | open | Element |
rest | open | First |
take | open | First |
drop | open | First |
upper | open | First |
lower | open | First |
length | open | Length |
get | open | MapValue |
keys | open | MapKeys |
words | open | Words |
locate | fixed | Position |
strip | fixed | Text |
text | fixed | Text |
read_number | fixed | Pure |
quantity | open | Generic |
encode | open | Bytes |
seen | open | Second |
All Physical & Money Units (52, from world::UNIT_TABLE) #
| Symbol | Quantity Dimension | Base Ratio |
|---|---|---|
EUR | Money | 1 / 1 |
USD | Money | 1 / 1 |
m | Length | 1 / 1 |
km | Length | 1000 / 1 |
cm | Length | 1 / 100 |
mm | Length | 1 / 1000 |
kg | Mass | 1 / 1 |
g | Mass | 1 / 1000 |
mg | Mass | 1 / 1000000 |
t | Mass | 1000 / 1 |
s | Duration | 1 / 1 |
ms | Duration | 1 / 1000 |
us | Duration | 1 / 1000000 |
ns | Duration | 1 / 1000000000 |
min | Duration | 60 / 1 |
h | Duration | 3600 / 1 |
day | Duration | 86400 / 1 |
week | Duration | 604800 / 1 |
month | Duration | 2592000 / 1 |
year | Duration | 31536000 / 1 |
Hz | Frequency | 1 / 1 |
kHz | Frequency | 1000 / 1 |
N | Force | 1 / 1 |
Pa | Pressure | 1 / 1 |
J | Energy | 1 / 1 |
Wh | Energy | 3600 / 1 |
kWh | Energy | 3600000 / 1 |
W | Power | 1 / 1 |
kW | Power | 1000 / 1 |
deg | Angle | 1 / 1 |
K | Temperature | 1 / 1 |
byte | Size | 1 / 1 |
bit | Size | 1 / 8 |
KB | Size | 1000 / 1 |
MB | Size | 1000000 / 1 |
GB | Size | 1000000000 / 1 |
TB | Size | 1000000000000 / 1 |
KiB | Size | 1024 / 1 |
MiB | Size | 1048576 / 1 |
GiB | Size | 1073741824 / 1 |
TiB | Size | 1099511627776 / 1 |
char | Offset | 1 / 1 |
% | Ratio | 1 / 100 |
L | Volume | 1 / 1000 |
mL | Volume | 1 / 1000000 |
ha | Area | 10000 / 1 |
MW | Power | 1000000 / 1 |
MWh | Energy | 3600000000 / 1 |
kJ | Energy | 1000 / 1 |
kPa | Pressure | 1000 / 1 |
bar | Pressure | 100000 / 1 |
degC | Temperature | 1 / 1 |
Reference entries for the first group of library words, in alphabetical order. Each entry gives the meaning for someone who writes rules, the kind of value it gives, and the trap to avoid.
abs #
Gives the size of a number without its sign, or the length of a vector: how far a value sits from zero, on either side. Use it for a gap or a tolerance where direction does not matter. A number keeps its unit, so a length stays a length; a vector gives its length, with the unit of its components.
-- but: ecart absolu entre une caisse et son quai, sans sens
Clerk
Dock name: Text, position: Length
Crate dock: Dock, spot: Length
gap = abs(spot - dock.position)
-> on Place by Clerk
show gap to Clerk within 1 s
example ecart
quai = Dock(name: "Quai 1", position: 10 m)
c = Place(dock: quai, spot: 4 m)
see c.gap = 6 m
acyclic #
A law, not a value: a relation such as a parent link never forms a loop, so that following the chain from any row always ends. Write it as a law line inside the sort whose relation it guards; it has no value to read in an example. A definition that walks along the relation, such as a depth that adds one per parent, is only sound when no chain loops.
-- but: une categorie a au plus un parent, et la hierarchie ne boucle jamais
Clerk
Category name: Text, parent: Category?
law acyclic(parent)
depth = parent.depth + 1 if any(parent) else 0
-> on Create by Clerk
show depth to Clerk within 1 s
example hierarchie
racine = Create(name: "Racine")
fils = Create(name: "Fils", parent: racine)
petit = Create(name: "Petit", parent: fils)
see petit.depth = 2
see racine.depth = 0
age #
Gives the time elapsed since an instant held by a field: now minus that instant. Write the field name so the word reads the instant the field holds; a row reads the instant it was born. The result is a duration, so compare it with a duration such as three days, not with a bare number. A field that holds an answer rather than an instant gives the time since that field was last set.
-- but: un ticket ouvert depuis trois jours est visible au responsable
Clerk
Ticket title: Text, opened: Instant
status: Open | Closed
waiting = age(opened)
-> Open on Log by Clerk
Open -> Closed on Close by Clerk
show status to Clerk within 1 s
example attente
t = Log(title: "Fuite", opened: 2026-11-01T09:00)
at 2026-11-04T09:00
see t.waiting = 3 day
bernoulli #
Draws yes or no at random, with the probability given: a probability of five per cent means about one draw in twenty is yes. It is a draw, written as a random assignment with the tilde form for a start or a next value, not an ordinary definition, which would stay fixed. A probability of zero is always no and a probability of one hundred per cent is always yes, which is what the example checks; any other probability is a random outcome that no example can state by hand.
-- but: tirage d'un controle : une probabilite nulle ne tombe jamais, une certitude tombe toujours
Clerk
Batch name: Text
start never ~ bernoulli(0 %)
start always ~ bernoulli(100 %)
show never, always to Clerk within 1 s
-> on Open by Clerk
example extremes
b = Open(name: "Lot 7")
see b.never = false
see b.always = true
born #
Gives the instant at which a row was created. Reading it for the row being written takes the row itself, as in the example. Use it for a deadline counted from creation: the birth instant plus a period gives the due instant. The result is an instant, so adding a duration gives an instant and subtracting two instants gives a duration.
-- but: un pret dure quatorze jours a compter de sa naissance
Clerk
Loan title: Text
due = born(self) + 14 day
-> on Lend by Clerk
show due to Clerk within 1 s
example echeance
at 2026-11-01T09:00
l = Lend(title: "Dune")
see l.due = 2026-11-15T09:00
clamp #
Keeps a value between two bounds. With three arguments, the value, its lower bound and its upper bound, all in the same unit. With two, the value and a limit m, which keeps the value between minus m and m; for a vector with one limit, a vector longer than m is shortened to length m and a shorter one is left alone (a negative m reverses the vector, so keep m at zero or more). The result has the unit of the value, so both bounds must share that unit.
-- but: un prix affiche est borne entre vingt et cinquante euros
Clerk
Quote asked: Money
charged = clamp(asked, 20 EUR, 50 EUR)
-> on Price by Clerk
show charged to Clerk within 1 s
example bornes
a = Price(asked: 80 EUR)
see a.charged = 50 EUR
b = Price(asked: 5 EUR)
see b.charged = 20 EUR
c = Price(asked: 30 EUR)
see c.charged = 30 EUR
cosine #
Gives the cosine of an angle. With one number, the number is an angle in degrees, not radians. With two vectors, it is the cosine of the angle between them: one for the same direction, zero for a right angle. The result is a pure ratio without unit. A zero vector has no direction, so its cosine is absent.
-- but: alignement de deux directions : un si identiques, zero si perpendiculaires
Clerk
Beam axis: Vector m, ray: Vector m
alignment = cosine(axis, ray)
-> on Aim by Clerk
show alignment to Clerk within 1 s
example perpendiculaires
b = Aim(axis: (1, 0) m, ray: (0, 2) m)
see b.alignment = 0
c = Aim(axis: (3, 0) m, ray: (5, 0) m)
see c.alignment = 1
cross #
Gives the cross product of two vectors. In two dimensions it is the signed area of the parallelogram they span; in three dimensions it is a vector perpendicular to both. The unit is the product of the two units: two lengths give an area. The three-dimensional result keeps all three coordinates.
Frame
-> on Open
a = (1, 2, 3) m
b = (4, 5, 6) m
normal = cross(a, b)
area = cross((1, 2) m, (4, 5) m)
show normal, area to self
example oriented area
f = Open
see f.normal = (-3, 6, -3) m2
see f.area = -3 m2
crosses #
Tells whether a shot from a point in a given direction reaches a target: true when the target is within the given range and its bearing from the point is within two degrees of the aim. Points are two-dimensional, and the aim is an angle written with its unit, as in the example. The result is a truth value, usable as a condition or as a law.
-- but: un tir touche si la cible est a portee et dans le cone de visee
Clerk
Turret pos: Point m, aim: Angle
ready = crosses(pos, aim, (10, 0) m, 80 m)
-> on Install by Clerk
example dans le cone
t = Install(pos: (0, 0) m, aim: 0 deg)
see t.ready = true
day #
Gives the number of the calendar day that an instant falls on: two instants on the same day have the same number, and the next day has the next number. It identifies a day rather than counting days, so compare it with equal or not equal rather than adding to it. The reference judge cuts days at midnight UTC; month and year work the same way at a coarser grain.
-- but: deux visites le meme jour calendaire ont le meme numero de jour
Clerk
Visit at: Instant
period = day(at)
-> on Arrive by Clerk
show period to Clerk within 1 s
example meme jour
v = Arrive(at: 2026-11-10T09:00)
w = Arrive(at: 2026-11-10T18:30)
x = Arrive(at: 2026-11-11T08:00)
see v.period = w.period
see x.period != v.period
decreasing #
A law under a function, not a value: it declares the measure of the recursion, here the argument, and the judge checks that claim at every recursive call it follows: the measure, read at the arguments of the call, must be lower than at the nearest call in progress of the same function, whether the recursion is direct or comes back through other functions or definitions (with several terms the first term that differs decides). The first call that does not lower it is named NoMeasure, and nothing the law says about the recursion ending is held at that call. It checks the calls that are followed, and proves nothing about arguments that no run reaches. Write it indented under the recursive function. The example bounds the count from zero to ten, because on unbounded counts the reference judge and the native image disagreed on a deep recursion in the checker's own generated rows.
-- but: un compte a rebours d'etapes, dont la mesure baisse a chaque appel
Clerk
Stage depth: Count 0..10
cost = steps(depth)
-> on Begin by Clerk
show cost to Clerk within 1 s
steps(n: Count) = 0 if n <= 0 else 1 + steps(n - 1)
law decreasing(n)
example trois etapes
s = Begin(depth: 3)
see s.cost = 3
The judge admits each recursive edge before reusing a cached, active or provisional value. An admitted measure follows a deferred call through the explicit stack, and a rejected edge leaves a later independent call free to compute its own value.
delay #
Gives the time an answer from a by field has been awaited. While the answer is still unknown it is the time since the question was asked; once the answer has come, it is the time between the question and the answer. The question is asked at the birth of the row or at the event named after on. The result is a duration, and absent when the field was never asked.
-- but: un paiement attend la reponse de la banque ; le delai d'attente se lit a tout instant
Bank
Pledge amount: Money
status: Pending | Received | Failed
card: Accepted | Declined by Bank on Give
waiting = delay(card)
-> Pending on Give
Pending -> Received when card is Accepted
Pending -> Failed when card is Declined
stays Pending while card is Unknown
show status to Bank within 1 s
example attente
p = Give(amount: 10 EUR)
after 3 s
see p.waiting = 3 s
see p is Pending
digit #
True when the first character of a text is a digit from zero to nine; an empty text gives false. Only the first character is read, so a code that starts with a digit counts, whatever follows it. Use it with letter to classify the first character of a code.
-- but: un code commence-t-il par un chiffre
Clerk
Label code: Text
starts_digit = digit(code)
-> on Print by Clerk
show starts_digit to Clerk within 1 s
example chiffre puis lettre
a = Print(code: "7B")
see a.starts_digit = true
b = Print(code: "B7")
see b.starts_digit = false
dir #
Gives the direction from one point to another as a unit vector: a vector of length one with no unit, pointing from the first point to the second. Read its components to aim a move along each axis. It is absent when the two points are the same, because a point has no direction towards itself; a rule that reads it must allow for that.
-- but: cap d'un drone vers sa cible, sous forme de direction sans unite
Pilot
Drone pos: Point m, goal: Point m
heading = dir(pos, goal)
-> on Fly by Pilot
show heading to Pilot within 1 s
example cap nord
d = Fly(pos: (0, 0) m, goal: (0, 7) m)
see d.heading.y = 1
see d.heading.x = 0
dist #
Gives the straight-line distance between two points, or between two vectors of the same number of coordinates: the length of their difference. For points in metres it is a length, so it compares with other lengths and with the unit of the points. Use it for a range check or to pick the nearest candidate. Different numbers of coordinates give an absent result.
-- but: distance en ligne droite entre un drone et sa cible
Clerk
Drone pos: Point m, goal: Point m
gap = dist(pos, goal)
-> on Fly by Clerk
show gap to Clerk within 1 s
example distance
d = Fly(pos: (0, 0) m, goal: (0, 7) m)
see d.gap = 7 m
dot #
Gives the scalar product of two vectors: the sum of the products of their components. Its unit is the product of the two units, so a force in newtons times a displacement in metres gives an energy, not a plain number. Use it for work or for a projection. It is absent when either vector is absent.
-- but: travail d'une force le long d'un deplacement
Clerk
Push force: Vector N, move: Vector m
work = dot(force, move)
-> on Apply by Clerk
show work to Clerk within 1 s
example travail
p = Apply(force: (2, 0) N, move: (5, 1) m)
see p.work = 10 J
drop #
Gives a text without its first k characters, or a collection without its first k elements. With a text as second argument, it removes that text when it is the prefix and returns the text unchanged otherwise; use it to cut a fixed header from a code. The result has the type of its first argument.
-- but: un numero de reference sans son prefixe fixe
Clerk
Ticket code: Text
number = drop(code, 4)
-> on Book by Clerk
show number to Clerk within 1 s
example prefixe
t = Book(code: "REF-2026")
see t.number = "2026"
empty #
True when a text has no characters or a collection has no element; false otherwise. Use it to guard a rule, for instance a label that must be given. It is a truth value, so it can serve as a condition, a law or a flag shown to someone.
-- but: une fiche sans libelle se repere a son champ vide
Clerk
Item label: Text
blank = empty(label)
-> on Enter by Clerk
show blank to Clerk within 1 s
example vide et rempli
a = Enter(label: "")
see a.blank = true
b = Enter(label: "Vis")
see b.blank = false
encode #
Gives the bytes of a value under its declared public format. The reference judge evaluates a value type with one constructor, or a row whose stored fields all participate in a public format, in declaration order. A Count field has a width from 1 to 16 bytes and an explicit byte order when wider than one byte; a Bytes field takes its length from an earlier count. Secret row fields do not form a public layout.
Absent or unknown fields propagate. A missing or unsupported public format leaves the result unknown with an OutOfScope gap. A count that does not fit its width, or a Bytes field whose length differs from the declared count, leaves it unknown with an InvalidNumber gap.
The example checks the width of three fields whose public formats use different widths and byte orders.
Message source: Count 0..65535 2 byte little, sequence: Count 0..16777215 3 byte big, flags: Count 0..255 1 byte
wire = encode(self)
width = length(wire)
-> on Send(source, sequence, flags)
show width to Receiver
example an encoded message occupies its declared width
m = Send(source: 513, sequence: 66309, flags: 7)
see m.width = 6
entered #
Gives the instant at which a row last entered a status: the most recent move into it, not the first. It measures time spent in a state, since now minus this instant is the time in that state. It is absent for a row that never entered the status. Call it on the row itself, or on another row with a dot.
-- but: un travail en cours depuis son entree dans l'etat Running
Clerk
Job
status: Waiting | Running | Done
since = entered(Running)
-> Waiting on Post by Clerk
Waiting -> Running on Start by Clerk
Running -> Done on Finish by Clerk
show status, since to Clerk within 1 s
example depuis
j = Post
at 2026-11-10T09:00
Start(j)
at 2026-11-10T09:30
see j.since = 2026-11-10T09:00
Finish(j)
see j is Done
key #
Gives the key the outside gives a row: the deployment for the rows it provides, the event for the row it makes be born. It is a count, read and never written or allocated by the program, so a rule can say "match 5 takes the winner of match 1" without inventing an identifier. Call it on the row itself: key(self).
Desk
Lamp watts: Count
state: Off | On
Off -> On on Switch
number = key(self)
show state, number to Desk
example the key
l = Lamp(watts: 40)
see l.number = 1
exp #
Gives e raised to the power of its argument, the base of continuous growth; the exponential of zero is one. The result is a pure ratio. The argument should be dimensionless, a count or a ratio, as in the example; the checker does not yet refuse another unit. A value so large that no double-precision number holds it is out of scope, and the checker answers that it cannot establish the result, which is why the example bounds its count from zero to fifty.
-- but: facteur de croissance continue ; sans temps ecoule, il vaut un
Clerk
Sample hours: Count 0..50
factor = exp(hours)
-> on Measure by Clerk
show factor to Clerk within 1 s
example aucun passage
s = Measure(hours: 0)
see s.factor = 1
first #
Gives the first element of a collection, or the first character of a text. For a collection the result may be absent when the collection is empty, so the result is optional; for a text it is a text of one character, or absent when the text is empty. Use it for an initial of a name or for the head of a list before its rest.
-- but: l'initiale d'un prenom
Clerk
Member name: Text
initial = first(name)
-> on Join by Clerk
show initial to Clerk within 1 s
example initiale
m = Join(name: "Ana")
see m.initial = "A"
get #
Gives the value stored under a key of a map, or absent when the key is not in the map. The result is optional, so a rule that reads it must allow for the missing key, and an absent key is not an error. Use it for a price list or a rate table held as a map field.
-- but: le prix d'un produit lu dans un catalogue
Clerk
Basket prices: Map(Text, Money)
price_of_bread = get(prices, "pain")
-> on Stock by Clerk
show price_of_bread to Clerk within 1 s
example lecture
b = Stock(prices: ["pain": 2 EUR, "lait": 1 EUR])
see b.price_of_bread = 2 EUR
idempotent #
States that repeating an external call has the same effect as one call, making a retry safe after a lost reply. It can be written as an assumption on a call that answers a field. Hector has no execution evidence for that external guarantee yet. Reading it gives Unknown and names the missing evidence; it cannot establish a law or an example.
inside #
Tells whether a two-dimensional point belongs to a polygon given by its vertices, including its edges and corners. Write at least three vertices in boundary order, clockwise or counterclockwise; the last edge returns to the first vertex. All coordinates must have compatible units. A wrong number of components, fewer than three vertices, or an absent operand is absent; an unknown vertex leaves the answer unknown. An opaque Region received from outside has no polygon coordinates to evaluate.
Site
-> on Open
boundary = [(0, 0) m, (4, 0) m, (4, 3) m, (0, 3) m]
middle = inside((2, 1) m, boundary)
edge = inside((4, 1) m, boundary)
outside = inside((5, 1) m, boundary)
show middle, edge, outside to self
example closed polygon
s = Open
see s.middle
see s.edge
see not s.outside
instant #
Reads a text written in the ISO form, year first, as a date alone or a date followed by a T and an hour, and gives the instant it names. It is absent when the text is not in that form. Use it when a time arrives as text from outside; once read, the instant compares and adds like any other instant.
-- but: un horodatage saisi en texte devient un instant comparable
Clerk
Stamp text: Text
at = instant(text)
-> on Record by Clerk
show at to Clerk within 1 s
example horodatage
s = Record(text: "2026-11-10T09:00")
see s.at = 2026-11-10T09:00
keys #
Gives the keys of a map as a set, one entry per key, without the values. Use it with another word, for instance to count the entries by taking the length of the set. Its type is a set of the key type.
-- but: le nombre de produits d'un panier, lu par ses cles
Clerk
Basket prices: Map(Text, Money)
lines = length(keys(prices))
-> on Stock by Clerk
show lines to Clerk within 1 s
example compte
b = Stock(prices: ["pain": 2 EUR, "lait": 1 EUR])
see b.lines = 2
length #
Gives how many elements a collection has, or how many characters a text has. The length of a text has the unit of a character, so write the expected number with that unit; a bare number is refused. An absent value gives an absent length. Use it for a size limit on a name or for a count of lines.
-- but: le nombre de lettres d'un nom
Clerk
Name text: Text
size = length(text)
-> on Enter by Clerk
show size to Clerk within 1 s
example longueur
n = Enter(text: "Lou")
see n.size = 3 char
letter #
True when the first character of a text is a letter or an underscore; false when it is a digit or a space, and false for an empty text. Only the first character is read. Use it with digit to classify the first character of a code.
-- but: un code commence-t-il par une lettre
Clerk
Label code: Text
starts_letter = letter(code)
-> on Print by Clerk
show starts_letter to Clerk within 1 s
example lettre puis chiffre
a = Print(code: "B7")
see a.starts_letter = true
b = Print(code: "7B")
see b.starts_letter = false
log #
Gives the natural logarithm, the power to which e gives the argument. The result is a pure ratio. The logarithm of one is zero. A zero or negative argument has no logarithm, so the result is absent rather than refused. Use it to weigh a count on a compressed scale.
-- but: poids d'un compte sur une echelle comprimee ; un seul coup donne zero
Clerk
Sample hits: Count 1..100
weight = log(hits)
-> on Measure by Clerk
show weight to Clerk within 1 s
example un seul coup
s = Measure(hits: 1)
see s.weight = 0
lower #
Gives the text in lower-case letters, so that keys compare without regard to case. The result is a text. An argument that is absent or not a text gives an absent result.
-- but: cle de recherche insensible a la casse
Clerk
Entry word: Text
key = lower(word)
-> on Store by Clerk
show key to Clerk within 1 s
example casse
e = Store(word: "HeCToR")
see e.key = "hector"
Reference entries for the second group of library words, in alphabetical order. Each entry gives the meaning for someone who writes rules, the kind of value it gives, and the trap to avoid.
locate #
The scalar search operation used by find: the first Unicode scalar offset, or absence.
Line value: Text
-> on Read(value)
parts = split(trim(value), ";")
combined = join(parts, ":")
changed = replace(value, ";", ":")
found = find(value, ";")
has = contains(value, ";")
shown = format(number("12"))
show combined, changed, found, has, shown to Screen
example text ingestion
a = Read(value: " 12;34 ")
see a.combined = "12:34"
see a.has = true
see a.shown = "12"
strip #
The edge-whitespace operation used by trim, using Unicode whitespace boundaries.
Line value: Text
-> on Read(value)
parts = split(trim(value), ";")
combined = join(parts, ":")
changed = replace(value, ";", ":")
found = find(value, ";")
has = contains(value, ";")
shown = format(number("12"))
show combined, changed, found, has, shown to Screen
example text ingestion
a = Read(value: " 12;34 ")
see a.combined = "12:34"
see a.has = true
see a.shown = "12"
text #
The canonical numeric rendering used by format; exact fractions remain exact.
Line value: Text
-> on Read(value)
parts = split(trim(value), ";")
combined = join(parts, ":")
changed = replace(value, ";", ":")
found = find(value, ";")
has = contains(value, ";")
shown = format(number("12"))
show combined, changed, found, has, shown to Screen
example text ingestion
a = Read(value: " 12;34 ")
see a.combined = "12:34"
see a.has = true
see a.shown = "12"
read_number #
The exact decimal and fraction reader used by number. Invalid text refuses with InvalidNumber; absence and Unknown propagate.
Line value: Text
-> on Read(value)
parts = split(trim(value), ";")
combined = join(parts, ":")
changed = replace(value, ";", ":")
found = find(value, ";")
has = contains(value, ";")
shown = format(number("12"))
show combined, changed, found, has, shown to Screen
example text ingestion
a = Read(value: " 12;34 ")
see a.combined = "12:34"
see a.has = true
see a.shown = "12"
max #
Gives the largest of several values of the same type: a price raised to a floor, or the later of two dates. Several arguments are read together, and an absent argument is ignored. A collection gives its largest element, and an empty collection gives an absent result. Use it to keep a figure from going under a fixed minimum.
-- but: prix facture : jamais en dessous du minimum fixe par le contrat
Clerk
Bill price: Money, minimum: Money
billed = max(price, minimum)
-> on Invoice by Clerk
show billed to Clerk within 1 s
example minimum et au-dessus
a = Invoice(price: 12 EUR, minimum: 20 EUR)
see a.billed = 20 EUR
b = Invoice(price: 35 EUR, minimum: 20 EUR)
see b.billed = 35 EUR
memory #
Gives the memory cost requested of a realization, as a quantity of the size dimension. The reference judge has no execution evidence for it yet: a rule that reads it gets Unknown and a named gap. It is never a measured zero.
min #
Gives the smallest of several values of the same type: an offer held under a customer's ceiling, or the earlier of two instants. Several arguments are read together, and an absent argument is ignored. A collection gives its smallest element, and an empty collection gives an absent result. It is the mirror of max: the example caps one offer and leaves a lower one alone.
-- but: prix d'une offre plafonne par la limite du client
Clerk
Ask offer: Money, cap: Money
charged = min(offer, cap)
-> on Quote by Clerk
show charged to Clerk within 1 s
example plafond et sous le plafond
a = Quote(offer: 12 EUR, cap: 20 EUR)
see a.charged = 12 EUR
b = Quote(offer: 35 EUR, cap: 20 EUR)
see b.charged = 20 EUR
mod #
Gives the remainder of a whole-number division, for example the position of a seat in a row of five or the phase of a cycle that repeats. The quotient is rounded down before the remainder is taken, so a negative dividend gives a remainder that is not negative: minus one modulo five is four. A zero divisor has no remainder, and the result is absent.
-- but: rang d'un siege dans une rangee de cinq : le reste de la division
Clerk
Seat number: Count 1..100
row = mod(number, 5)
-> on Book by Clerk
show row to Clerk within 1 s
example reste
s = Book(number: 17)
see s.row = 2
t = Book(number: 10)
see t.row = 0
month #
Gives the calendar month an instant falls in, as a number that stays the same for every instant of that month and goes up by one in the next. Like day, it identifies a month rather than counting months, so compare two results with equal and never add them. The reference judge cuts months at midnight UTC on the first day. Use it to tell whether two dates belong to the same month.
-- but: une facture et son paiement tombent-ils dans le meme mois ?
Clerk
Invoice issued: Instant, paid: Instant
same_month = month(issued) = month(paid)
-> on File by Clerk
show same_month to Clerk within 1 s
example meme mois puis mois suivant
a = File(issued: 2026-11-02T09:00, paid: 2026-11-28T17:00)
see a.same_month = true
b = File(issued: 2026-11-30T09:00, paid: 2026-12-01T08:00)
see b.same_month = false
norm #
Gives the length of a vector: the square root of the sum of the squares of its components, in the unit of the vector, so the length of a displacement given in metres is a length. A vector without a unit gives a plain ratio. Use it to measure how far a move goes whatever its direction. The example uses a three, four, five triangle, which a reader can check by hand.
-- but: longueur d'un deplacement, sans son sens
Clerk
Walk step: Vector m
length = norm(step)
-> on Move by Clerk
show length to Clerk within 1 s
example pas de trois et quatre
w = Move(step: (3, 4) m)
see w.length = 5 m
normal #
Draws a random value from a bell curve centred on zero, whose spread is the standard deviation given as argument, so that most draws lie within two spreads of zero. Like uniform and bernoulli it is a draw, written with the tilde form for a start or a next value, because an ordinary definition would stay fixed. A spread of zero always gives zero, which is what the example checks; any other spread is a random outcome that no example can state by hand.
-- but: bruit d'un capteur sans dispersion : la mesure reste exacte
Clerk
Probe name: Text
start noise ~ normal(0 m)
-> on Open by Clerk
show noise to Clerk within 1 s
example sans dispersion
p = Open(name: "Sonde")
see p.noise = 0 m
now #
Gives the current instant of the run, the moment at which a rule is read. A definition that uses it moves as time passes: the example reads the same row before and after a day has gone by. To keep the instant at which a row was created, use born(self) instead, which does not move. The result is an instant, and the difference of two instants is a duration.
-- but: horodater l'instant d'un releve ; la valeur suit l'horloge
Clerk
Reading level: Count
taken = now
-> on Record by Clerk
show taken, level to Clerk within 1 s
example horodatage qui avance
at 2026-11-04T09:00
r = Record(level: 7)
see r.taken = 2026-11-04T09:00
after 1 day
see r.taken = 2026-11-05T09:00
p99 #
No example. Is meant to give the 99th percentile of the time that a sort or an event takes on the realisation: the time that 99 runs in 100 do not exceed. It sits in a performance preference such as prefer p99 <= 8 ms on Frame, which states a goal for the realisation and never changes the result. The reference judge answers Unknown for it, and no run can state a latency by hand, so it is measured rather than exampled.
past #
No example. Is meant to give the value that a quantity had a given time ago, so that a rule can compare a reading with the one of yesterday. The duration is written with its unit, as one day. The reference judge does not evaluate it yet: a rule that reads it is not established, and an example that states its value is refuted, the judge answering Unknown.
pow #
Gives a number raised to a power: the area of a square from its side when the side is a count (a length gives a ratio here), or a growth over whole periods. With a whole-number exponent the result stays exact while it fits two 128-bit words, and a fractional exponent gives a decimal result rounded in the reference arithmetic. A zero base with a negative exponent has no value, so the result is absent.
-- but: surface d'un carre de cote n : n puissance deux
Clerk
Square side: Count 1..20
area = pow(side, 2)
-> on Cut by Clerk
show area to Clerk within 1 s
example carre de trois
s = Cut(side: 3)
see s.area = 9
quantity #
Reads a text as a number, so that a figure typed by someone can be added and compared like any other quantity. A text that is not a number gives an absent value, which is the case the example checks. The word does not fix the dimension of the figure: the rule that uses the result decides what it measures. Use it at the edge where a form or a file gives figures as text.
-- but: une saisie en texte devient une quantite, ou reste absente si ce n'est pas un nombre
Clerk
Entry typed: Text
amount = quantity(typed)
-> on Enter by Clerk
show amount to Clerk within 1 s
example saisie lisible
e = Enter(typed: "42")
see e.amount = 42
f = Enter(typed: "abc")
see not any(f.amount)
repeats #
Says that an event may arrive again with the same request and must give the same fact, which is the default: a replayed birth is not a second row, so this premise need not be written in new programs. The predicate holds for an event declared by the program; an argument that names no such event is absent.
The example checks that the declared event is recognized and that its repeated act leaves the state unchanged.
Desk
Lamp watts: Count
state: Off | On
Off -> On on Switch
repeated Switch when state is On
retryable = repeats(Switch)
show state, retryable to Desk
example a repeated switch leaves the lamp on
l = Lamp(watts: 40)
see l.retryable = true
Switch(l)
see l is On
repeated Switch(l)
see l is On
rest #
Gives everything after the first element: a text without its first character, or a list without its first element. It is the companion of first, so that a rule can walk along a list one element at a time. Reading the rest of an absent value gives an absent result, and the rest of a one-character text is empty. Use it to drop a leading mark before comparing what follows.
-- but: le prenom sans sa premiere lettre, pour l'appel par le nom
Clerk
Member name: Text
tail = rest(name)
-> on Join by Clerk
show tail to Clerk within 1 s
example sans initiale
m = Join(name: "Ana")
see m.tail = "na"
round #
Rounds a quantity to a step: a sum of money to the nearest five euros, or a duration to the hour. The step carries the unit of the quantity, and the mode says which way to go: Down and Up take the step below or above for a positive amount; for a negative one they go toward zero and away from it, as the checker computes them, while HalfUp and HalfEven use the usual half-way rules. The mode is a business choice, so a call without one is an open question that the checker asks you to answer. Use it when a figure must land on a unit that people pay or count.
-- but: un montant arrondi au billet de cinq euros inferieur, et au superieur
Clerk
Cash amount: Money
down = round(amount, 5 EUR, Down)
up = round(amount, 5 EUR, Up)
-> on Tally by Clerk
show down, up to Clerk within 1 s
example billets
c = Tally(amount: 17 EUR)
see c.down = 15 EUR
see c.up = 20 EUR
second #
Gives the second element of a collection, or the second character of a text: the same reading as first, one place further. For a collection the result is optional, since a short collection has no second element; for a text it is a one-character text, or absent when the text is too short. Use it for the second letter of a code or the second item of a pair. Third works the same way for the position after.
-- but: deuxieme lettre d'un prenom, pour un classement
Clerk
Member name: Text
letter2 = second(name)
-> on Join by Clerk
show letter2 to Clerk within 1 s
example deuxieme lettre
m = Join(name: "Ana")
see m.letter2 = "n"
seen #
Gives the value that an observer has been shown: the second argument, read for the observer named first. Use it where a rule must state what someone else received, such as the altitude that a tower was sent by a plane, rather than the value the plane holds itself. The reference judge gives the second argument unchanged and models no delay in what is seen, so the example checks that reading and nothing more.
-- but: l'altitude d'un avion, telle que la tour la recoit
Clerk
Tower name: Text
Plane tower: Tower, height: Length
reported = seen(tower, height)
-> on Fly by Clerk
show reported to Clerk within 1 s
example altitude recue
t = Tower(name: "Orly")
p = Fly(tower: t, height: 300 m)
see p.reported = 300 m
sine #
Gives the sine of an angle, with the angle in degrees and not in radians: a quarter turn gives one. The result is a pure ratio. Some exact values do not come out exact: the sine of a half turn is a very small number rather than zero, so a rule that tests for an exact zero fails and should compare with a tolerance. Use it with cosine to turn a heading and a distance into a horizontal offset.
-- but: hauteur d'un rayon de lumiere sur un mur, selon l'angle de l'astre
Clerk
Beam angle: Angle
height = sine(angle)
-> on Aim by Clerk
show height to Clerk within 1 s
example un quart de tour
b = Aim(angle: 90 deg)
see b.height = 1
space #
True when the first character of a text is a space, a tab or a line break, and false for an empty text. Only the first character is read, so a blank further along the text does not count. It is the companion of letter and digit, which classify the first character in the same way. Use it to reject a value that starts with a blank.
-- but: une saisie commence-t-elle par un blanc ?
Clerk
Entry typed: Text
leading = space(typed)
-> on Enter by Clerk
show leading to Clerk within 1 s
example espace en tete
e = Enter(typed: " Ana")
see e.leading = true
f = Enter(typed: "Ana")
see f.leading = false
sqrt #
Gives the square root of a number: the side of a square whose area is given. The root of a plain count is a pure ratio, and the root of an area is a length, since the dimension is halved. A dimension that is not a square has no root type in the checker: the number is still computed, with its unit not checked, and a negative number has no real root, so a rule must not rely on a result for it. Use it to turn an area into a side, or a variance into a spread.
-- but: cote d'un carre dont on connait l'aire
Clerk
Plot area: Count 1..400
side = sqrt(area)
-> on Survey by Clerk
show side to Clerk within 1 s
example carre de seize
p = Survey(area: 16)
see p.side = 4
stable #
States that a value does not change during the run. Hector has no execution evidence for this guarantee yet: reading it gives Unknown and names the gap. It never certifies a changing value as stable.
take #
Gives the first k elements of a collection, or the first k characters of a text: the short code of a name, or the first items of a list. When the text or collection is shorter than k, the whole of it comes back, with no error to handle. A count below zero gives nothing. It is the companion of drop, which removes the same leading elements instead. Use it for codes, short labels and previews.
-- but: le code court d'un article : ses trois premieres lettres
Clerk
Item name: Text
code = take(name, 3)
-> on Label by Clerk
show code to Clerk within 1 s
example code court
i = Label(name: "Hector")
see i.code = "Hec"
third #
Gives the third element of a collection, or the third character of a text: the same reading as second, one place further. For a collection the result is optional, since a short collection has no third element; for a text it is a one-character text, or absent when the text is too short. Use it for the third letter of a code, or as a sort key on a name.
-- but: troisieme lettre d'un prenom, pour un classement
Clerk
Member name: Text
letter3 = third(name)
-> on Join by Clerk
show letter3 to Clerk within 1 s
example troisieme lettre
m = Join(name: "Hector")
see m.letter3 = "c"
uniform #
Draws a random number between two bounds, each value between them equally likely: a die of six faces draws between one and six, but the checker gives a real number, not a whole face. Like normal it is a draw, written with the tilde form for a start or a next value, because an ordinary definition would stay fixed. No example can state a draw by hand, so the example checks that the draw stays within its bounds.
-- but: un tirage de de a six faces : toujours entre un et six
Clerk
Die name: Text
start roll ~ uniform(1, 6)
-> on Cast by Clerk
show roll to Clerk within 1 s
example entre un et six
d = Cast(name: "D6")
see d.roll >= 1 and d.roll <= 6
unique #
Tells whether a row is the only one that holds a given value: unique(name) is true when no other row of the same sort has the same name. Written as a law, law unique(name) inside a sort, it refuses any row that would repeat the value, which is the usual way to forbid two records with the same code. As a value, it reads the rows at the moment of the reading, so the answer changes when another row is added. Use it to flag duplicates before a rule forbids them.
-- but: un nom porte-t-il deja un membre ?
Clerk
Member name: Text
alone = unique(name)
-> on Join by Clerk
example nom partage
a = Join(name: "Ana")
see a.alone = true
b = Join(name: "Ana")
see a.alone = false
see b.alone = false
Reservation resource: Text
status: Held | Released
-> Held on Reserve by Clerk
Held -> Released on Release by Clerk
law unique(resource) where Held
show status to Clerk
example une reservation par ressource tant qu elle est tenue
first = Reserve(resource: "desk")
refused Reserve(resource: "desk")
Release(first)
second = Reserve(resource: "desk")
see first is Released
see second is Held
unit #
Gives the direction of a vector as a unit vector: a vector of length one with no unit, pointing the same way. Read its components to aim a move along each axis, as the example does for a step of three and four metres. A zero vector has no direction, so the result is absent. Use it with a length to split a move into its direction and its size.
-- but: sens d'un deplacement, sans sa longueur
Clerk
Walk step: Vector m
heading = unit(step)
-> on Move by Clerk
show heading to Clerk within 1 s
example direction
w = Move(step: (3, 4) m)
see w.heading.x = 0.6
upper #
Gives the text in capital letters, the counterpart of lower: a label printed in capitals, or a code shown in a fixed form. The result is a text. An argument that is absent or not a text gives an absent result. Use it where a name must always appear in the same form on a document.
-- but: le nom d'un article affiche en capitales sur l'etiquette
Clerk
Label name: Text
shout = upper(name)
-> on Print by Clerk
show shout to Clerk within 1 s
example capitales
i = Print(name: "Ana")
see i.shout = "ANA"
visible #
Tells whether one point can see another: true when the second point is in view from the first. The reference judge answers true for every pair of points, so the example confirms only the open case, a point one metre from the origin, and no obstacle is modelled yet. The result is a truth value, usable as a condition in the where clause of a show. Use it to hide from one player what another cannot see.
-- but: un point est-il visible depuis un autre ?
Clerk
Spot pos: Point m
in_view = visible(pos, (0, 0) m)
-> on Place by Clerk
show in_view to Clerk within 1 s
example point proche
s = Place(pos: (1, 0) m)
see s.in_view = true
words #
Gives the words of a text as a list of lowercase words: each run of letters or digits, with punctuation, spaces and hyphens dropped between them. A note with five words and a hyphen gives five entries, which the example checks. Use length to count the words, or first to take the leading one. An absent text gives an absent list.
-- but: compter les mots d'une note libre, sans ponctuation
Clerk
Note text: Text
count = length(words(text))
first_word = first(words(text))
-> on Post by Clerk
show count, first_word to Clerk within 1 s
example cinq mots
n = Post(text: "Bonjour, Ana-Lee et Bob !")
see n.count = 5
see n.first_word = "bonjour"
year #
Gives the calendar year an instant falls in, as a whole number that stays the same for every instant of that year and goes up by one just after the turn. The reference judge cuts years at midnight UTC on the first of January, so an instant a few minutes before midnight on that day still belongs to the old year. Use it for a yearly report or to group records by year.
-- but: l'annee civile d'une facture, pour le classement annuel
Clerk
Invoice issued: Instant
fiscal_year = year(issued)
-> on Record by Clerk
show fiscal_year to Clerk within 1 s
example annee civile
f = Record(issued: 2026-12-31T23:30)
see f.fiscal_year = 2026
g = Record(issued: 2027-01-01T00:30)
see g.fiscal_year = 2027