all repos — min @ 505e95942dd8879db3b68ae58c86e9a07bf39556

A small but practical concatenative programming language.

Fixing docs.
h3rald h3rald@h3rald.com
Sat, 26 Oct 2024 19:11:43 +0200
commit

505e95942dd8879db3b68ae58c86e9a07bf39556

parent

39741481af7892e0b19c3afe54f8b4de6e197620

M Min_DeveloperGuide.mdMin_DeveloperGuide.md

@@ -125,10 +125,6 @@ ### `net` Module

{@ site/contents/reference-net.md || 1 @} -### `seq` Module - -{@ site/contents/reference-seq.md || 1 @} - ### `stack` Module {@ site/contents/reference-stack.md || 1 @}
M site/contents/reference-dict.mdsite/contents/reference-dict.md

@@ -4,11 +4,11 @@ title: "dict Module"

----- {@ _defs_.md || 0 @} -{#op||dup||{{d1}}||{{d2}}|| -Returns a copy of {{d1}}. #} - {#op||del||{{d}} {{sl}}||{{d}}|| Removes {{sl}} from {{d1}} and returns {{d1}}. #} + +{#op||dup||{{d1}}||{{d2}}|| +Returns a copy of {{d1}}. #} {#op||get||{{d}} {{sl}}||{{any}}|| Returns the value of key {{sl}} from dictionary {{d}}. #}
M site/contents/reference-fs.mdsite/contents/reference-fs.md

@@ -10,17 +10,20 @@

{#op||absolute-path?||{{sl}}||{{b}}|| Returns {{t}} if {{sl}} is an absolute path. #} +{#op||append||{{s1}} {{s2}}||{{none}}|| +Appends {{s1}} to the end of file {{s2}}. #} + {#op||atime||{{sl}}||{{flt}}|| Returns a timestamp corresponding to the time that file/directory {{sl}} was last accessed.#} {#op||ctime||{{sl}}||{{flt}}|| Returns a timestamp corresponding to the time that file/directory {{sl}} was created.#} +{#op||dir?||{{sl}}||{{b}}|| +Returns {{t}} if the specified path {{sl}} exists and is a directory. #} + {#op||dirname||{{sl}}||{{s}}|| Returns the path of the directory containing path {{sl}}.#} - -{#op||dir?||{{sl}}||{{b}}|| -Returns {{t}} if the specified path {{sl}} exists and is a directory. #} {#op||exists?||{{sl}}||{{b}}|| Returns {{t}} if the specified file or directory {{sl}} exists. #}

@@ -43,14 +46,17 @@

{#op||join-path||{{q}}||{{s}}|| Joins the strings contained in {{q}} with `/`.#} +{#op||mtime||{{sl}}||{{flt}}|| +Returns a timestamp corresponding to the time that file/directory {{sl}} was last modified.#} + {#op||normalized-path||{{sl}}||{{s}}|| Returns the normalized path to {{sl}}. #} - -{#op||mtime||{{sl}}||{{flt}}|| -Returns a timestamp corresponding to the time that file/directory {{sl}} was last modified.#} {#op||permissions||{{sl}}||{{i}}|| Returns the Unix permissions (expressed as a three-digit number) of file/directory {{sl}}.#} + +{#op||read||{{s}}||{{s}}|| +Reads the file {{s}} and puts its contents on the top of the stack as a string.#} {#op||relative-path||{{sl1}} {{sl2}}||{{s}}|| Returns the path of {{sl1}} relative to {{sl2}}. #}

@@ -93,3 +99,6 @@ Converts all backslashes in {{sl}} to slashes. #}

{#op||windows-path||{{sl}}||{{s}}|| Converts all slashes in {{sl}} to backslashes. #} + +{#op||write||{{s1}} {{s2}}||{{none}}|| +Writes {{s1}} to the file {{s2}}, erasing all its contents first. #}
M site/contents/reference-global.mdsite/contents/reference-global.md

@@ -104,8 +104,17 @@ {#alias||||||expect-any#}

{#alias||&&||expect-all#} +{#op||all?||{{q1}} {{q2}}||{{b}}|| +Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if all elements of {{q1}} satisfy predicate {{q2}}, {{f}} otherwise. #} + {#op||and||{{b1}} {{b2}}||{{b3}}|| Returns {{t}} if {{b1}} is equal to {{b2}}, {{f}} otherwise.#} + +{#op||any?||{{q1}} {{q2}}||{{b}}|| +Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if at least one element of {{q1}} satisfies predicate {{q2}}, {{f}} otherwise. #} + +{#op||append||{{any}} {{q}}||({{a0p}} {{any}})|| +Returns a new quotation containing the contents of {{q}} with {{any}} appended. #} {#op||apply||{{q}}||({{a0p}})|| Returns a new quotation obtained by evaluating each element of {{q}} in a separate stack. #}

@@ -192,6 +201,9 @@

{#op||compiled?||{{none}}||{{b}}|| Returns {{t}} if the current program has been compiled.#} +{#op||concat||{{q1}} {{q2}}||{{q3}}|| +Concatenates {{q1}} with {{q2}}. #} + {#op||define||{{any}} {{sl}}||{{none}}|| Defines a new symbol {{sl}}, containing the specified value.#}

@@ -224,8 +236,21 @@

{#op||dictionary?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a dictionary, {{f}} otherwise. #} +{#op||difference||{{q1}} {{q2}}||{{q3}}|| +> Calculates the difference {{q3}} of {{q1}} and {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(2)` on the stack: +> > +> > (1 2 "test") ("test" "a" true 1) seq.difference #} + {#op||div||{{i1}} {{i2}}||{{i3}}|| Divides {{i1}} by {{i2}} (integer division). #} + +{#op||drop||{{q1}} {{i}}||{{q2}}|| +Returns a quotation {{q2}} containing the remaining elements after the first _n_ values of the input quotation {{q1}}, or an empty quotation if {{i}} is greater than the length of {{q1}}. #} {#op||escape||{{sl}}||{{s}}|| Returns a copy of {{sl}} with quotes and backslashes escaped with a backslash.#}

@@ -270,6 +295,42 @@

{#op||expect-empty-stack||{{none}}||{{none}}|| Raises an error if the stack is not empty.#} +{#op||filter||{{q1}} {{q2}}||{{q3}}|| +> Returns a new quotation {{q3}} containing all elements of {{q1}} that satisfy predicate {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(2 6 8 12)` on the stack: +> > +> > (1 37 34 2 6 8 12 21) +> > (stackdup 20 < stack.swap even? and) seq.filter #} + +{#op||find||{{q1}} {{q2}}||{{i}}|| +> Returns the index of the first element within {{q1}} that satisfies predicate {{q2}}, or -1 if no element satisfies it. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `3` on the stack: +> > +> > (1 2 4 8 16) +> > (5 >) seq.find #} + +{#op||first||{{q}}||{{any}}|| +Returns the first element of {{q}}. #} + +{#op||flatten||{{q1}}||{{q2}}|| +> Flattens all quotations within {{q1}} and returns the resulting sequence {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(1 2 3 4 5 6 7 8)` on the stack: +> > +> > (1 (2 3 4) 5 (6 7) 8) +> > seq.flatten #} + {#op||float||{{any}}||{{flt}}|| > Converts {{any}} to a float value based on the following rules: >

@@ -328,12 +389,26 @@ > > Note

> > > > At present, only YAML objects containing string values are supported.#} +{#op||get||{{q}} {{i}}||{{any}}|| +Returns the _n^th_ element of {{q}} (zero-based).#} + {#op||gets||{{none}}||{{s}}|| Reads a line from STDIN and places it on top of the stack as a string.#} {#op||get-env||{{sl}}||{{s}}|| Returns environment variable {{sl}}. #} +{#op||harvest||{{q1}}||{{q2}}|| +> Creates a new quotation {{q2}} containing all elements of {{q1}} except for empty quotations. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(1 2 3)` on the stack: +> > +> > (1 () () () 2 () 3) +> > seq.harvest #} + {#op||help||{{sl}}||{{none}}|| Prints the help text for {{sl}}, if available. #}

@@ -342,6 +417,21 @@ If {{q1}} evaluates to {{t}} then evaluates {{q2}}, otherwise evaluates {{q3}}.#}

{#op||import||{{sl}}||{{none}}|| Imports the a previously-loaded module {{sl}}, defining all its symbols in the current scope. #} +{#op||in?||{{q}} {{any}}||{{b}}|| +Returns {{t}} if {{any}} is contained in {{q}}, {{f}} otherwise.#} + +{#op||insert||{{q1}} {{any}} {{i}}||{{q2}}|| +Inserts {{any}} as the value of the _n^th_ element {{q1}} (zero-based), and returns the modified copy of the quotation {{q2}}. #} + +{#op||intersection||{{q1}} {{q2}}||{{q3}}|| +> Calculates the intersection {{q3}} of {{q1}} and {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(1 "test")` on the stack: +> > +> > (1 2 "test") ("test" "a" true 1) seq.intersection #} {#op||indent||{{sl}} {{i}}||{{s}}|| Returns {{s}} containing {{sl}} indented with {{i}} spaces.#}

@@ -413,6 +503,9 @@

{#op||lambda-bind||{{q}} {{sl}}||{{none}}|| Binds the specified quotation to an existing symbol {{sl}} which was previously-set via `lambda`. #} +{#op||last||{{q}}||{{any}}|| +Returns the last element of {{q}}. #} + {#op||length||{{sl}}||{{i}}|| Returns the length of {{sl}}.#}

@@ -462,6 +555,20 @@

{#op||lowercase||{{sl}}||{{s}}|| Returns a copy of {{sl}} converted to lowercase.#} +{#op||map||{{q1}} {{q2}}||{{q3}}|| +Returns a new quotation {{q3}} obtained by applying {{q2}} to each element of {{q1}}.#} + +{#op||map-reduce||{{q1}} {{q2}} {{q3}}||{{i}}|| +> Applies {{q2}} (map) to each element of {{q1}} and then applies {{q3}} (reduce) to each successive element of {{q1}}. {{q1}} must have at least one element. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `35` on the stack: +> > +> > (1 3 5) +> > (stack.dup *) (+) seq.map-reduce #} + {#op||match?||{{s1}} {{s2}}||{{b}}|| > Returns {{t}} if {{s2}} matches {{s1}}, {{f}} otherwise. > > %tip%

@@ -490,6 +597,9 @@

{#op||odd?||{{i}}||{{b}}|| Returns {{t}} if {{i}} is odd, {{f}} otherwise. #} +{#op||one?||{{q1}} {{q2}}||{{b}}|| +Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if only one element of {{q1}} satisfies predicate {{q2}}, {{f}} otherwise. #} + {#op||operator||{{q}}||{{a0p}}|| > Provides a way to define a new operator (symbol, sigil, or typeclass) on the current scope performing additional checks (compared to `define` and `define-sigil`), and automatically mapping inputs and outputs. >

@@ -534,6 +644,9 @@

{#op||opts||{{none}}||{{d}}|| Returns a dictionary of all options passed to the current program, with their respective values.#} +{#op||or||{{b1}} {{b2}}||{{b3}}|| +Returns {{t}} if {{b1}} or {{b2}} is {{t}}, {{f}} otherwise.#} + {#op||ord||{{s}}||{{i}}|| Returns the ASCII code {{i}} corresponding to the single character {{s}}.#}

@@ -546,6 +659,20 @@

{#op||parse-url||{{s}}||{{url}}|| Parses the url {{s}} into its components and stores them into {{url}}.#} +{#op||partition||{{q1}} {{q2}}||{{q3}} {{q4}}|| +> Partitions {{q1}} into two quotations: {{q3}} contains all elements of {{q1}} that satisfy predicate {{q2}}, {{q4}} all the others. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(1 3 5) (2 4 6)` on the stack: +> > +> > (1 2 3 4 5 6) +> > (odd?) seq.partition #} + +{#op||prepend||{{any}} {{q}}||({{any}} {{a0p}})|| +Returns a new quotation containing the contents of {{q}} with {{any}} prepended. #} + {#op||prefix||{{sl1}} {{sl2}}||{{s}}|| Prepends {{sl2}} to {{sl1}}.#}

@@ -573,9 +700,6 @@ > > Example

> > > Publish symbol [my-local-symbol](class:kwd) to [global](class:kwd) scope: > > `'my-local-symbol global publish` #} - -{#op||or||{{b1}} {{b2}}||{{b3}}|| -Returns {{t}} if {{b1}} or {{b2}} is {{t}}, {{f}} otherwise.#} {#op||pred||{{i1}}||{{i2}}|| Returns the predecessor of {{i1}}.#}

@@ -589,6 +713,9 @@

{#op||put-env||{{sl1}} {{sl2}}||{{s}}|| Sets environment variable {{sl2}} to {{sl1}}. #} +{#op||quote-map||{{q1}}||{{q2}}|| +Returns a new quotation {{q2}} obtained by quoting each element of {{q1}}.#} + {#op||quit||{{none}}||{{none}}|| Exits the program or shell with 0 as return code. #}

@@ -624,6 +751,32 @@

{#op||raise||{{e}}||{{none}}|| Raises the error specified via the dictionary {{e}}.#} +{#op||raw-get||{{q}} {{i}}||{{rawval}}|| +Returns the _n^th_ element of {{q}} (zero-based) wrapped in a {{rawval}}.#} + +{#op||reduce||{{q1}} {{a1}} {{q2}}||{{a2}}|| +> Combines each successive element of {{q1}} using {{q2}}. On the first iteration, the first two inputs processed by {{q2}} are {{a1}} and the first element of {{q1}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `120` on the stack: +> > +> > (1 2 3 4 5) +> > 1 (*) seq.reduce #} + +{#op||reject||{{q1}} {{q2}}||{{q3}}|| +Returns a new quotatios {{q3}} including all elements of {{q1}} that do not satisfy predicate {{q2}} (i.e. the opposite of `filter`)#} + +{#op||remove||{{q1}} {{i}}||{{q2}}|| +Returns the _n^th_ element of {{q1}} (zero-based), and returns the modified copy of the quotation {{q2}}.#} + +{#op||rest||{{q1}}||{{q2}}|| +Returns a new quotation {{q2}} containing all elements of {{q1}} quotation except for the first. #} + +{#op||reverse||{{q1}}||{{q2}}|| +Returns a new quotation {{q2}} containing all elements of {{q1}} in reverse order. #} + {#op||raw-args||{{none}}||{{q}}|| Returns a list of all arguments and (non-parsed) options passed to the current program.#}

@@ -760,6 +913,49 @@

{#op||semver?||{{s}}||{{b}}|| Checks whether {{s}} is a [SemVer](https://semver.org)-compliant version or not. #} +{#op||set||{{q1}} {{any}} {{i}}||{{q2}}|| +Sets the value of the _n^th_ element {{q1}} (zero-based) to {{any}}, and returns the modified copy of the quotation {{q2}}. #} + +{#op||set-sym||{{q1}} {{sl}} {{i}}||{{q2}}|| +Sets the value of the _n^th_ element {{q1}} (zero-based) to {{sl}} (treating it as a symbol), and returns the modified copy of the quotation {{q2}}. #} + +{#op||shorten||{{q1}} {{i}}||{{q2}}|| +Returns a quotation {{q2}} containing the first _n_ values of the input quotation {{q1}}. #} + +{#op||size||{{q}}||{{i}}|| +Returns the length of {{q}}.#} + +{#op||slice||{{q1}} {{i1}} {{i2}}||{{q2}}|| +> Creates a new quotation {{q2}} obtaining by selecting all elements of {{q1}} between indexes {{i1}} and {{i2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(3 4 5)` on the stack: +> > +> > (1 2 3 4 5 6) +> > 2 4 seq.slice #} + +{#op||sort||{{q1}} {{q2}}||{{q3}}|| +> Sorts all elements of {{q1}} according to predicate {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(1 3 5 7 9 13 16)` on the stack: +> > +> > (1 9 5 13 16 3 7) '> seq.sort #} + +{#op||symmetric-difference||{{q1}} {{q2}}||{{q3}}|| +> Calculates the symmetric difference {{q3}} of {{q1}} and {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(true "a" 2)` on the stack: +> > +> > (1 2 "test") ("test" "a" true 1) seq.symmetric-difference #} + {#op||split||{{sl1}} {{sl2}}||{{q}}|| Splits {{sl1}} using separator {{sl2}} (a {{pcre}}) and returns the resulting strings within the quotation {{q}}. #}

@@ -809,6 +1005,9 @@

{#op||symbol-help||{{sl}}||{{help}}|{{null}}|| Returns the help dictionary for the symbol {{sl}}, if available, {{null}} otherwise. #} +{#op||take||{{q1}} {{i}}||{{q2}}|| +Returns a quotation {{q2}} containing the first _n_ values of the input quotation {{q1}}, or {{q1}} itself if {{i}} is greater than the length of {{q1}}. #} + {#op||tap||{{any}} {{q}}||{{any}}|| > Performs the following operations: >

@@ -885,7 +1084,7 @@ > > (0)

> > ) try #} {#op||type||{{any}}||{{s}}|| -Returns the type of {{any}}.#} +Returns the data type of {{any}}. In cased of typed dictionaries, the type name is prefixed by `dict:`, e.g. `dict:module`, `dict:socket`, etc.#} {#op||typealias||{{sl1}} {{sl2}}||{{none}}|| Creates a type alias {{sl1}} for type expression {{sl2}}.#}

@@ -895,6 +1094,16 @@ Returns {{t}} if the data type of {{any}} satisfies the specified type expression {{sl}}, {{f}} otherwise. #}

{#op||unless||{{q1}} {{q2}}||{{a0p}}|| If {{1}} evaluates to {{f}} then evaluates {{2}}.#} + +{#op||union||{{q1}} {{q2}}||{{q3}}|| +> Calculates the union {{q3}} of {{q1}} and {{q2}}. +> +> > %sidebar% +> > Example +> > +> > The following program leaves `(true 1 "test" "a" 2)` on the stack: +> > +> > (1 2 "test") ("test" "a" true 1) seq.union #} {#op||unseal-symbol||{{sl}}||{{none}}|| Unseals the user-defined symbol {{sl}}, so that it can be re-assigned. #}
M site/contents/reference-io.mdsite/contents/reference-io.md

@@ -34,17 +34,8 @@

{#op||error||{{any}}||{{any}}|| Prints {{any}} and a new line to STDERR, if logging level is set to [error](class:kwd) or lower.#} -{#op||fappend||{{s1}} {{s2}}||{{none}}|| -Appends {{s1}} to the end of file {{s2}}. #} - {#op||fatal||{{any}}||{{any}}|| Prints {{any}} and a new line to STDERR, and exists the program with error code `100`.#} - -{#op||fread||{{s}}||{{s}}|| -Reads the file {{s}} and puts its contents on the top of the stack as a string.#} - -{#op||fwrite||{{s1}} {{s2}}||{{none}}|| -Writes {{s1}} to the file {{s2}}, erasing all its contents first. #} {#op||getchr||{{none}}||{{i}}|| Reads single character from STDIN without waiting for ENTER key and places its ASCII code on top of the stack.#}

@@ -83,9 +74,6 @@ {#op||putchr||{{s}}||{{any}}||

Prints {{s}} to STDOUT without printing a new line ({{s}} must contain only one character).#} {#alias||read||fread#} - -{#op||type||{{any}}||{{s}}|| -Puts the data type of {{any}} on the stack. In cased of typed dictionaries, the type name is prefixed by `dict:`, e.g. `dict:module`, `dict:socket`, etc.#} {#op||unmapkey||{{sl}}||{{none}}|| > Unmaps a previously-mapped key or key-combination {{sl}}, restoring the default mapping if available.
D site/contents/reference-seq.md

@@ -1,215 +0,0 @@

------ -content-type: "page" -title: "seq Module" ------ -{@ _defs_.md || 0 @} - -{#op||all?||{{q1}} {{q2}}||{{b}}|| -Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if all elements of {{q1}} satisfy predicate {{q2}}, {{f}} otherwise. #} - -{#op||any?||{{q1}} {{q2}}||{{b}}|| -Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if at least one element of {{q1}} satisfies predicate {{q2}}, {{f}} otherwise. #} - -{#op||append||{{any}} {{q}}||({{a0p}} {{any}})|| -Returns a new quotation containing the contents of {{q}} with {{any}} appended. #} - -{#op||get||{{q}} {{i}}||{{any}}|| -Returns the _n^th_ element of {{q}} (zero-based).#} - -{#op||concat||{{q1}} {{q2}}||{{q3}}|| -Concatenates {{q1}} with {{q2}}. #} - -{#op||difference||{{q1}} {{q2}}||{{q3}}|| -> Calculates the difference {{q3}} of {{q1}} and {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(2)` on the stack: -> > -> > (1 2 "test") ("test" "a" true 1) seq.difference #} - -{#op||drop||{{q1}} {{i}}||{{q2}}|| -Returns a quotation {{q2}} containing the remaining elements after the first _n_ values of the input quotation {{q1}}, or an empty quotation if {{i}} is greater than the length of {{q1}}. #} - -{#op||filter||{{q1}} {{q2}}||{{q3}}|| -> Returns a new quotation {{q3}} containing all elements of {{q1}} that satisfy predicate {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(2 6 8 12)` on the stack: -> > -> > (1 37 34 2 6 8 12 21) -> > (stackdup 20 < stack.swap even? and) seq.filter #} - -{#op||find||{{q1}} {{q2}}||{{i}}|| -> Returns the index of the first element within {{q1}} that satisfies predicate {{q2}}, or -1 if no element satisfies it. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `3` on the stack: -> > -> > (1 2 4 8 16) -> > (5 >) seq.find #} - -{#op||first||{{q}}||{{any}}|| -Returns the first element of {{q}}. #} - -{#op||flatten||{{q1}}||{{q2}}|| -> Flattens all quotations within {{q1}} and returns the resulting sequence {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(1 2 3 4 5 6 7 8)` on the stack: -> > -> > (1 (2 3 4) 5 (6 7) 8) -> > seq.flatten #} - -{#op||harvest||{{q1}}||{{q2}}|| -> Creates a new quotation {{q2}} containing all elements of {{q1}} except for empty quotations. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(1 2 3)` on the stack: -> > -> > (1 () () () 2 () 3) -> > seq.harvest #} - -{#op||in?||{{q}} {{any}}||{{b}}|| -Returns {{t}} if {{any}} is contained in {{q}}, {{f}} otherwise.#} - -{#op||insert||{{q1}} {{any}} {{i}}||{{q2}}|| -Inserts {{any}} as the value of the _n^th_ element {{q1}} (zero-based), and returns the modified copy of the quotation {{q2}}. #} - -{#op||intersection||{{q1}} {{q2}}||{{q3}}|| -> Calculates the intersection {{q3}} of {{q1}} and {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(1 "test")` on the stack: -> > -> > (1 2 "test") ("test" "a" true 1) seq.intersection #} - -{#op||last||{{q}}||{{any}}|| -Returns the last element of {{q}}. #} - -{#op||map||{{q1}} {{q2}}||{{q3}}|| -Returns a new quotation {{q3}} obtained by applying {{q2}} to each element of {{q1}}.#} - -{#op||map-reduce||{{q1}} {{q2}} {{q3}}||{{i}}|| -> Applies {{q2}} (map) to each element of {{q1}} and then applies {{q3}} (reduce) to each successive element of {{q1}}. {{q1}} must have at least one element. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `35` on the stack: -> > -> > (1 3 5) -> > (stack.dup *) (+) seq.map-reduce #} - -{#op||partition||{{q1}} {{q2}}||{{q3}} {{q4}}|| -> Partitions {{q1}} into two quotations: {{q3}} contains all elements of {{q1}} that satisfy predicate {{q2}}, {{q4}} all the others. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(1 3 5) (2 4 6)` on the stack: -> > -> > (1 2 3 4 5 6) -> > (odd?) seq.partition #} - -{#op||one?||{{q1}} {{q2}}||{{b}}|| -Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if only one element of {{q1}} satisfies predicate {{q2}}, {{f}} otherwise. #} - -{#op||prepend||{{any}} {{q}}||({{any}} {{a0p}})|| -Returns a new quotation containing the contents of {{q}} with {{any}} prepended. #} - -{#op||quote-map||{{q1}}||{{q2}}|| -Returns a new quotation {{q2}} obtained by quoting each element of {{q1}}.#} - -{#op||raw-get||{{q}} {{i}}||{{rawval}}|| -Returns the _n^th_ element of {{q}} (zero-based) wrapped in a {{rawval}}.#} - -{#op||reduce||{{q1}} {{a1}} {{q2}}||{{a2}}|| -> Combines each successive element of {{q1}} using {{q2}}. On the first iteration, the first two inputs processed by {{q2}} are {{a1}} and the first element of {{q1}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `120` on the stack: -> > -> > (1 2 3 4 5) -> > 1 (*) seq.reduce #} - -{#op||reject||{{q1}} {{q2}}||{{q3}}|| -Returns a new quotatios {{q3}} including all elements of {{q1}} that do not satisfy predicate {{q2}} (i.e. the opposite of `filter`)#} - -{#op||remove||{{q1}} {{i}}||{{q2}}|| -Returns the _n^th_ element of {{q1}} (zero-based), and returns the modified copy of the quotation {{q2}}.#} - -{#op||rest||{{q1}}||{{q2}}|| -Returns a new quotation {{q2}} containing all elements of {{q1}} quotation except for the first. #} - -{#op||reverse||{{q1}}||{{q2}}|| -Returns a new quotation {{q2}} containing all elements of {{q1}} in reverse order. #} - -{#op||set||{{q1}} {{any}} {{i}}||{{q2}}|| -Sets the value of the _n^th_ element {{q1}} (zero-based) to {{any}}, and returns the modified copy of the quotation {{q2}}. #} - -{#op||set-sym||{{q1}} {{sl}} {{i}}||{{q2}}|| -Sets the value of the _n^th_ element {{q1}} (zero-based) to {{sl}} (treating it as a symbol), and returns the modified copy of the quotation {{q2}}. #} - -{#op||shorten||{{q1}} {{i}}||{{q2}}|| -Returns a quotation {{q2}} containing the first _n_ values of the input quotation {{q1}}. #} - -{#op||size||{{q}}||{{i}}|| -Returns the length of {{q}}.#} - -{#op||slice||{{q1}} {{i1}} {{i2}}||{{q2}}|| -> Creates a new quotation {{q2}} obtaining by selecting all elements of {{q1}} between indexes {{i1}} and {{i2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(3 4 5)` on the stack: -> > -> > (1 2 3 4 5 6) -> > 2 4 seq.slice #} - -{#op||sort||{{q1}} {{q2}}||{{q3}}|| -> Sorts all elements of {{q1}} according to predicate {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(1 3 5 7 9 13 16)` on the stack: -> > -> > (1 9 5 13 16 3 7) '> seq.sort #} - -{#op||symmetric-difference||{{q1}} {{q2}}||{{q3}}|| -> Calculates the symmetric difference {{q3}} of {{q1}} and {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(true "a" 2)` on the stack: -> > -> > (1 2 "test") ("test" "a" true 1) seq.symmetric-difference #} - -{#op||take||{{q1}} {{i}}||{{q2}}|| -Returns a quotation {{q2}} containing the first _n_ values of the input quotation {{q1}}, or {{q1}} itself if {{i}} is greater than the length of {{q1}}. #} - -{#op||union||{{q1}} {{q2}}||{{q3}}|| -> Calculates the union {{q3}} of {{q1}} and {{q2}}. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(true 1 "test" "a" 2)` on the stack: -> > -> > (1 2 "test") ("test" "a" true 1) seq.union #}
M site/contents/reference-stack.mdsite/contents/reference-stack.md

@@ -28,9 +28,6 @@

{#op||get||{{none}}||({{a0p}})|| Puts a quotation containing the contents of the stack on the stack.#} -{#op||id||{{none}}||{{none}}|| -Does nothing.#} - {#op||keep||{{a1}} {{q}}||{{a0p}} {{a1}}|| > Removes the first element from the stack, dequotes it, and restores the second element. > > %sidebar%
M site/contents/reference-store.mdsite/contents/reference-store.md

@@ -12,6 +12,9 @@ {#op||get||{{dstore}} {{sl}}||{{d}}||

Retrieves item {{d}} from datastore {{dstore}}. {{d}} is retrieved by specifying {{sl}}, which contains the collection containing the item and the item id, separated by a forward slash (/). #} +{#op||has?||{{dstore}} {{sl}}||{{b}}|| +Returns {{t}} if {{dstore}} has a key called {{sl}} (which contains the collection containing the item and the item id), {{f}} otherwise.#} + {#op||init||{{sl}}||{{dstore}}|| Initializes a bew datastore by creating the {{sl}} JSON file. Puts the datastore instance on the stack. #}
M site/contents/reference-sys.mdsite/contents/reference-sys.md

@@ -7,6 +7,9 @@

{#op||admin?||{{none}}||{{b}}|| Returns {{t}} if the program is being run with administrative privileges. #} +{#op||cd||{{sl}}||{{none}}|| +Change the current directory to {{sl}}. #} + {#op||chmod||{{sl}} {{i}}||{{none}}|| > Sets the permissions of file or directory {{sl}} to {{i}}. {{i}} is a three-digit representation of user, group and other permissions. See the [Unix Permissions Calculator](http://permissions-calculator.org/) for examples and conversions. >

@@ -16,9 +19,6 @@ > >

> > The following program makes the file **/tmp/test.txt** readable, writable and executable by its owner, and readable and executable by users of the same group and all other users: > > > > `"/tmp/test.txt 755 sys.chmod"`#} - -{#op||cd||{{sl}}||{{none}}|| -Change the current directory to {{sl}}. #} {#op||cp||{{sl1}} {{sl2}}||{{none}}|| Copies the file or directory {{sl1}} to {{sl2}}. #}
M site/contents/reference-time.mdsite/contents/reference-time.md

@@ -3,18 +3,6 @@ content-type: "page"

title: "time Module" ----- {@ _defs_.md || 0 @} - -{#op||now||{{none}}||{{flt}}|| -Returns the current time as Unix timestamp with microseconds. #} - -{#op||stamp||{{none}}||{{i}}|| -Returns the current time as Unix timestamp. #} - -{#op||info||{{i}}||{{tinfo}}|| -Returns a timeinfo dictionary from timestamp {{i}}. #} - -{#op||to-timestamp||{{tinfo}}||{{i}}|| -Converts the timeinfo dictionary {{tinfo}} to the corresponding Unix timestamp. #} {#op||datetime||{{i}}||{{s}}|| Returns an ISO 8601 string representing the combined date and time in UTC of timestamp {{i}}. #}

@@ -26,3 +14,15 @@ > > %tip%

> > Tip > > > > For information on special characters in the format string, see the [format](https://nim-lang.org/docs/times.html#format,TimeInfo,string) nim method. #} + +{#op||info||{{i}}||{{tinfo}}|| +Returns a timeinfo dictionary from timestamp {{i}}. #} + +{#op||now||{{none}}||{{flt}}|| +Returns the current time as Unix timestamp with microseconds. #} + +{#op||stamp||{{none}}||{{i}}|| +Returns the current time as Unix timestamp. #} + +{#op||to-timestamp||{{tinfo}}||{{i}}|| +Converts the timeinfo dictionary {{tinfo}} to the corresponding Unix timestamp. #}
M site/contents/reference-xml.mdsite/contents/reference-xml.md

@@ -4,30 +4,6 @@ title: "xml Module"

----- {@ _defs_.md || 0 @} -{#op||from-html||{{sl}}||{{xnode}}|| -Returns an {{xnode}} representing an HTML string (wrapped in a `<document>` tag unless a valid HTML document is provided as input).#} - -{#op||from-xml||{{sl}}||{{xnode}}|| -> Returns an {{xnode}} representing an XML string (element or fragment). -> -> > %sidebar% -> > Example -> > -> > The following program: -> > -> > "<a href='https://min-lang.org'>min web site</a>" from-xml -> > returns the following: -> > -> > { -> > {"https://min-lang.org" :href} :attributes -> > ({"min web site" :text}) :children -> > "a" :tag -> > ;xml-element -> > } - #} - -{#op||to-xml||{{xnode}}||{{s}}|| -Returns a {{s}} representing an XML node. #} {#op||cdata||{{sl}}||{{xcdata}}|| Returns a {{xcdata}} representing an XML CDATA section. #}

@@ -41,9 +17,6 @@

{#op||entity||{{sl}}||{{xentity}}|| Returns a {{xentity}} representing an XML entity. #} -{#op||escape||{{sl}}||{{s}}|| -Converts any `<`, `>`, `&`, `'`, and `"` present in {{sl}} into the corresponding XML entities. #} - {#op||entity2utf8||{{xentity}}||{{s}}|| > Returns the UTF-8 symbol corresponding to the specified XML entity. >

@@ -55,6 +28,31 @@ > >

> > "&gt;" xml.entity xml.entity2utf8 puts! #} + {#op||escape||{{sl}}||{{s}}|| +Converts any `<`, `>`, `&`, `'`, and `"` present in {{sl}} into the corresponding XML entities. #} + +{#op||from-html||{{sl}}||{{xnode}}|| +Returns an {{xnode}} representing an HTML string (wrapped in a `<document>` tag unless a valid HTML document is provided as input).#} + +{#op||from-xml||{{sl}}||{{xnode}}|| +> Returns an {{xnode}} representing an XML string (element or fragment). +> +> > %sidebar% +> > Example +> > +> > The following program: +> > +> > "<a href='https://min-lang.org'>min web site</a>" from-xml +> > returns the following: +> > +> > { +> > {"https://min-lang.org" :href} :attributes +> > ({"min web site" :text}) :children +> > "a" :tag +> > ;xml-element +> > } + #} + {#op||query||{{xelement}} {{sl}}||{{xelement}}|| > Returns an {{xelement}} representing the first element matching CSS the selector {{sl}}. >

@@ -79,7 +77,7 @@ > > ;xml-element

> > } #} -{#op||queryall||{{xelement}} {{sl}}||{{xelement}}|| +{#op||query-all||{{xelement}} {{sl}}||{{xelement}}|| > Returns a list of {{xelement}} dictionaries representing all the elements matching CSS the selector {{sl}}. > > > %sidebar%

@@ -111,3 +109,6 @@ #}

{#op||text||{{sl}}||{{xtext}}|| Returns a {{xtext}} representing an XML text node. #} + +{#op||to-xml||{{xnode}}||{{s}}|| +Returns a {{s}} representing an XML node. #}