Skip to content

Instantly share code, notes, and snippets.

@marksim
Created August 5, 2013 15:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marksim/6156871 to your computer and use it in GitHub Desktop.
Save marksim/6156871 to your computer and use it in GitHub Desktop.

The Erlang VM only allows a limited set of expressions as guards:

  • comparison operators (==, !=, ===, !==, >, <, <=, >=);

  • boolean operators (and, or) and negation operators (not, !);

  • arithmetic operators (+, -, *, /);

  • <> and ++ as long as the left side is a literal;

  • the in operator;

  • all the following type check functions:

    • is_atom/1
    • is_binary/1
    • is_bitstring/1
    • is_boolean/1
    • is_float/1
    • is_function/1
    • is_function/2
    • is_integer/1
    • is_list/1
    • is_number/1
    • is_pid/1
    • is_port/1
    • is_record/2
    • is_record/3
    • is_reference/1
    • is_tuple/1
    • is_exception/1
  • plus these functions:

    • abs(Number)
    • bit_size(Bitstring)
    • byte_size(Bitstring)
    • div(Number, Number)
    • elem(Tuple, n)
    • float(Term)
    • hd(List)
    • length(List)
    • node()
    • node(Pid|Ref|Port)
    • rem(Number, Number)
    • round(Number)
    • self()
    • size(Tuple|Bitstring)
    • tl(List)
    • trunc(Number)
    • tuple_size(Tuple)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment