Skip to content

Core

This package provides common algorithms and data structures.

{
"type": "library"
}
{
"dependencies": {
"Core": "pen:///core"
}
}

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.

Calculate bitwise “and” given two 64-bit integers.

\(x number, y number) number

Calculate bitwise “or” given two 64-bit integers.

\(x number, y number) number

Calculate bitwise exclusive-“or” given two 64-bit integers.

\(x number, y number) number

Calculate bitwise “not” given two 64-bit integers.

\(x number) number

Calculate unsigned left shift given a 64-bit integer.

\(x number, n number) number

Calculate unsigned right shift given a 64-bit integer.

\(x number, n number) number

Convert an integer in IEEE-754 to a 64-bit integer.

\(x number) number

Convert a 64-bit integer to an integer in IEEE-754.

\(x number) number

This module provides common boolean operations.

No types are defined.

Return true if any of given booleans are true or false otherwise.

\(bs [boolean]) boolean

Return true if all of given booleans are true or false otherwise.

\(bs [boolean]) boolean

No types are defined.

\(n number) string
\(s string) number

This module provides common list operations.

No types are defined.

Get the first element in a list. If a list is empty, it returns a fallback value.

\(xs [any], fallback any) any

Get the last element in a list. If a list is empty, it returns a fallback value.

\(xs [any], fallback any) any

Convert a list of an any type to one of a number type skipping non-number types.

\(xs [any]) [number]

Convert a list of an any type to one of a string type skipping non-string types.

\(xs [any]) [string]

Convert a list of an any type to one of a boolean type skipping non-boolean types.

\(xs [any]) [boolean]

This module provides common number operations.

No types are defined.

Calculate an absolute value.

\(x number) number

Calculate a ceil value.

\(x number) number

Machine epsilon

\() number

Calculate an exponential of a number.

\(x number) number

Calculate a floor value.

\(x number) number

Calculate a fraction value of a number.

\(x number) number

Infinity

\() number

Check if a number is NaN.

\(x number) boolean

Calculate a maximum.

\(x number, y number) number

Calculate a minimum.

\(x number, y number) number

NaN

\() number

Parse a number.

\(s string) number | error

Calculate a power.

\(base number, exponent number) number

Create a list of numbers from a minimum to a maximum.

\(minimum number, maximum number) [number]

Calculate a remainder.

\(dividend number, divisor number) number

Round a number.

\(x number) number

Create a list of numbers from 1 to a maximum value.

\(maximum number) [number]

Calculate a square root.

\(x number) number

Convert a number into its string representation.

\(x number) string

Sum up numbers.

\(xs [number]) number

Return an integer value of a number.

\(x number) number

This module provides common string operations.

No types are defined.

Concatenate strings.

\(strings [string]) string

Join strings with a separator.

\(strings [string], separator string) string

Check if a string starts with a pattern.

\(s string, prefix string) boolean

This module provides operations for strings as byte arrays.

No types are defined.

Return a length of a string.

\(s string) number

Slice a string.

\(s string, start number, end number) string

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 {
# ...
}

Create a view of a string.

\(s string) View

Get an original string.

\(v View) string

Get a start index of a view.

\(v View) number

Get an end index of a view.

\(v View) number

Check if a string starts with a pattern.

\(v View, s string) boolean

Get a length of a view.

\(v View) number

Move a start index forward.

\(v View, n number) View

Slice a view.

\(v View, start number, end number) View

Convert a view into a string.

\(v View) string

This module provides operations for strings encoded in UTF-8.

No types are defined.

Split a string into characters.

\(s string) [string]

Check if a string contains a pattern.

\(s string, pat string) boolean

Find an index for a pattern in a string.

\(s string, pat string) number | none

Checks if a string starts with a pattern..

\(s string, pat string) boolean

Checks if a string ends with a pattern..

\(s string, pat string) boolean

Return a length of a string.

\(s string) number

Replace a pattern in a string.

\(s string, pattern string, replacement string) string

Slice a string.

\(s string, start number, end number) string

Split a string by a pattern.

\(s string, pat string) [string]

Convert a string into lowercase.

\(s string) string

Convert a string into uppercase.

\(s string) string

Trim leading and trailing spaces.

\(s string) string

Trim trailing spaces.

\(s string) string

Trim trailing patterns.

\(s string, pat string) string

Trim leading and trailing patterns.

\(s string, pat string) string

Trim leading spaces.

\(s string) string

Trim leading patterns.

\(s string, pat string) string