Skip to content

Basics (type and operators)

AxelHumeau edited this page Jan 13, 2024 · 3 revisions

Types

In LobsterLang we have 5 types :

  • Int
  • Boolean
  • String
  • List
  • Function

Operators

Operations are stricly permetted to certains combination of types and only right-associative

-> denote the return type of the operator

Operators and the associated types are:

Unary operators

  • @ : any type -> String (to string)
  • ! : Boolean -> Boolean (boolean not)
  • ~ : List -> Int (length)

Binary operators

  • + : two Int -> Int (addition) or two String -> String (concatenation)
  • - : two Int -> Int (substraction)
  • * : two Int -> Int (multiplication)
  • / : two Int -> Int (division)
  • % : two Int -> Int (modulo)
  • == : two Int -> Boolean (equal)
  • != : two Int -> Boolean (not equal)
  • > : two Int -> Boolean (greater than)
  • >= : two Int -> Boolean (greater than or equal)
  • < : two Int -> Boolean (lesser than)
  • <= : two Int -> Boolean (lesser than or equal)
  • && : two Boolean -> Boolean (boolean and)
  • || : two Boolean -> Boolean (boolean or)
  • ^^ : two Boolean -> Boolean (boolean xor)
  • ++ : List and any type -> List (append)
  • -- : List and any type -> List (remove all occurences)
  • !! : List and Int -> any type (Get an element) or String and Int -> String (Get a substring of one character)
  • $ : two any type (then operator)

release

Documentation

Tests

Clone this wiki locally