Skip to content

Index of Module ln_core

Jonathan Chan edited this page Jun 12, 2018 · 83 revisions

Module: ln_core

The ln_core module provides basic functionality used by all applications. E.g. math routines, string manipulation routines, time routines, sorting algorithms, logging infrastructure, among others. This module is REQUIRED for most if not all application.

Functions in this module:

Function Short Description
(color-alpha x) Returns the alpha component of a given color
(color-blue x) Returns the blue component of a given color
(color-green x) Returns the green component of a given color
(color-red x) Returns the red component of a given color
(color-rgba r g b a) Constructs a color from given components (0-255), including transparency
(color-rgb r g b) Constructs a color from given components (0-255)
(color-rgbf r g b) Constructs a color from given components (0-1.)
(color-rgbaf r g b a) Constructs a color from given components (0-1.), including transparency
(color-gradient type value) Returns a color based on the gradient type
(color-mix c1 c2 w) Mix two colors in rgb space
(color-shade c w) Apply a weight to a color (shading)
(color-fade c f) Apply transparency to a color
(make-colorflutter color1 color2 transistiontime) Set up a fluttering (oscillating) colour based on the given two colors
(colorflutter idx) Return fluttering colors
(rgb->hsv rgb) Convert rbg list to hsv list (255 based)
(hsv->rgb hsv) Convert hsv list to rgb list (255 based)
(color-mixhsv c1 c2 w) Mix two colors in hsv space
(compress-file src dst) Compresses a file to a compressed file
(decompress-file src dst) Uncompresses a compressed file to a new file
(quick-compress src) Compresses a file
(quick-decompress dst) Uncompresses a file
(float->string x p) Convert number to string, specifying the maximum number of digits after the decimal point
(float->zeropaddedstring x p) Convert a number to string, specifying the exact number of digits after the decimal point
(float->choppedstring v p) Convert number to string, specifying the exact string-length
(fix n) Change a number to a fixed point value
(flo n) Change a number to a floating point value
(host-ipaddr . name) Returns host ip4 address as a u8vector
(ipaddr->string addr) Convert an u8vector ip4 to a string ip4 address
(foldr f base lst) Fold a list to the right
(scale lst k) Scales a list. (Multiply each element by k)
(offset lst k) Offsets a list (Adds k to each element)
(sum-of-squares lst) Sum of squares in a list
(sum lst) Sum list
(product lst) Product of a list
(mean lst) Mean of a list
(median lst) Median of a list
(first-quartile lst) Returns the first quartile of the list
(third-quartile lst) Returns the third quartile of the list
(interquartile lst) Difference between the first and third quartiles
(percentile lst prc) Obtain percentile value from list
(variance lst) Variance of a list
(std lst) Standard deviation of a list
(rms lst) Root mean square or quadratic mean of a list
(list-normalize lst) Normalize a list
(list-min lst) Smallest element of the list
(list-max lst) Largest element of a list
(list-diff lst) Calculate differences of list elements
(list-dot lst1 lst2) Calculate dot product/inner product of two lists
(list-notempty? lst) Checks if a list has at least one element
(list-fldot flst1 flst2) Calculate dot product of two lists of floats
(make-list n elem) Makes a list of n repeated elements
(list-head l k) Return the first n elements of list
(list-keep lst cnd) Return list element(s) that meet condition
(maps fcn lst) Behaves like map but removes empty lists
(list-interpolate lst x0) Interpolate list elements
(list-resample lst n) Resample a list by linear interpolation
(sublist lst start end) Returns a part of a list
(list-remove-duplicates lst) Removes duplicate elements from a list
(list-delete-item lst item) Remove an item from a list
(list-set! lst pos item) Replaces a list item
(list-pos lst element) Determine the position of an element in a list
(listlist? obj) Check if an object is a list of lists
(listlist-map m ll) Apply mapping to list of lists
(listlist-apply f ll) Apply a function to a list of lists
(listlist-transpose lst) Transpose a list of lists
(listlist-flatten lst) Flatten a list of lists
(listlist-add m1 m2) Add two matrices (list of lists)
(listlist-subtract m1 m2) Subtract matrix (list of lists) from matrix
(listlist-scale m n) Scale a matrix (list of lists) by value
(listlist-multiply m1 m2) Multiply two matrices (list of lists)
(listlist-determinant m) Return the determinant of a matrix (list of lists)
(listlist-cofactor m) Obtain the cofactor of a matrix (list of lists)
(listlist-inverse m) Invert a matrix (list of lists)
(listlist-ref m row col) Reference a value in a matrix (list of lists)
(listlist-set! m row col) Set a value in a matrix (list of lists)
(sort lst cmp) Sorts a list
(vector-map fcn vec . vectors) Map for vectors
(vector-foldr fcn base vec) Fold a vector to the right
(vector-scale vec k) Scales a vector (Multiply each element by k)
(vector-offset vec k) Offsets a vector (Adds k to each element)
(vector-sum vec) Sum of a vector
(vector-product vec) Product of a vector
(vector-mean vec) Mean of a vector
(vector-dot v1 v2) Dot product (inner product) of two vectors
(vector-diff vec) Calculate differences of vector elements
(log-debug s v . x) Log information with DEBUG prefix, if verbosity is sufficiently high
(log-error s . x) Log information with ERROR prefix
(log-status s . x) Log information with STATUS prefix
(log-system s . x) Log information with SYSTEM prefix
(log-warning s . x) Log information with WARNING prefix
(log-verbose n) Sets the minimum verbosity level for log-debug
(log-folder-cleanup) Internal use: Keeps only last 10 log files.
(log-trace thread) placeholder, please help expand!
(exception->string e) Convert an exception into readable string
(make-safe-thread p . name) Wrapper for (make-thread p . name) that catches exceptions
(logb x b) Returns the logarithm of x in base b
(log10 x) Returns the logarithm of x in base 10
(lg x) Returns the logarithm of x in base 2
(10log10 x) Returns 10 multiplied by logarithm of x in base 10
(20log10 x) Returns 20 multiplied by logarithm of x in base 10
(logsig x) Returns the floating point of a sigmoid function
(sign x) Returns the signs of a value
(inverse x) Returns the multiplicative inverse of x
(square x) Returns the square of x
(sinc x) Returns the value of sinus cardinal function
(acosh x) Returns the hyperbolic arcsine of x
(acot x) Returns the arccotangent of x
(acoth x) Returns the hyperbolic arccotangent of x
(acsc x) Returns the arccosecant of x
(acsch x) Returns the hyperbolic arccosecant of x
(asec x) Returns the arcsecant of x
(asech x) Returns the hyperbolic arcsecant of x
(asinh x) Returns the hyperbolic arcsine of x
(atanh x) Returns the hyperbolic arctangent of x
(cosh x) Returns the hyperbolic cosine of x
(cot x) Returns the cotangent of x
(coth x) Returns the hyperbolic cotangent of x
(csc x) Returns the cosecant of x
(csch x) Returns the hyperbolic cosecant of x
(sec x) Returns the secant of x
(sech x) Returns the hyperbolic secant of x
(sinh x) Returns the hyperbolic arcsine of x
(tanh x) Returns the hyperbolic tangent of x
(exact-round x) Returns the rounded value
(exact-floor x) Returns the rounded down value
(exact-ceiling x) Returns the rounded up value
(fmodulo x y) Returns the remainder on division of x/y
(ffloor x y) Floor relative to multiples of a float (ffloor+fmodulo = x)
(fceiling x y) Ceiling relative to multiples of a float (fceiling = ffloor + y)
(pos-lin x) placeholder, please help expand!
(lambda-fmodulo y) placeholder, please help expand!
(round-decimal num place) Round to decimal place
(packtool-unpack file cdata) Extract an embedded file at startup
(utf8string-length src) Returns length of UTF8 string
(utf8string->unicode src) Converts a UTF8 string to Unicode
(unicode->utf8string src) Converts a Unicode string to UTF8
(string-trim str) Removing spaces from start and end of string
(string-remove-quotes str) Removing quotation marks from start and end of string
(string-remove-spaces str) Removes all spaces from string
(string-remove-char str chr) Removes all occurrences of character chr from string
(string-split str sep) Split a string into a list at character sep
(string-upcase! str) Convert the original string to uppercase
(string-upcase str) Convert a string to uppercase
(string-downcase! str) Convert the original string to lowercase
(string-downcase str) Convert a string to lowercase
(string-capitalize! str) Convert the first letter of every word in the original string to an uppercase
(string-capitalize str) Convert the first letter of every word in a string to an uppercase
(string-explode str seplst) Split a string with multiple separators
(string-index str a-char . comp) Return the index of the first occurrence of a-char in str
(string-contains str pattern) Return the index of the first occurrence of pattern in str
(string-contains-ci str pattern) Return the index of the first case-insensitive occurrence of pattern in str
(string-count str pattern) Return the number of occurrences of pattern in str
(string-mapconcat sequence separator . proc) Return string concatenating the sequence after applying the optional procedure and separating the elements by separator
(string-replace-char str oldchr newchr) Replaces oldchr with newchr throughout a string
(string-replace-substring str searchstr replacestr) Replaces searchstr with replacestr throughout a string
(string-split-into-two str) Determines the best way to wrap a string between two lines. Minimizes the number of characters on each line.
(string-insert-at str s i) Inserts the string s after i characters in str (so the index of s in str will be i).
(string-prefix? pattern str) Checks if str begins with pattern.
(string-prefix-ci? pattern str) Checks if str begins with pattern case-insensitive.
(string-suffix? pattern str) Checks if str ends with pattern.
(string-suffix-ci? pattern str) Checks if str ends with pattern case-insensitive.
(sxml->xml lst . prt) Converts SXML to XML
(read-leap-second-table filename) SRFI-19: Updates the leap seconds table with a tai-utc.dat file
(copy-time time) SRFI-19: Creates a new time object, with the same time type, nanosecond, and second as time1
(current-seconds) Returns the number of seconds since 1970-01-01T00:00:00Z+00:00
(current-milliseconds) Returns the number of milliseconds since 1970-01-01T00:00:00Z+00:00
(current-time-tc . clock-type) Returns the current time in the clock type specified
(time-resolution . clock-type) SRFI-19: Clock resolution, in nanoseconds, of the system clock
(time=? time1 time2) SRFI-19: #t if time1 at (equal) time2
(time>? time1 time2) SRFI-19: #t if time1 is after (greater than) time2
(time<? time1 time2) SRFI-19: #t if time1 is before (less than) time2
(time>=? time1 time2) SRFI-19: #t if time1 is at or after (greater than or equal to) time2
(time<=? time1 time2) SRFI-19: #t if time1 is before or at (less than or equal to) time2
(time-difference time1 time2) SRFI-19: The time-duration between time1 and time2
(add-duration time1 duration) SRFI-19: The time resulting from adding time-duration to time1
(subtract-duration time1 duration) SRFI-19: The time resulting from subtracting time-duration to time1
(time-tai->time-utc time-in) SRFI-19: Convert TAI time to UTC time
(time-utc->time-tai time-in) SRFI-19: Convert UTC time to TAI time
(time-monotonic->time-utc time-in) SRFI-19: Convert monotonic time to UTC time
(time-monotonic->time-tai time-in) SRFI-19: Convert monotonic time to TAI time
(time-utc->time-monotonic time-in) SRFI-19: Convert UTC time to monotonic time
(time-tai->time-monotonic time-in) SRFI-19: Convert TAI time to monotonic time
(time-tai->date time . tz-offset) SRFI-19: Convert TAI time to date, using time zone offset
(time-utc->date time . tz-offset) SRFI-19: Convert UTC time to date, using time zone offset
(time-monotonic->date time . tz-offset) SRFI-19: Convert monotonic time to date, using time zone offset
(date->time-utc date) SRFI-19: Convert date to UTC time
(date->time-tai d) SRFI-19: Convert date to TAI time
(date->time-monotonic date) SRFI-19: Convert date to monotonic time
(leap-year? date) Test if a year is a leap year
(date-year-day date) SRFI-19: The ordinal day of the year of this date. January 1 is 1, etc
(date-week-day date) SRFI-19: The day of the week of this date, where Sunday=0
(date-week-number date day-of-week-starting-week) SRFI-19: The ordinal week of the year which holds this date, ignoring a first partial week
(current-date . tz-offset) SRFI-19: Date corresponding to the current UTC time
(date->julian-day date)] SRFI-19: Convert date to Julian Day
(date->modified-julian-day date) SRFI-19: Convert date to Modified Julian Day
(time-utc->julian-day time) SRFI-19: Convert UTC time to Julian Day
(time-utc->modified-julian-day time) SRFI-19: Convert UTC time to Modified Julian Day
(time-tai->julian-day time) SRFI-19: Convert TAI time to Julian Day
(time-tai->modified-julian-day time) SRFI-19: Convert TAI time to Modified Julian Day
(time-monotonic->julian-day time) SRFI-19: Convert monotonic time to Julian Day
(time-monotonic->modified-julian-day time) SRFI-19: Convert monotonic time to Modified Julian Day
(julian-day->time-utc jdn) SRFI-19: Convert Julian Day to UTC time
(julian-day->time-tai jdn) SRFI-19: Convert Julian Day to TAI time
(julian-day->time-monotonic jdn) SRFI-19: Convert Julian Day to monotonic time
(julian-day->date jdn . tz-offset) SRFI-19: Convert Julian Day to date, , using time zone offset
(modified-julian-day->date jdn . tz-offset) Convert Modified Julian Day to date, using time zone offset
(modified-julian-day->time-utc jdn) SRFI-19: Convert Modified Julian Day to UTC time
(modified-julian-day->time-tai jdn) SRFI-19: Convert Modified Julian Day to TAI time
(modified-julian-day->time-monotonic jdn) SRFI-19: Convert Modified Julian Day to monotonic time
(current-julian-day) SRFI-19: Current Julian Day
(current-modified-julian-day) SRFI-19: Current Modified Julian Day
(date->string date . format-string) SRFI-19: Converts a date to a string, using the format string
(string->date input-string template-string) SRFI-19: Converts an input string to a date, using the template string
(string->seconds str fmt . tz0) Convert a string with the given format into seconds
(seconds->string sec0 fmt . tz0) Convert seconds to string, specified in format
(localseconds->string sec fmt) Convert seconds to string, specified in format. Uses UTC, e.g. for relative times
(time->string t fmt) Convert time object to string
(secondselapsed->string arg1 . arg2) Returns time string in hh:mm:ss format
(time->timestamp arg1) Convert time to YYMMDD-hhmmss string
(seconds->timestamp arg1) Convert time in seconds to YYMMDD-hhmmss string
(current-time-seconds) Returns the current time in seconds (Unix epoch). Consider ##now instead
(function-exists? str) Tests if a function named str exists
(u8data) Create a u8data structure
(u8vector->u8data v . l) Convert a u8vector to u8data
(subu8data data start end) Create a subset of u8data
(u8data-skip data count) Jump to a point in u8data
(u8data-ref data idx) Look up a value at particular index in the u8data
(u8data-set! data idx val) Set u8data value
(u8data-length data) Return a u8data length
(u8data-u8 buf) Return an unsigned 8-bit integer
(u8data-s8 buf) Return an signed 8-bit integer
(u8data-u16 v) Return an unsigned 16-bit integer
(u8data-s16 buf) Return an signed 16-bit integer
(u8data-u32 v) Return an unsigned 32-bit integer
(u8data-s32 buf) Return a signed 32-bit integer
(u8data-le-u16 v) Return an unsigned little endian 16-bit integer
(u8data-le-s16 buf) Return a signed little endian 16-bit integer
(u8data-le-u32 v) Return an unsigned little endian 32-bit integer
(u8data-le-s32 buf) Return a signed little endian 32-bit integer
(u8data->u8vector data) Convert u8data to u8vector
(u8data-f32 u) Return a 32-bit floating point
(u8data-f64 u) Returns a 64-bit floating point
(u8vector-compress inbuf) Returns a compressed vector
(u8vector-decompress inbuf) Returns a decompressed vector
(u8vector-crc32 v) Return a 32bit cyclic redundancy checksum
(u8vector-crc16-ccitt v) Return a CCITT 16bit cyclic redundancy checksum
(u8vector-crc8 v) Return a 8bit cyclic redundancy checksum
(string->u8vector str) Convert a string to u8vector
(u8vector->string vec) Convert a u8vector to string. Terminates string at first #\0
(u8vector->file u8v filename) Write a u8vector to a file
(u8vector->u16 v . ofs) Convert a u8vector to an 16bit unsigned integer
(u8vector->u24 v . ofs) Convert a u8vector to an 24bit unsigned integer
(u8vector->u32 v . ofs) Convert a u8vector to an 32bit unsigned integer
(u8vector->u48 v . ofs) Convert a u8vector to an 48bit unsigned integer
(u8vector->u64 v . ofs) Convert a u8vector to an 64bit unsigned integer
(u8vector->u96 v . ofs) Convert a u8vector to an 96bit unsigned integer
(u16->u8vector v) Convert a 16bit unsigned integer to a u8vector
(u24->u8vector v) Convert a 24bit unsigned integer to a u8vector
(u32->u8vector v) Convert a 32bit unsigned integer to a u8vector
(u48->u8vector v) Convert a 48bit unsigned integer to a u8vector
(u64->u8vector v) Convert a 64bit unsigned integer to a u8vector
(u96->u8vector v) Convert a 96bit unsigned integer to a u8vector
(u8vector->s16 v . ofs) Convert a u8vector to an 16bit signed integer
(u8vector->s24 v . ofs) Convert a u8vector to an 24bit signed integer
(u8vector->s32 v . ofs) Convert a u8vector to an 32bit signed integer
(u8vector->s48 v . ofs) Convert a u8vector to an 48bit signed integer
(u8vector->s64 v . ofs) Convert a u8vector to an 64bit signed integer
(u8vector->s96 v . ofs) Convert a u8vector to an 96bit signed integer
(s16->u8vector v) Convert a 16bit signed integer to a u8vector
(s24->u8vector v) Convert a 24bit signed integer to a u8vector
(s32->u8vector v) Convert a 32bit signed integer to a u8vector
(s48->u8vector v) Convert a 48bit signed integer to a u8vector
(s64->u8vector v) Convert a 64bit signed integer to a u8vector
(s96->u8vector v) Convert a 96bit signed integer to a u8vector
(unit-test n . x) Add / run a unit-test
(unit-test-all) Run all registered unit tests
Clone this wiki locally