Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Lists, text, and numbers

Romit scripts have lists, decimals, and text building, all without brackets.

Text

+ or plus joins text, and {…} inside a string inserts any value:

name = "Ada"
say "Hello, " + name
say "Hi {name}, you have {count of tasks} tasks"

Write {{ or }} for a literal brace. (Braces are only allowed inside text. Code structure still uses indentation.)

Numbers

Whole numbers stay whole, and anything else becomes a decimal:

say 7 / 2        # 3.5
say 6 / 2        # 3
say 0.1 + 0.2    # 0.3
say round 3.14159, 2

Lists

groceries = list "milk", "eggs"
add "bread" to groceries
remove "eggs" from groceries
empty = list

for each item in groceries
  say "- {item}"

say count of groceries
say first of groceries
say item 2 of groceries          # positions start at 1
if groceries contains "milk"
  say "got milk"
say join groceries, ", "

Built-in functions

Call them like any function (sort nums) or with of (sum of nums).

FunctionDoes
list a, b, cmake a list
count, size, lengthitems in a list, or letters in text
first, last, item N ofpick items
sum, average, min, maxmath over a list
sort, reverse, uniquenew reordered or de-duplicated list
join list, sep, split text, sepbetween lists and text
upper, lower, trim, text, numbertext helpers
round x, places, floor, ceil, abs, sqrtnumber helpers
range a, b, random a, bnumber ranges

Changing values

score = 0
score += 10
score -= 2
increase score by 5
decrease lives

Loops

stop leaves a loop early and skip jumps to the next pass:

for each n in 1 to 100
  if n remainder 2 is 0
    skip
  if n is above 9
    stop
  say n

More

Records, maps, where / each / grouped by, match, try, ask, enums, dates and use are covered in Records, match, and errors.

Comments

# a comment
note also a comment
say "hi"   # comments can end a line too