Functions and Operators

Function syntax

All built-in standard library functions are reflected as functions in e.

  1. e.str_upper(e.str("hello"));
  2. // str_upper("hello")
  3. e.op(e.int64(2), '+', e.int64(2));
  4. // 2 + 2
  5. const nums = e.set(e.int64(3), e.int64(5), e.int64(7))
  6. e.op(e.int64(4), 'in', nums);
  7. // 4 in {3, 5, 7}
  8. e.math.mean(nums);
  9. // math::mean({3, 5, 7})

Prefix operators

Unlike functions, operators do not correspond to a top-level function on the e object. Instead, they are expressed with the e.op function.

Prefix operators operate on a single argument: OPERATOR <arg>.

  1. e.op('not', e.bool(true)); // not true
  2. e.op('exists', e.set('hi')); // exists {'hi'}
  3. e.op('distinct', e.set('hi', 'hi')); // distinct {'hi', 'hi'}

“exists” “distinct” “not”

Infix operators

Infix operators operate on two arguments: <arg> OPERATOR <arg>.

  1. e.op(e.str('Hello '), '++', e.str('World!'));
  2. // 'Hello ' ++ 'World!'

“=” “?=” “!=” “?!=” “>=” “>” “<=” “<” “or” “and” “+” “-“ “*” “/“ “//“ “%” “^” “in” “not in” “union” “??” “++” “like” “ilike” “not like” “not ilike”

Ternary operators

Ternary operators operate on three arguments: <arg> OPERATOR <arg> OPERATOR <arg>. Currently there’s only one ternary operator: the if else statement.

  1. e.op(e.str('😄'), 'if', e.bool(true), 'else', e.str('😢'));
  2. // 😄 if true else 😢