-
Notifications
You must be signed in to change notification settings - Fork 5
LRM Standard Library Functions
Bahul Jain edited this page Feb 27, 2016
·
2 revisions
JSJS provides a simple set of standard library functions to perform basic operations on lists, maps and work with standard input/output. By default, all the following libraries are automatically available.
The awesome List
module provides essential functions to do basic operations on lists:
-
List.hd
: Returns the head of the list. -
List.tl
: Returns a list without the head of the original list. -
List.cons
: Appends an element to the head of the list. -
List.length
: Returns the total number of elements in the list. -
List.nth
: Returns the nth element of the list. -
List.contains?
: Return true if a given element exists in the list, else returns false. -
List.isEmpty?
: Return true if the list does not contain any elements, else returns false. -
List.rev
: Reverses the given list.
The awesome Map
module provides essential functions to do basic operations on maps:
-
Map.set
: Adds an entry in a map. -
Map.get
: Returns a value given the key from a map. -
Map.remove
: Returns a map after removing key from a map. -
Map.clear
: Removes all entries of the map.
The String
module is provided to assist users with string manipulation:
-
String.length
: Returns the length of the string -
String.concat
: Concatenates two strings -
String.substring
: Returns a substring of the given string
The IO
module is used to interact with the standard IO
-
IO.print
: Display on standard output -
IO.println
: Display on standard output, followed by a new line character. -
IO.read
: Reads contents from standard input.
JSJS © 2016