System Functions - Spicery/Nutmeg GitHub Wiki
The following is a list of system-functions that have been implemented along with short explanations of what they do.
- x:int - y:int -> int
- Returns the numerical difference of x and y
- object != object -> bool
- Not-equal-to
- m:int ... n:int -> range
- Closed range from m to n
- m:int ..< n:int -> range
- Half-open range from m to n, not including n
- Synonym for
...
- Synonym for
..<
- x:int * y:int -> int
- Computes the product of two numbers
- x:int + y:int -> int
- Computes the sum of two numbers
- x:iterable ++ y:iterable -> x:iterable
- Returns an iterable of the same type as x that iterates over the values of x and then y.
- x:int < y:int -> bool
- Numerical less-than operator
- x:int <= y:int -> bool
- Numerical less-than-or-equal-to operator
- object == object -> bool
- Structural equality
- x:int > y:int -> bool
- Numerical greater-than operator
- x:int >= y:int -> bool
- Numerical greater-than-or-equal-to operator
- int.AND(int) -> int
- bitwise AND of two ints
- x:int.LSHIFT( y:int ) -> int
- bitwise left-shift of x by y
- x:int.NOT -> int
- bitwise negation of x
- int.OR(int) -> int
- bitwise OR of two ints
- x:int.RSHIFT( y:int ) -> int
- bitwise right-shift of x by y
- int.XOR(int) -> int
- bitwise XOR of two ints
- contains( x:string, y:char ) -> bool
- contains( x:string, y:string ) -> bool
- String x contains character or string y as a substring
- x.dup( n ) -> ( x0, ..., xn )
- returns n shared instances of x
- endsWith( x:string, y:string ) -> bool
- String x ends-with string y
- x.get( int* ) -> char*
- Gets the i-th, j-th ... characters by position in x
- indexOf( x:string, y:char ) -> int
- indexOf( x:string, y:string ) -> int
- Finds where a char/string y appears in x
- isLowercase( char|string ) -> bool
- Returns true if the character is lowercase.
- Returns true if all cased characters of the string are lowercase.
- isUppercase( char|string ) -> bool
- Returns true if the character is uppercase.
- Returns true if all cased characters of the string are uppercase.
- sep:string.join( string, ... ) -> string
- Joins multiple strings together, separated by sep, into a single string
- length( x:string ) -> int
- Returns the length of a string
- lowercase( char|string ) -> char|string
- Converts a character or string to lowercase
- max( int+ ) -> int
- Finds the maximum of one or more ints.
- min( int+ ) -> int
- Finds the minimum of one or more ints.
- newString( x:string|char, ... ) -> string
- Constructs a new string from the supplied strings and characters
- not( bool ) -> bool
- Maps true to false and vice versa
- println( x, ... )
- Prints a series of values to stdout, suitable for formatting the output
- product( int* )
- Returns the product of ints, defaulting to 1 if there are no arguments.
- x:int.quot( y:int ) -> q:int
- Returns the integer quotient of x and y, defined as floor( x/y ).
- x:int.rem( y:int ) -> r:int • Returns the integer remainder of x/y, defined as x - y*floor( x/y ).
- showMe( x )
- Prints a faithful representation of x to stdout, suitable for developers e.g. strings gets quoted.
- string.split() -> string*
- Splits a string at whitespace boundaries into multiple strings
- When we figure out how to add in optional parameters we'll allow the separator to be specified.
- startsWith( x:string, y:string ) -> bool
- String x starts-with string y
- string.substring( (range|seq)* ) -> string
- Given a source string, composes a new string based on ranges over the source (or arbitrary sequences of positions)
- sum( int, ... ) -> int
- Finds the sum of the supplied numbers.
- If no numbers are supplied it returns zero.
- trim( string ) -> string
- Strips leading/trailing whitespace from a string.
- uppercase( char| string ) -> char|string
- Convert a character or string to an uppercase version.