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

"[x...y]"

  • Synonym for ...

"[x..<y]"

  • 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

"AND"

  • int.AND(int) -> int
  • bitwise AND of two ints

"LSHIFT"

  • x:int.LSHIFT( y:int ) -> int
  • bitwise left-shift of x by y

"NOT"

  • x:int.NOT -> int
  • bitwise negation of x

"OR"

  • int.OR(int) -> int
  • bitwise OR of two ints

"RSHIFT"

  • x:int.RSHIFT( y:int ) -> int
  • bitwise right-shift of x by y

"XOR"

  • int.XOR(int) -> int
  • bitwise XOR of two ints

"contains"

  • contains( x:string, y:char ) -> bool
  • contains( x:string, y:string ) -> bool
  • String x contains character or string y as a substring

"dup"

  • x.dup( n ) -> ( x0, ..., xn )
  • returns n shared instances of x

"endsWith"

  • endsWith( x:string, y:string ) -> bool
  • String x ends-with string y

"get"

  • x.get( int* ) -> char*
  • Gets the i-th, j-th ... characters by position in x

"indexOf"

  • indexOf( x:string, y:char ) -> int
  • indexOf( x:string, y:string ) -> int
  • Finds where a char/string y appears in x

"isLowercase"

  • isLowercase( char|string ) -> bool
  • Returns true if the character is lowercase.
  • Returns true if all cased characters of the string are lowercase.

"isUppercase"

  • isUppercase( char|string ) -> bool
  • Returns true if the character is uppercase.
  • Returns true if all cased characters of the string are uppercase.

"join"

  • sep:string.join( string, ... ) -> string
  • Joins multiple strings together, separated by sep, into a single string

"length"

  • length( x:string ) -> int
  • Returns the length of a string

"lowercase"

  • lowercase( char|string ) -> char|string
  • Converts a character or string to lowercase

"max"

  • max( int+ ) -> int
  • Finds the maximum of one or more ints.

"min"

  • min( int+ ) -> int
  • Finds the minimum of one or more ints.

"newString"

  • newString( x:string|char, ... ) -> string
  • Constructs a new string from the supplied strings and characters

"not"

  • not( bool ) -> bool
  • Maps true to false and vice versa

"println"

  • println( x, ... )
  • Prints a series of values to stdout, suitable for formatting the output

"product"

  • product( int* )
  • Returns the product of ints, defaulting to 1 if there are no arguments.

"quot"

  • x:int.quot( y:int ) -> q:int
  • Returns the integer quotient of x and y, defined as floor( x/y ).

"rem"

  • x:int.rem( y:int ) -> r:int • Returns the integer remainder of x/y, defined as x - y*floor( x/y ).

"showMe"

  • showMe( x )
  • Prints a faithful representation of x to stdout, suitable for developers e.g. strings gets quoted.

"split"

  • 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"

  • startsWith( x:string, y:string ) -> bool
  • String x starts-with string y

"substring"

  • 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"

  • sum( int, ... ) -> int
  • Finds the sum of the supplied numbers.
  • If no numbers are supplied it returns zero.

"trim"

  • trim( string ) -> string
  • Strips leading/trailing whitespace from a string.

"uppercase"

  • uppercase( char| string ) -> char|string
  • Convert a character or string to an uppercase version.
⚠️ **GitHub.com Fallback** ⚠️