| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'content/fate_v1/computations')
| -rw-r--r-- | content/fate_v1/computations/addresses/_index.md | 25 | ||||
| -rw-r--r-- | content/fate_v1/computations/basics/_index.md | 137 | ||||
| -rw-r--r-- | content/fate_v1/computations/collections/_index.md | 243 | ||||
| -rw-r--r-- | content/fate_v1/computations/conditionals/_index.md | 13 | ||||
| -rw-r--r-- | content/fate_v1/computations/lambda_functions/_index.md | 13 | ||||
| -rw-r--r-- | content/fate_v1/computations/text/_index.md | 5 | 
6 files changed, 298 insertions, 138 deletions
| diff --git a/content/fate_v1/computations/addresses/_index.md b/content/fate_v1/computations/addresses/_index.md index aafd0f1..ae052ca 100644 --- a/content/fate_v1/computations/addresses/_index.md +++ b/content/fate_v1/computations/addresses/_index.md @@ -1,18 +1,27 @@  ---  title: Addresses  --- -### VALUE ACCESS -{{< fatecode >}}(at [ADDRESS]){{< /fatecode >}} -Returns the variable at `[ADDRESS]`. +Addresses are values that indicate where in the memory some other value is +located. They can thus be used to pass around an indication of where to modify +a value. + +### VALUE ACCESS +{{< fatecode >}}(at [address: (POINTER X)]){{< /fatecode >}} +Returns the `[X]` value at `[address]`. The returned value can act as a +reference. -### ALLOCATION -{{< fatecode >}}(new [TYPE]){{< /fatecode >}} +**Examples:** `(at my_ptr_var)`, `(at (ptr my_var))` -Returns the address of a new variable of type `[TYPE]`. Don't forget to call -`free` on it once you're done. +**Aliases:** `at`.  ### ADDRESS -{{< fatecode >}}(ptr [COMPUTATION VARIABLE]){{< /fatecode >}} +{{< fatecode >}}(ptr [X]){{< /fatecode >}}  Returns the address of `[COMPUTATION VARIABLE]`. + +**Examples:** `(ptr my_var)` + +**Aliases:** `address_of`, `addressof`, `addressOf`, `address`, `addr`, +`pointer_to`, `pointerto`, `pointerTo`, `pointer`, `ptr`, `reference_to`, +`referenceto`, `referenceTo`, `reference`, `ref`. diff --git a/content/fate_v1/computations/basics/_index.md b/content/fate_v1/computations/basics/_index.md index e8a8816..52b5e42 100644 --- a/content/fate_v1/computations/basics/_index.md +++ b/content/fate_v1/computations/basics/_index.md @@ -2,19 +2,44 @@  title: Computations  weight: 2  --- -Computations are values. They may read from the memory, but do not modify it -(with a single exception). +Computations are values. They may read from the memory, but do not modify it.  ### TEXT -{{< fatecode >}}(text [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(text [C0: COMPUTATION]...[CN: COMPUTATION]){{< /fatecode >}} -Returns a `text` node containing the text representation of `C0` ... `CN`. +Returns a `text` value containing the text representation of `C0`...`CN`. + +**Examples:** `(text just a few strings)`, +`(text (string just a single string))`, `(text There are (+ 3 1) lights!)`, +`(text (text (text well...)))`. + +**Aliases:** `text`.  ### VARIABLE | REFERENCE  {{< fatecode >}}(var {String}){{< /fatecode >}}  Returns the value of the variable `{String}`, or a reference to it if -applicable. Structure members can be accessed by using `.` in `{String}`. +applicable. In cases where no `text` or `string` value is expected, using +`{String}` instead of `(var {String})` will work as a shortcut. + +Structure members can be accessed by using `.` in `{String}`. Collection +(`list` or `set`) elements can be similarly accessed by their index. + +**Examples:** `(var my_list)`, `(var my_list.0)`, `(var my_list.0.name)`. + +**Aliases:** `var`, `variable`. + +### STRING +{{< fatecode >}}(string {String}){{< /fatecode >}} + +Returns a `string` value corresponding to `{String}`. This can be used +to disambiguate strings and variable names, as well as to create strings with +spaces. + +**Examples:** +`(string just a single string)`, `(string var0_is_not_a_var)` + +**Aliases:** `string`.  ### SEQUENCE | PROCEDURE  {{< fatecode >}}(sequence {String}){{< /fatecode >}} @@ -22,21 +47,42 @@ applicable. Structure members can be accessed by using `.` in `{String}`.  Returns a `[SEQUENCE]` value corresponding to the sequence named `{String}`.  Said sequence can be defined at a later point. +**Examples:** `(sequence the_cave)`, `(sequence end_credits)`. + +**Aliases:** `seq`, `sequence`. + +  ### STRUCTURE FIELD ACCESS -{{< fatecode >}}{Structure Var Name}.{Field Name}{{< /fatecode >}} -{{< fatecode >}}(field {String} [STRUCTURE VAR]){{< /fatecode >}} +{{< fatecode >}}{Structure Variable Name}.{Field Name}{{< /fatecode >}} +{{< fatecode >}}(struct:field {String} [STRUCTURE]){{< /fatecode >}} -Accesses the `{String}` field of the structure `[STRUCTURE VAR]`. Using `.` to -access fields is recommended over the use of this operator. +Accesses the `{String}` field of the structure `[STRUCTURE]`. Using `.` to +access fields is recommended over the use of this operator when possible. The +returned value can act as a reference. + +**Examples:** `claude.health_points`, `(struct:field health_points jack)`, +`(struct:field stamina (car (list:pop_left character_list)))` + +**Aliases:** `struct:field`, `struct:get`, `struct:getfield`, +`struct:get_field`. -### STRUCTURE FIELD VALUE -{{< fatecode >}}(get_field {String} [STRUCTURE]){{< /fatecode >}} -Returns the value of the `{String}` field of the structure `[STRUCTURE]`.  ### TEMPORARY VARIABLES -{{< fatecode >}}(let (({V0 = String} [C0 = COMPUTATION]) ... ({VN = String} [CN = COMPUTATION])) [R = COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(let +   ( +      ({V0: String} [C0: COMPUTATION]) +      ... +      ({VN: String} [CN: COMPUTATION]) +   ) +   [result: COMPUTATION] +){{< /fatecode >}} + +Defines a hierarchical level and local variables `V0` ... `VN` with values `C0` ... `CN`, and returns the value of `result`. + +**Examples:** + +**Aliases:** -Defines a hierarchical level and local variables `V0` ... `VN` with values `C0` ... `CN`, and returns the value of `[R]`.  ### CAST  {{< fatecode >}}(cast [TYPE] [COMPUTATION*]){{< /fatecode >}} @@ -49,18 +95,28 @@ allowed:  * `[BOOL]` to `[BOOL]` and `[STRING]`.  * `[STRING]` to `[BOOL]` (`true` and `false`), `[FLOAT]`, `[INT]`, and`[STRING]`. +**Examples:** + +**Aliases:** + +  ### RANDOM NUMBER -{{< fatecode >}}(rand [I0 = INT] [IN = INT]){{< /fatecode >}} +{{< fatecode >}}(rand [I0: INT] [IN: INT]){{< /fatecode >}}  Returns a random number between `I0` and `IN` (inclusive). +**Examples:** + +**Aliases:** + +  ## Basic Operators  ### BOOL OPERATORS -{{< fatecode >}}(and [B0 = BOOL] ... [BN = BOOL]){{< /fatecode >}} +{{< fatecode >}}(and [B0: BOOL] ... [BN: BOOL]){{< /fatecode >}}  Standard conjunction (minimum of 2 arguments). -{{< fatecode >}}(or [B0 = BOOL] ... [BN = BOOL]){{< /fatecode >}} +{{< fatecode >}}(or [B0: BOOL] ... [BN: BOOL]){{< /fatecode >}}  Standard disjunction (minimum of 2 arguments). @@ -68,53 +124,58 @@ Standard disjunction (minimum of 2 arguments).  Standard negation. -{{< fatecode >}}(implies [B0 = BOOL] [B1 = BOOL]){{< /fatecode >}} +{{< fatecode >}}(implies [B0: BOOL] [B1: BOOL]){{< /fatecode >}}  Standard implication. -{{< fatecode >}}(one_in [B0 = BOOL] ... [BN = BOOL]){{< /fatecode >}} +{{< fatecode >}}(one_in [B0: BOOL] ... [BN: BOOL]){{< /fatecode >}}  true if, and only if, exactly one of the operands is true. +**Examples:** + +**Aliases:** + +  ### MATH OPERATORS  All operands must be of the same type, which is also the type returned by the  operation. -{{< fatecode >}}(+ [N0 = NUMBER] ... [NN = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(+ [N0: NUMBER] ... [NN: NUMBER]){{< /fatecode >}}  Standard addition (minimum of 2 arguments). -{{< fatecode >}}(- [N0 = NUMBER] ... [NN = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(- [N0: NUMBER] ... [NN: NUMBER]){{< /fatecode >}}  Standard substraction (minimum of 2 arguments). -{{< fatecode >}}(* [N0 = NUMBER] ... [NN = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(* [N0: NUMBER] ... [NN: NUMBER]){{< /fatecode >}}  Standard multiplication (minimum of 2 arguments). -{{< fatecode >}}(/ [N0 = NUMBER] [N1 = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(/ [N0: NUMBER] [N1: NUMBER]){{< /fatecode >}}  Standard division. Note that a division on integers is indeed a integer  division. -{{< fatecode >}}(^ [N0 = NUMBER] [N1 = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(^ [N0: NUMBER] [N1: NUMBER]){{< /fatecode >}}  Standard exponentiation. -{{< fatecode >}}(% [I0 = INT] [I1 = INT]){{< /fatecode >}} +{{< fatecode >}}(% [I0: INT] [I1: INT]){{< /fatecode >}}  Standard modulo operation. -{{< fatecode >}}(min [N0 = NUMBER] ... [NN = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(min [N0: NUMBER] ... [NN: NUMBER]){{< /fatecode >}}  Lowest value among the operands. -{{< fatecode >}}(max [N0 = NUMBER] ... [NN = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(max [N0: NUMBER] ... [NN: NUMBER]){{< /fatecode >}}  Highest value among the operands. -{{< fatecode >}}(clamp [N0 = NUMBER] [N1 = NUMBER] [N2 = NUMBER]){{< /fatecode >}} +{{< fatecode >}}(clamp [N0: NUMBER] [N1: NUMBER] [N2: NUMBER]){{< /fatecode >}}  Equivalent to `(max N0 (min N1 N2))`. @@ -123,23 +184,33 @@ Equivalent to `(max N0 (min N1 N2))`.  Positive value of `[NUMBER]`. +**Examples:** + +**Aliases:** + +  ### COMPARISON OPERATORS -{{< fatecode >}}(= [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(= [C0: COMPUTATION] ... [CN: COMPUTATION]){{< /fatecode >}}  True if, and only if, all operands are equal. -{{< fatecode >}}(< [C0 = COMPARABLE] [C1 = COMPARABLE]){{< /fatecode >}} +{{< fatecode >}}(< [C0: COMPARABLE] [C1: COMPARABLE]){{< /fatecode >}}  True if, and only if, `C0` is strictly lower than `C1`. -{{< fatecode >}}(=< [C0 = COMPARABLE] [C1 = COMPARABLE]){{< /fatecode >}} +{{< fatecode >}}(=< [C0: COMPARABLE] [C1: COMPARABLE]){{< /fatecode >}}  True if, and only if, `C0` is lower or equal to/than `C1`. -{{< fatecode >}}(> [C0 = COMPARABLE] [C1 = COMPARABLE]){{< /fatecode >}} +{{< fatecode >}}(> [C0: COMPARABLE] [C1: COMPARABLE]){{< /fatecode >}}  True if, and only if, `C0` is strictly higher than `C1`. -{{< fatecode >}}(>= [C0 = COMPARABLE] [C1 = COMPARABLE]){{< /fatecode >}} +{{< fatecode >}}(>= [C0: COMPARABLE] [C1: COMPARABLE]){{< /fatecode >}}  True if, and only if, `C0` is higher or equal to/than `C1`. + +**Examples:** + +**Aliases:** + diff --git a/content/fate_v1/computations/collections/_index.md b/content/fate_v1/computations/collections/_index.md index 80a4ead..584baef 100644 --- a/content/fate_v1/computations/collections/_index.md +++ b/content/fate_v1/computations/collections/_index.md @@ -2,151 +2,208 @@  title: Collections  ---  ### ACCESS -{{< fatecode >}}(access [INT] [COLLECTION|COLLECTION PTR]){{< /fatecode >}} +{{< fatecode >}}(list:access [INT] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:access [INT] [SET]){{< /fatecode >}} -Returns the value of the `[INT]`th element in `[COLLECTION|COLLECTION PTR]`. +Returns the value of the `[INT]`th element in the collection.  ### ACCESS CONSTANT INDEX -{{< fatecode >}}[(COLLECTION|COLLECTION PTR) VAR].{Integer}{{< /fatecode >}} +{{< fatecode >}}[(LIST) VAR].{Integer}{{< /fatecode >}} +{{< fatecode >}}[(SET) VAR].{Integer}{{< /fatecode >}} -Returns a variable corresponding to the `[INT]`th element in -`[(COLLECTION|COLLECTION PTR) VAR]`. - -### ACCESS POINTER -{{< fatecode >}}(access_pointer [INT] [(COLLECTION|COLLECTION PTR) VAR]){{< /fatecode >}} - -Returns a pointer to the `[INT]`th element in `[(COLLECTION|COLLECTION PTR) -VAR]`. +Returns a variable corresponding to the `[INT]`th element in the collection.  ### ADD ELEMENT AT -{{< fatecode >}}(add_element_at [INT] [COMPUTATION*] [LIST]){{< /fatecode >}} +{{< fatecode >}}(list:add_element_at [INT] [COMPUTATION*] [LIST]){{< /fatecode >}}  Returns a copy of `[LIST]` with `[COMPUTATION*]` added at index `[INT]`. Note -that `[COMPUTATION*]` does not allow use of the variable shorthand. +that `[COMPUTATION*]` does not allow use of the variable shorthand if `[LIST]` +is a list of strings.  ### ADD ELEMENT -{{< fatecode >}}(add_element [C0 = COMPUTATION*] ... [CN = COMPUTATION*] [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:add_element [C0 = COMPUTATION*] ... [CN = COMPUTATION*] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:add_element [C0 = COMPUTATION*] ... [CN = COMPUTATION*] [SET]){{< /fatecode >}}  Returns a copy of `[COLLECTION]` with `C0` ... `CN` added. If `[COLLECTION]`  is a `[LIST]`, then the elements are added at the end of the list, in order  (meaning that `CN` will be the last element added). -Note that `[COMPUTATION*]` does not allow use of the variable shorthand. +Note that `[COMPUTATION*]` does not allow use of the variable shorthand if the +collection is a collection of strings.  ### ADDING MEMBERS -{{< fatecode >}}(add_all_elements [C0 = COLLECTION] [C1 = COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:add_all_elements [C0 = LIST|SET]+ [C1 = LIST]){{< /fatecode >}} +{{< fatecode >}}(set:add_all_elements [C0 = LIST|SET]+ [C1 = SET]){{< /fatecode >}} -Returns a copy of `[C1]`, with all the elements of `[C2]` added. If `[C1]` +Returns a copy of `[C1]`, with all the elements of `[C0]` added. If `[C1]`  is a `[LIST]`, the new members are added at the end of the list. +As a shorthand, multiple `[C0]` can be specified. They will all be added in +order. + +### SUB-LIST +{{< fatecode >}}(list:sublist [start: INT] [end_before: INT] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:subset [start: INT] [end_before: INT] [SET]){{< /fatecode >}} + +Returns a copy of the collection in which only the elements with an index +higher or equal to `[start]` and strictly less than `[end_before]` are included. + +### SHUFFLE +{{< fatecode >}}(list:shuffle [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:shuffle [SET]){{< /fatecode >}} + +Returns a list containing all the elements of the collection in a random order. +  ### COUNT -{{< fatecode >}}(count [COMPUTATION*] [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:count [COMPUTATION*] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:count [COMPUTATION*] [SET]){{< /fatecode >}} -Returns the number of occurrences of `[COMPUTATION*]` in `[COLLECTION]`. -Note that `[COMPUTATION*]` does not allow use of the variable shorthand. +Returns the number of occurrences of `[COMPUTATION*]` in `[LIST]` or `[SET]`. +Note that `[COMPUTATION*]` does not allow use of the variable shorthand if +the collection is a collection of strings.  ### INDEX OF -{{< fatecode >}}(index_of [COMPUTATION] [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:index_of [COMPUTATION] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:index_of [COMPUTATION] [SET]){{< /fatecode >}} -Returns the index of the first occurrence of `[COMPUTATION]` in `[COLLECTION]`, -starting at 0. +Returns the index of the first occurrence of `[COMPUTATION]` in `[LIST]` or +`[SET]`, starting at 0.  ### IS MEMBER -{{< fatecode >}}(is_member [COMPUTATION] [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:is_member [COMPUTATION] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:is_member [COMPUTATION] [SET]){{< /fatecode >}} -Returns true if, and only if, `[COMPUTATION]` is in `[COLLECTION]`. +Returns true if, and only if, `[COMPUTATION]` is in `[LIST]` or `[SET]`.  ### SIZE -{{< fatecode >}}(size [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:size [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:size [SET]){{< /fatecode >}} -Returns the size (`[INT]`) of `[COLLECTION]`. +Returns the size (`[INT]`) of `[LIST]` or `[SET]`.  ### IS EMPTY -{{< fatecode >}}(is_empty [COLLECTION]){{< /fatecode >}} +{{< fatecode >}}(list:is_empty [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:is_empty [SET]){{< /fatecode >}} + +Returns true if, and only if `[LIST]` or `[SET]` is empty. + +### REMOVE ONE COPY +{{< fatecode >}}(list:remove [COMPUTATION*]+ [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:remove [COMPUTATION*]+ [SET]){{< /fatecode >}} + +Returns a copy of the collection with one instance of `[COMPUTATION*]` having been removed. The variable shorthand cannot be used if the collection is a collection of strings. + +As a shorthand, multiple computations can be specified. They will all be removed +in order. + +### REMOVE ALL COPIES +{{< fatecode >}}(list:remove_each [COMPUTATION*]+ [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:remove_each [COMPUTATION*]+ [SET]){{< /fatecode >}} + +Returns a copy of the collection with all instances of `[COMPUTATION*]` having been removed. The variable shorthand cannot be used if the collection is a collection of strings. + +As a shorthand, multiple computations can be specified. They will all be removed +from the list. + +### REMOVE ALL ALSO IN +{{< fatecode >}}(list:remove_all [removed: COLLECTION]+ [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:remove_all [removed: COLLECTION]+ [SET]){{< /fatecode >}} + +Returns a copy of the collection with all elements of `[removed]` having been +removed. + +As a shorthand, multiple `[removed]` can be specified. Their elements will all +be removed. + +### REMOVE AT +{{< fatecode >}}(list:remove_at [INT] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:remove_at [INT] [SET]){{< /fatecode >}} + +Returns a copy of the collection with the element at index `[INT]` having been +removed. + +### PUSH ELEMENT +{{< fatecode >}}(list:push_left [COMPUTATION*] [LIST]){{< /fatecode >}} +{{< fatecode >}}(list:push_right [COMPUTATION*] [LIST]){{< /fatecode >}} +{{< fatecode >}}(set:push_left [COMPUTATION*] [SET]){{< /fatecode >}} +{{< fatecode >}}(set:push_right [COMPUTATION*] [SET]){{< /fatecode >}} + +Returns a list corresponding to the given `[LIST]` or `[SET]` to which the +`[COMPUTATION*]` has been added to the right (`push_right`) or the left +(`push_left`). + +### POP ELEMENT +TODO + +### PARTITION +TODO + +### PARTITION (INDEXED) +TODO -Returns true if, and only if `[COLLECTION]` is empty. +### SORT +TODO  ### FILTER ELEMENTS -{{< fatecode >}}(filter [LAMBDA BOOL (X)] [X COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(filter [LAMBDA BOOL (X Y0 ... YN)] [X COLLECTION] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}} +{{< fatecode >}}(list:filter [LAMBDA BOOL (X)] [X LIST]){{< /fatecode >}} +{{< fatecode >}}(set:filter [LAMBDA BOOL (X)] [X SET]){{< /fatecode >}} -Returns a copy of `[X COLLECTION]` in which only the elements for which -`[LAMBDA BOOL (X)]` returns `true` remain. If the lambda function needs extra -parameters, use the second syntax, which adds those parameters at the end of the -`(filter ...)` call. Note that the variable shorthand cannot be used for these -extra parameters. +Returns a copy of `[X LIST]` or `[X SET]` in which only the elements for which +`[LAMBDA BOOL (X)]` returns `true` remain.  ### FILTER ELEMENTS (INDEXED) -{{< fatecode >}}(indexed_filter [LAMBDA BOOL (INT X)] [X COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(indexed_filter [LAMBDA BOOL (INT X Y0 ... YN)] [X COLLECTION] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}} +{{< fatecode >}}(list:indexed_filter [LAMBDA BOOL (INT X)] [X LIST]){{< /fatecode >}} +{{< fatecode >}}(set:indexed_filter [LAMBDA BOOL (INT X)] [X SET]){{< /fatecode >}} -Returns a copy of `[INT X COLLECTION]` in which only the elements for which +Returns a copy of `[X LIST]` or `[X SET]` in which only the elements for which  `[LAMBDA BOOL (INT X)]` (with `INT` being the element's index) returns `true` -remain. If the lambda function needs extra parameters, use the second syntax, -which adds those parameters at the end of the `(indexed_filter ...)` call. Note -that the variable shorthand cannot be used for these extra parameters. +remain.  ### FOLD OVER COLLECTION -{{< fatecode >}}(foldl [LAMBDA X (X Y)] [X COMPUTATION*] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(foldl [LAMBDA X (X Y Z0 ... ZN)] [X COMPUTATION*] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(foldr [LAMBDA X (X Y)] [X COMPUTATION*] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(foldr [LAMBDA X (X Y Z0 ... ZN)] [X COMPUTATION*] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} +{{< fatecode >}}(list:foldl [LAMBDA X (X Y)] [X COMPUTATION*] [Y LIST]){{< /fatecode >}} +{{< fatecode >}}(list:foldr [LAMBDA X (X Y)] [X COMPUTATION*] [Y LIST]){{< /fatecode >}} +{{< fatecode >}}(set:foldl [LAMBDA X (X Y)] [X COMPUTATION*] [Y SET]){{< /fatecode >}} +{{< fatecode >}}(set:foldr [LAMBDA X (X Y)] [X COMPUTATION*] [Y SET]){{< /fatecode >}}  Returns the result of iterating `[LAMBDA X (X Y)]` over `[Y COLLECTION]`, with  `[X COMPUTATION*]` being the initial value. The direction of the iteration is  by ascending index order when using `foldl`, and the opposite order when using -`foldr`. Extra parameters for the lambda function can be passed as extra -parameters of the call. Note that the variable shorthand cannot be used for -those extra parameters, nor for the initial value. +`foldr`. The variable shorthand cannot be used for the initial value if the +lambda function returns a string.  ### MERGE COLLECTIONS -{{< fatecode >}}(merge_to_list [LAMBDA O (X Y)] [X COLLECTION] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(merge_to_list [LAMBDA O (X Y Z0 ... ZN)] [X COLLECTION] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(merge_to_set [LAMBDA O (X Y)] [X COLLECTION] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(merge_to_set [LAMBDA O (X Y Z0 ... ZN)] [X COLLECTION] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -Merges two collections into either a list or a set. This version of merging -only continues as long as both collections have elements. Thus, extra elements -in either list are ignored.  Extra parameters for the lambda function can be -passed as extra parameters of the call. Note that the variable shorthand cannot -be used for those extra parameters. +{{< fatecode >}}(list:merge [LAMBDA O (X Y)] [X LIST|X SET] [Y LIST|Y SET]){{< /fatecode >}} +{{< fatecode >}}(set:merge [LAMBDA O (X Y)] [X LIST|X SET] [Y LIST|Y SET]){{< /fatecode >}} +Merges two collections into either a list (`list:merge`) or a set +(`set:merge`). This version of merging only continues as long as both +collections have elements. Thus, extra elements in either list are ignored.  ### SAFE-MERGE COLLECTIONS -{{< fatecode >}}(safe_merge_to_list [LAMBDA O (X Y)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(safe_merge_to_list [LAMBDA O (X Y Z0 ... ZN)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(safe_merge_to_set [LAMBDA O (X Y)] [X COLLECTION] [X COMPUTATION*] [Y COLLECTION] [Y COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(safe_merge_to_set [LAMBDA O (X Y Z0 ... ZN)] [X COLLECTION] [X COMPUTATION*] [Y COLLECTION] [Y COMPUTATION*] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -Merges two collections into either a list or a set. This version of merging -continues as long as either collection has elements. Hence the extra two -parameters compared to the non-safe version: these correspond to the value used -for the lambda when a collection has ran out of elements but the other has not. -Extra parameters for the lambda function can be passed as extra parameters of -the call. Note that the variable shorthand cannot be used for those extra -parameters. +{{< fatecode >}}(list:safe_merge [LAMBDA O (X Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(set:safe_merge [LAMBDA O (X Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION]){{< /fatecode >}} +Safely merges two collections into either a list (`list:safe_merge`) or a set +(`set:safe_merge`). This version of merging continues as long as either +collection has elements. If one of the two collections runs out of elements +before the other, it uses the provided default value (`[X COMPUTATION]` for the +first list, `[Y COMPUTATION]` for the second one).  ### MERGE COLLECTIONS (INDEXED) -{{< fatecode >}}(indexed_merge_to_list [LAMBDA O (INT X Y)] [X COLLECTION] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(indexed_merge_to_list [LAMBDA O (INT X Y Z0 ... ZN)] [X COLLECTION] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(indexed_merge_to_set [LAMBDA O (INT X Y)] [X COLLECTION] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(indexed_merge_to_set [LAMBDA O (INT X Y Z0 ... ZN)] [X COLLECTION] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -Merges two collections into either a list or a set, indicating the index of both -elements as first parameter for the lambda function. This version of merging -only continues as long as both collections have elements. Thus, extra elements -in either list are ignored and there is only one index passed as parameter for -the lambda function. Extra parameters for the lambda function can be -passed as extra parameters of the call. Note that the variable shorthand cannot -be used for those extra parameters. +{{< fatecode >}}(list:indexed_merge [LAMBDA O (INT X Y)] [X LIST|X SET] [Y LIST|Y SET]){{< /fatecode >}} +{{< fatecode >}}(set:indexed_merge [LAMBDA O (INT X Y)] [X LIST|X SET] [Y LIST|Y SET]){{< /fatecode >}} +Merges two collections into either a list (`list:merge`) or a set +(`set:merge`). This version of merging only continues as long as both +collections have elements. Thus, extra elements in either list are ignored. +The first parameter passed to the lambda function is the index of the element +in both collections.  ### SAFE-MERGE COLLECTIONS (INDEXED) -{{< fatecode >}}(safe_indexed_merge_to_list [LAMBDA O (INT X INT Y)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(safe_indexed_merge_to_list [LAMBDA O (INT X INT Y Z0 ... ZN)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -{{< fatecode >}}(safe_indexed_merge_to_set [LAMBDA O (INT X INT Y)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION]){{< /fatecode >}} -{{< fatecode >}}(safe_indexed_merge_to_set [LAMBDA O (INT X INT Y Z0 ... ZN)] [X COMPUTATION*] [X COLLECTION] [Y COMPUTATION*] [Y COLLECTION] [Z0 COMPUTATION*] ... [ZN COMPUTATION*]){{< /fatecode >}} -Merges two collections into either a list or a set. This version of merging -continues as long as either collection has elements. Hence the extra two -parameters compared to the non-safe version: these correspond to the value used -for the lambda when a collection has ran out of elements but the other has not. -This is also the reason why two indices are given. The index given for a list -that has ran out of elements is equal the size of the list. -Extra parameters for the lambda function can be passed as extra parameters of -the call. Note that the variable shorthand cannot be used for those extra -parameters. +{{< fatecode >}}(list:indexed_safe_merge [LAMBDA O (INT X INT Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(set:indexed_safe_merge [LAMBDA O (INT X INT Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION]){{< /fatecode >}} +Safely merges two collections into either a list (`list:safe_merge`) or a set +(`set:safe_merge`). This version of merging continues as long as either +collection has elements. If one of the two collections runs out of elements +before the other, it uses the provided default value (`[X COMPUTATION]` for the +first list, `[Y COMPUTATION]` for the second one). The first and third parameters +passed to the lambda function correspond to the index of the element in either +collection. It does not increase if the collection has no more elements and is +using the default value. diff --git a/content/fate_v1/computations/conditionals/_index.md b/content/fate_v1/computations/conditionals/_index.md index 7b65294..ee86b80 100644 --- a/content/fate_v1/computations/conditionals/_index.md +++ b/content/fate_v1/computations/conditionals/_index.md @@ -10,13 +10,22 @@ some condition. All possible returned values must be of the same type.  Returns `C0` is `[BOOL]` yields true, `C1` otherwise.  ### COND -{{< fatecode >}}(cond ([B0 = BOOL] [C0 = COMPUTATION]) ... ([BN = BOOL] [CN = COMPUTATION])){{< /fatecode >}} +{{< fatecode >}}(cond +   ([B0 = BOOL] [C0 = COMPUTATION]) +   ... +   ([BN = BOOL] [CN = COMPUTATION]) +){{< /fatecode >}}  Returns `[CI]`, such that `[BI]` is the first to hold true. If there is not such  `Bi`, returns `[CN]`.  ### SWITCH -{{< fatecode >}}(switch [T = COMPUTATION] ([V0 = COMPUTATION] [C0 = COMPUTATION]) ... ([VN = BOOL] [CN = COMPUTATION]) [D = COMPUTATION]){{< /fatecode >}}a +{{< fatecode >}}(switch [T = COMPUTATION] +   ([V0 = COMPUTATION] [C0 = COMPUTATION]) +   ... +   ([VN = BOOL] [CN = COMPUTATION]) +   [D = COMPUTATION] +){{< /fatecode >}}a  Returns the first `CI` such that `VI` is equal to `T`. If there is not such  `VI`, returns `[D]`. diff --git a/content/fate_v1/computations/lambda_functions/_index.md b/content/fate_v1/computations/lambda_functions/_index.md index 35485a3..7992b54 100644 --- a/content/fate_v1/computations/lambda_functions/_index.md +++ b/content/fate_v1/computations/lambda_functions/_index.md @@ -7,17 +7,26 @@ corresponds to the function itself, the `eval` computation must be used to  obtain the value that the function computes.  ### DEFINITION -{{< fatecode >}}(lambda (([T0 = TYPE] {S0 = String}) ... ([TN = TYPE] {SN = String})) [COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(lambda +   (([T0 = TYPE] {S0 = String}) ... ([TN = TYPE] {SN = String})) +   [COMPUTATION] +){{< /fatecode >}}  Returns a lambda function taking `S0` ... `SN` of types `T0` ... `TN` as  arguments and evaluating to `[COMPUTATION]`.  ### EVALUATION -{{< fatecode >}}(eval [REFERENCE] [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}} +{{< fatecode >}}(eval [LAMBDA O (C0 ... CN)] [C0 = COMPUTATION] ... [CN = COMPUTATION]){{< /fatecode >}}  Returns the result of evaluating the lambda function at `[REFERENCE]` given the  parameters `C0` ... `CN`. +### PARTIAL EVALUATION +{{< fatecode >}}(partial [LAMBDA O (C0 ... CN)] [C0 = COMPUTATION] ... [CM = COMPUTATION]){{< /fatecode >}} + +Returns a lambda function corresponding to the `[LAMBDA O (C0 ... CN)]` in which +the first M parameters have already been filled with `C0` ... `CM`. +  ## Examples  {{< fatecode >}}(lambda ( (int i) )     (+ (var i) 1) diff --git a/content/fate_v1/computations/text/_index.md b/content/fate_v1/computations/text/_index.md index b91a75f..4f6f520 100644 --- a/content/fate_v1/computations/text/_index.md +++ b/content/fate_v1/computations/text/_index.md @@ -9,3 +9,8 @@ title: Text  ### NEW LINE  {{< fatecode >}}(newline){{< /fatecode >}} + +### JOIN +{{< fatecode >}}(join_text [TEXT LIST|TEXT SET] [TEXT]){{< /fatecode >}} +Returns a text value corresponding to all elements of the text collection being +appended, with `[TEXT]` having been put in between each pair. | 


