Operators

See WebL Core Operators lists the operators belonging to the WebL core. To illustrate how operators are overloaded, we use a functional notation even though the operators are written in infix, prefix, or right-bracket fix. For example,

op(x: T, y: S): U

 

denotes that an infix operator op takes a first operand of x of type T and a second operand y of type S, and returns a value of type U. Unary operators have only a single argument to specify.

 

WebL Core Operators

Operator

Description

+(x: int, y: int): int
+(x: int, y: real): real
+(x: real, y: int): real
+(x: real, y: real): real

Numeric addition x + y.

+(x: char, y: string): string
+(x: char, y: char): string
+(x: string, y: string): string

String and character concatenation.

+(x: set, y: set): set

Set union.

+(x: list, y: list): list

List concatenation.

-(x: int, y: int): int
-(x: int, y: real): real
-(x: real, y: int): real
-(x: real, y: real): real

Numeric substraction.

-(x: int): int
-(x: real): real

Numeric negation.

-(x: set, y: set): set

Set exclusion.

*(x: int, y: int): real
*(x: int, y: real): real
*(x: real, y: int): real
*(x: real, y: real): real

Numeric multiplication.

*(x: set, y: set): set

Set intersection.

/(x: int, y: int): int
/(x: int, y: real): real
/(x: real, y: int): real
/(x: real, y: real): real

Numeric division.

div(x: int, y: int): int

Whole division.

mod(x: int, y: int): int

x mod y.

C(x: int, y: int): bool
C(x: int, y: real): bool
C(x: real, y: int): bool
C(x: real, y: real): bool

Numerical comparison, where C is one of <, <=, >, or >=.

C(x: string, y: string): bool
C(x: char, y: char): bool

Lexical comparison, where C is one of <, <=, >, or >=.

== (x, y): bool

Value equality test. See Value Equality

!=(x, y): bool

Value in-equality test. See Value Equality

or(x: bool, y: bool): bool
and(x: bool, y: bool): bool

Logical operators (Short-circuit evaluation).

!(x: bool): bool

Logical negation.

.(x: object, y): any

Object field access.

[](x: list, i: int): any
[](x: object, i): any
[](x: string, i: int): char

List, object, and string indexing 1 . Elements in a list and string are numbered from 0 to Size-1.

member(x, s: set): bool
member(x, l: list): bool
member(x, o: object): bool

Set, list and object 2 membership test.


1. Operator is written in the form x[i].

2. Object membership test is based on object field names.


Up Previous Next