str Module

%

% interpolate

See interpolate.

=%

=% apply-interpolate

See apply-interpolate.

=~

=~ regex

See regex.

apply-interpolate

str quot str

The same as pushing apply and then interpolate on the stack.

capitalize

'sym str

Returns a copy of 'sym with the first character capitalized.

chr

int str

Returns the single character str obtained by interpreting int as an ASCII code.

escape

'sym str

Returns a copy of 'sym with quotes and backslashes escaped with a backslash.

from-semver

str dict

Given a basic SemVer-compliant string (with no additional labels) str, it pushes a dictionary dict on the stack containing a major, minor, and patch key/value pairs.

indent

'sym int str

Returns str containing 'sym indented with int spaces.

indexof

str1 str2 int

If str2 is contained in str1, returns the index of the first match or -1 if no match is found.

interpolate

str quot str

Substitutes the placeholders included in str with the values in quot.

Notes

  • If quot contains symbols or quotations, they are not interpreted. To do so, call apply before interpolating or use apply-interpolate instead.
  • You can use the $# placeholder to indicate the next placeholder that has not been already referenced in the string.
  • You can use named placeholders like $pwd, but in this case quot must contain a quotation containing both the placeholder names (odd items) and the values (even items).

join

quot 'sym str

Joins the elements of quot using separator 'sym, producing str.

length

'sym int

Returns the length of 'sym.

lowercase

'sym str

Returns a copy of 'sym converted to lowercase.

match?

str1 str2 bool

Returns true if str2 matches str1, false otherwise.

ord

str int

Returns the ASCII code int corresponding to the single character str.

parse-url

str dict:url

Parses the url str into its components and stores them into dict:url.

prefix

'sym1 'sym2 str

Prepends 'sym2 to 'sym1.

repeat

'sym int str

Returns str containing 'sym repeated int times.

replace

str1 str2 str3 str4

Returns a copy of str1 containing all occurrences of str2 replaced by str3

replace-apply

str1 str2 quot str3

Returns a copy of str1 containing all occurrences of str2 replaced by applying quot to each quotation correponding to each match.

search

str1 str2 quot

Returns a quotation containing the first occurrence of str2 within str1. Note that:

  • The first element of quot is the matching substring.
  • Other elements (if any) contain captured substrings.
  • If no matches are found, the quotation contains empty strings.

search-all

str1 str2 quot

Returns a quotation of quotations (like the one returned by the search operator) containing all occurrences of str2 within str1.

semver-inc-major

str1 str2

Increments the major digit of the SemVer-compliant string (with no additional labels) str1.

semver-inc-minor

str1 str2

Increments the minor digit of the SemVer-compliant string (with no additional labels) str1.

semver-inc-patch

str1 str2

Increments the patch digit of the SemVer-compliant string (with no additional labels) str1.

semver?

str bool

Checks whether str is a SemVer-compliant version or not.

split

'sym1 'sym2 quot

Splits 'sym1 using separator 'sym2 (a Perl Compatible Regular Expression) and returns the resulting strings within the quotation quot.

strip

'sym str

Returns str, which is set to 'sym with leading and trailing spaces removed.

substr

str1 int1 int2 str2

Returns a substring str2 obtained by retriving int2 characters starting from index int1 within str1.

suffix

'sym1 'sym2 str

Appends 'sym2 to 'sym1.

titleize

'sym str

Returns a copy of 'sym in which the first character of each word is capitalized.

to-semver

dict str

Given a a dictionary dict containing a major, minor, and patch key/value pairs , it pushes a basic SemVer-compliant string (with no additional labels) str on the stack.

uppercase

'sym1 'sym2

Returns a copy of 'sym converted to uppercase.