Core
This package provides common algorithms and data structures.
{ "type": "library"}Install
Section titled “Install”{ "dependencies": { "Core": "pen:///core" }}Core'Bit module
Section titled “Core'Bit module”This module provides bitwise operations.
Most functions defined in this module take arguments of 64-bit integers.
They can be converted from and into integers represented in IEEE-754 of a
number type.
No types are defined.
Functions
Section titled “Functions”Calculate bitwise “and” given two 64-bit integers.
\(x number, y number) numberCalculate bitwise “or” given two 64-bit integers.
\(x number, y number) numberCalculate bitwise exclusive-“or” given two 64-bit integers.
\(x number, y number) numberCalculate bitwise “not” given two 64-bit integers.
\(x number) numberLeftShift
Section titled “LeftShift”Calculate unsigned left shift given a 64-bit integer.
\(x number, n number) numberRightShift
Section titled “RightShift”Calculate unsigned right shift given a 64-bit integer.
\(x number, n number) numberToInteger64
Section titled “ToInteger64”Convert an integer in IEEE-754 to a 64-bit integer.
\(x number) numberFromInteger64
Section titled “FromInteger64”Convert a 64-bit integer to an integer in IEEE-754.
\(x number) numberCore'Boolean module
Section titled “Core'Boolean module”This module provides common boolean operations.
No types are defined.
Functions
Section titled “Functions”Return true if any of given booleans are true or false otherwise.
\(bs [boolean]) booleanReturn true if all of given booleans are true or false otherwise.
\(bs [boolean]) booleanCore'Character module
Section titled “Core'Character module”No types are defined.
Functions
Section titled “Functions”FromCodePoint
Section titled “FromCodePoint”\(n number) stringToCodePoint
Section titled “ToCodePoint”\(s string) numberCore'List module
Section titled “Core'List module”This module provides common list operations.
No types are defined.
Functions
Section titled “Functions”Get the first element in a list. If a list is empty, it returns a fallback value.
\(xs [any], fallback any) anyGet the last element in a list. If a list is empty, it returns a fallback value.
\(xs [any], fallback any) anyToNumbers
Section titled “ToNumbers”Convert a list of an any type to one of a number type skipping non-number types.
\(xs [any]) [number]ToStrings
Section titled “ToStrings”Convert a list of an any type to one of a string type skipping non-string types.
\(xs [any]) [string]ToBooleans
Section titled “ToBooleans”Convert a list of an any type to one of a boolean type skipping non-boolean types.
\(xs [any]) [boolean]Core'Number module
Section titled “Core'Number module”This module provides common number operations.
No types are defined.
Functions
Section titled “Functions”Absolute
Section titled “Absolute”Calculate an absolute value.
\(x number) numberCalculate a ceil value.
\(x number) numberEpsilon
Section titled “Epsilon”Machine epsilon
\() numberExponential
Section titled “Exponential”Calculate an exponential of a number.
\(x number) numberCalculate a floor value.
\(x number) numberFraction
Section titled “Fraction”Calculate a fraction value of a number.
\(x number) numberInfinity
Section titled “Infinity”Infinity
\() numberCheck if a number is NaN.
\(x number) booleanMaximum
Section titled “Maximum”Calculate a maximum.
\(x number, y number) numberMinimum
Section titled “Minimum”Calculate a minimum.
\(x number, y number) numberNaN
\() numberParse a number.
\(s string) number | errorCalculate a power.
\(base number, exponent number) numberCreate a list of numbers from a minimum to a maximum.
\(minimum number, maximum number) [number]Remainder
Section titled “Remainder”Calculate a remainder.
\(dividend number, divisor number) numberRound a number.
\(x number) numberSequence
Section titled “Sequence”Create a list of numbers from 1 to a maximum value.
\(maximum number) [number]SquareRoot
Section titled “SquareRoot”Calculate a square root.
\(x number) numberString
Section titled “String”Convert a number into its string representation.
\(x number) stringSum up numbers.
\(xs [number]) numberTruncate
Section titled “Truncate”Return an integer value of a number.
\(x number) numberCore'String module
Section titled “Core'String module”This module provides common string operations.
No types are defined.
Functions
Section titled “Functions”Concatenate
Section titled “Concatenate”Concatenate strings.
\(strings [string]) stringJoin strings with a separator.
\(strings [string], separator string) stringStartsWith
Section titled “StartsWith”Check if a string starts with a pattern.
\(s string, prefix string) booleanCore'String'Byte module
Section titled “Core'String'Byte module”This module provides operations for strings as byte arrays.
No types are defined.
Functions
Section titled “Functions”Length
Section titled “Length”Return a length of a string.
\(s string) numberSlice a string.
\(s string, start number, end number) stringCore'String'Byte'View module
Section titled “Core'String'Byte'View module”This module provides views of strings as byte arrays. By using those views, you can apply operations to strings without copying them.
A view of a string
type View { # ...}Functions
Section titled “Functions”Create a view of a string.
\(s string) ViewViewee
Section titled “Viewee”Get an original string.
\(v View) stringGet a start index of a view.
\(v View) numberGet an end index of a view.
\(v View) numberStartsWith
Section titled “StartsWith”Check if a string starts with a pattern.
\(v View, s string) booleanLength
Section titled “Length”Get a length of a view.
\(v View) numberMove a start index forward.
\(v View, n number) ViewSlice a view.
\(v View, start number, end number) ViewToString
Section titled “ToString”Convert a view into a string.
\(v View) stringCore'String'Utf8 module
Section titled “Core'String'Utf8 module”This module provides operations for strings encoded in UTF-8.
No types are defined.
Functions
Section titled “Functions”Characters
Section titled “Characters”Split a string into characters.
\(s string) [string]Contains
Section titled “Contains”Check if a string contains a pattern.
\(s string, pat string) booleanFind an index for a pattern in a string.
\(s string, pat string) number | noneStartsWith
Section titled “StartsWith”Checks if a string starts with a pattern..
\(s string, pat string) booleanEndsWith
Section titled “EndsWith”Checks if a string ends with a pattern..
\(s string, pat string) booleanLength
Section titled “Length”Return a length of a string.
\(s string) numberReplace
Section titled “Replace”Replace a pattern in a string.
\(s string, pattern string, replacement string) stringSlice a string.
\(s string, start number, end number) stringSplit a string by a pattern.
\(s string, pat string) [string]ToLowercase
Section titled “ToLowercase”Convert a string into lowercase.
\(s string) stringToUppercase
Section titled “ToUppercase”Convert a string into uppercase.
\(s string) stringTrim leading and trailing spaces.
\(s string) stringTrimEnd
Section titled “TrimEnd”Trim trailing spaces.
\(s string) stringTrimEndMatches
Section titled “TrimEndMatches”Trim trailing patterns.
\(s string, pat string) stringTrimMatches
Section titled “TrimMatches”Trim leading and trailing patterns.
\(s string, pat string) stringTrimStart
Section titled “TrimStart”Trim leading spaces.
\(s string) stringTrimStartMatches
Section titled “TrimStartMatches”Trim leading patterns.
\(s string, pat string) string