deck-beaufort/src/beaufort.j
def const LIMITS as list of int init [1, 6, 12, 20, 29, 39, 50, 62, 75, 89, 103, 118];
export func force(kmh as int) {
if ($kmh < 0) {
throw Error{kind: "beaufort", message: "beaufort: negative speed"};
}
def f as int init 0;
while ($f < 12 and $kmh >= LIMITS[$f]) {
$f = $f + 1;
}
return $f;
}