all repos — min @ 315dd472cf35599d304de68aabe108b2c1903232

A small but practical concatenative programming language.

site/contents/_includes/_reference-str.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
{@ _defs_.md || 0 @}

{#alias||%||interpolate#}

{#alias||=~||regex#}

{#op||capitalize||{{sl}}||{{s}}||
Returns a copy of {{sl}} with the first character capitalized.#}

{#op||indent||{{sl}} {{i}}||{{s}}||
Returns {{s}} containing {{sl}} indented with {{i}} spaces.#}

{#op||indexof||{{s1}} {{s2}}||{{i}}||
If {{s2}} is contained in {{s1}}, returns the index of the first match or -1 if no match is found. #}

{#op||interpolate||{{s}} {{q}}||{{s}}||
> Substitutes the placeholders included in {{s}} with the values in {{q}}.
> > %note%
> > Note
> > 
> > If {{q}} contains symbols or quotations, they are not interpreted. To do so, call `apply` before interpolating. 
> 
> > %sidebar%
> > Example
> >  
> > The following code (executed in a directory called '/Users/h3rald/Development/min' containing 19 files):
> > 
> > `"Directory '$1' includes $2 files." (. (. ls 'file? filter size)) apply interpolate`
> > 
> > produces:
> > 
> > `"Directory '/Users/h3rald/Development/min' includes 19 files."`#}

{#op||join||{{q}} {{sl}}||{{s}}||
Joins the elements of {{q}} using separator {{sl}}, producing {{s}}.#}

{#op||length||{{sl}}||{{i}}||
Returns the length of {{sl}}.#}

{#op||lowercase||{{sl}}||{{s}}||
Returns a copy of {{sl}} converted to lowercase.#}

{#op||match||{{s1}} {{s2}}||{{b}}||
> Returns {{t}} if {{s2}} matches {{s1}}, {{f}} otherwise.
> > %tip%
> > Tip
> > 
> > {{s2}} can be a {{sgregex}}-compatible regular expression.#}

{#op||repeat||{{sl}} {{i}}||{{s}}||
Returns {{s}} containing {{sl}} repeated {{i}} times.#}

{#op||replace||{{s1}} {{s2}} {{s3}}||{{s4}}||
> Returns a copy of {{s1}} containing all occurrences of {{s2}} replaced by {{s3}}
> > %tip%
> > Tip
> > 
> > {{s2}} can be a {{sgregex}}-compatible regular expression.
> 
> > %sidebar%
> > Example
> > 
> > The following:
> > 
> > `"This is a stupid test. Is it really a stupid test?" " s[a-z]+" " simple" replace`
> > 
> > produces: `"This is a simple test. Is it really a simple test?"`#}

{#op||regex||{{s1}} {{s2}}||{{q}}||
> Performs a search and/or a search-and-replace operation using pattern {{s2}}.
> 
> {{s2}} can be one of the following patterns:
> 
>   * **/**_search-regex_**/**_modifiers_
>   * **s/**_search-regex_**/**_replacemenet_**/**_modifiers_
> 
> {{q}} is always a quotation containing:
> 
>   * One or more strings containing the first match and captures (if any), like for the `search` operator.
>   * A string containing the resuling string after the search-and-replace operation.
> 
> > %tip%
> > Tip
> > 
> > * _search-regex_ can be a {{sgregex}}-compatible regular expression.
> > * _modifiers_ are optionals can contain one or more of the following characters, in any order:
> >   * **i**: case-insensitive match.
> >   * **m**: multi-line match.
> >   * **s**: dot character includes newlines.
> 
> > %sidebar%
> > Example: Search
> > 
> > The following:
> > 
> > `"This is a GOOD idea." "/(good) idea/i" regex`
> > 
> > produces: `("GOOD idea", "GOOD")`
> 
> > %sidebar%
> > Example: Search and Replace
> > 
> > The following:
> > 
> > `"This is a GOOD idea." "s/good/bad/i" regex`
> > 
> > produces: `("This is a bad idea")`#}

{#op||search||{{s1}} {{s2}}||{{q}}||
> Returns a quotation containing the first occurrence of {{s2}} within {{s2}}. Note that:
> 
>   * The first element of {{q}} is the matching substring.
>   * Other elements (if any) contain captured substrings.
> 
> > %tip%
> > Tip
> > 
> > {{s2}} can be a {{sgregex}}-compatible regular expression.
> 
> > %sidebar%
> > Example
> > 
> > The following:
> > 
> > `"192.168.1.1, 127.0.0.1" "[0-9]+\.[0-9]+\.([0-9]+)\.([0-9]+)" search`
> > 
> > produces: `("192.168.1.1", "1", "1")`#}

{#op||split||{{sl1}} {{sl2}}||{{q}}||
Splits {{sl1}} using separator {{sl2}} and returns the resulting strings within the quotation {{q}}. #}

{#op||strip||{{sl}}||{{s}}||
Returns {{s}}, which is set to {{sl}} with leading and trailing spaces removed.#} 

{#op||titleize||{{sl}}||{{s}}||
Returns a copy of {{sl}} in which the first character of each word is capitalized.#}

{#op||uppercase||{{sl1}}||{{sl2}}||
Returns a copy of {{sl}} converted to uppercase.#}