-
Notifications
You must be signed in to change notification settings - Fork 0
Standard library jcore
tbd...
The stdlib module offers basic functions, which can be usable anytime.
A simple wrapper for the print function with a newline at the end.
Converts a list of elements in its stringified form. Usually, one would use this to convert a list of characters into a string.
The math module offers functions for often used math functions.
Returns the bigger number from two given numbers.
Returns the smaller number from two given numbers.
Returns absolute (positive) value of a given number representing its distance from zero.
Returns the power of a base raised to an exponent using the efficient Binary Exponentiation (Square-and-Multiply) algorithm in O(log n) time.
Returns the approximated n-th root of a radicand (x) using Newton's Method. Returns nil by
- zero root (n == 0)
- an even root of a negative number
- a division by zero
This algorithm uses floating-point numbers, which inherently cause small precision errors due to the binary representation of decimal fractions under IEEE 754 standard. If you check the results of this, you are advides to use an approximation.
Returns the square root (2nd root) of a non-negative number using the internal implementation of root(x: number, n: number).
Returns the calculated fibonacci number using a simple loop approach, which is not optimized (yet).
Returns true if a given number is a prime number. Implements an optimized implementation using wheel factorization.
The date module offers functions for date manipulation. Please note that this module does not support handling timezones. For passing and processing dates, a date struct is offered, containing fields for year, month and day.
Returns true, if the passed year is a leap year.
Accepts unix time seconds and calculates based on these a date struct containing the corresponding day in time. The function supports negative unix time seconds for handling date before the 01.01.1970.
Accepts a date struct and calculates based on this a number of seconds since unix time. If the passed date if before unix time, the number of elapsed seconds will be negative.
A simple function for pretty printing a date struct.
Override the print function for pretty printing dates.
Override the printLine function for pretty printing dates with a newline.