Modules

This documents the certain modules in Jolf. For readability, each space will be replaced by an underscore. Use a space when coding.

Prototype module

These are constructed as (space)(character)(this)(arguments).

String prototypes

  • _F(string)(function) - foreach over string char-by-char with function.
  • _E(string) - String replace. (NOTE: Use ρ to save a byte.)
  • _i(string)(thing) - string.indexOf(thing).
  • _h(string1)(string2) - regex search for string2 in string1; returns true if the string is found.
  • _s(string)(thing) - searches string for thing; literally string.search(thing).
  • _l(string)(bottom)(top) - slices string from bottom to top; string.slice(bottom,top).
  • _L(string)(index) - string.slice(index).
  • _S(string)(function) - maps string with function.
  • _m(string)(regex as string)(flags OR "g") - matches string according to the regex and flags; string.match(new RegExp(m,o||"g")).
  • _M(string)(regex as string)(flags) - _m, but with mandatory flags.
  • _r(string) - trims string (removes leading and trailing whitespace).
  • _R(string) - reverses string. (NOTE: Use _(string), with a literal underscore, to save a byte.)
  • _`(string)(index) - the indexth character in string.

Array prototypes

  • _e(array)(function) - checks if every value in array "satisfies" function. (Array.every.)
  • _f(array)(function) - filter array.
  • _F(array)(function) - array foreach.
  • _h(array)(element) - membership in array.
  • _i(array)(thing) - indexof thing in array.
  • _r(array) - random element.
  • _R(array) - reverse. (NOTE: use _(array) (literal underscore) to reverse an array.)
  • _p(array) - pops element from array. (NOTE: use Χ (uppercase Chi) to pop an element from an array.)
  • _s(array) - shifts element from array. (NOTE: use χ (lowercase Chi) to shift an element from an array.)
  • _S(array) - shuffles an array.
  • _l and _L - slice an array with 2 and 1 arguments, respectively.
  • _m(array)(thing) - if thing is a function, function map. Otherwise, tries using thing as jolf then regular JS code. Otherwise, tries to pawn you off to another language.
  • _`(array)(value) - fill array with value.

mathjs module

Called with ! + char.

Array Z module

These are called Z<char> in the program. Currently an incomplete list.

  • a (Za<numA><numB>) - makes an array filled with numA of length numB. Literally, Zb*[J]j (if J = numA and j = numB).
  • A (ZA<num>) - makes a zero array of length num. Compare to Za0<num> and Zb*[0]j.
  • b (Zb<array>) - returns the big union of the array, i.e., flattening the array.
  • B (ZB<arrayA><arrayB>) - returns the intersection of two arrays.
  • c (Zc<array><num>) - returns array chopped into subarrays of length num. For example, Zc[1,2,3,4,5]2 yields [[1,2],[3,4],[5]].
  • C (ZC<array>) - returns the cumulative summation of array. For example, ZC[1,2,3,4,5] yields [1,1+2,1+2+3,1+2+3+4,1+2+3+4+5] = [1,3,6,10,15].
  • d (Zd<array>) - returns the differences between the indices of array. For example, Zd[1,5,2,3] yields [4,-3,1].
  • D (ZD<str>) - converts str into an array of digts.
  • e (Ze<array><num>) - returns all entries of length num in array.
  • E (ZE<array><num>) - returns all entries not of length num in array.
  • f (Zf<array>) - flattens an array.
  • F (ZF<array><num>) - flattens an array, but only to a certain depth num.
  • g (Zg<array>) - returns cumulative product on array. See ZC.
  • G (ZG<array><func><num>) - cumulatively reduces array over the function func with a starting point num.
  • h (Zh<any>) - returns "all but the last entry of" any. (For a number, it chops of the last digit.)
  • H (ZH<any>) - returns "all but the first of" any. Compare Zh.
  • i (Zi<str>) - returns strs lines, but reversed and joined.
  • I - unassigned
  • j (Zj<any><num>) - returns "all but the last N" of any. Compare Zh.
  • J (ZJ<any><num>) - returns "all but the first N" of any. Compare Zh.
  • k (Zk<array>) - returns the minimal element of array.
  • K (ZK<array>) - returns the maximal element of array. (TBA)