Coem

Learn

Basic patterns to get you started.

Declaring a variable

To declare a variable:

let name be value

let begins the variable declaration. You can name the variable anything—try a noun! A special thing about names in this language is that you can use regular expressions in them.

Regular expressions

Regular expressions are a sequence of characters that specify a search pattern. With a regular expression, you can describe a range of strings instead of just one. Try the pipe operator, the plus operator, the question operator, and parentheses for grouping.

RegExr is a great resource to play around with different expressions.

Declaring a function

To declare a function:

to name:
     do things here.

to begins the function declaration. You can name it anything—try a verb! You can also use regular expressions for function names. The colon begins the block and the dot ends it.

Returning a value

To return a value from a function:

to name:
    & value.

The ampersand takes the place of the return keyword in other languages.

Writing comments

To write a comment:

 this is a comment

The dagger is a specialised character typically used to begin a footnote in literature, often when the asterisk has been used for a previous footnote on the same page. Here, it’s used in a similar context of denoting additional information as a comment in the code. The web editor gives an easy way to insert the symbol, but you can also type OptionT on Mac.

Describing a condition

To write an if statement:

ifcondition:
     do things if true.

To write a while statement:

whilecondition:
     do things while true.

If and while statements do things in their body if the condition given is true. The difference is that if statements will perform the action just once; while statements will keep checking the condition and performing the action as long as it’s true. Similar to the function, a colon begins the block and a dot ends it.

See some examples