summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-12-22 04:08:34 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-12-22 04:08:34 +0100
commitd0d6117176d68b2345d36e81ccdaa447e9caa724 (patch)
tree6cb8f3e4735a695be8c0922434df4c60f7cf82c7 /content/fate_v1/instructions/collections
Moving to Hugo.
Diffstat (limited to 'content/fate_v1/instructions/collections')
-rw-r--r--content/fate_v1/instructions/collections/_index.md72
1 files changed, 72 insertions, 0 deletions
diff --git a/content/fate_v1/instructions/collections/_index.md b/content/fate_v1/instructions/collections/_index.md
new file mode 100644
index 0000000..8d646ee
--- /dev/null
+++ b/content/fate_v1/instructions/collections/_index.md
@@ -0,0 +1,72 @@
+---
+title: Collections
+---
+Fate supports two types of collections: `[LIST]`, which are basic, unordered
+lists; and `[SET]`, which are ordered lists, but only useable with
+`[COMPARABLE]` elements.
+
+### ADDING A MEMBER
+{{< fatecode >}}(add_element! [COMPUTATION*] [COLLECTION VAR]){{< /fatecode >}}
+
+Adds `[COMPUTATION*]` to `[COLLECTION VAR]`. If `[COLLECTION VAR]` is a
+`[LIST]`, the new member is added at the end of the list. Note that
+`[COMPUTATION*]` does not support use of the variable shorthand.
+
+### ADDING A MEMBER AT INDEX
+{{< fatecode >}}(add_element_at! [INT] [COMPUTATION*] [LIST VAR]){{< /fatecode >}}
+
+Adds `[COMPUTATION*]` to `[LIST VAR]` at index `[INT]`. If `[INT]` is less than
+0, the element is added at the start of the list, and if `[INT]` is greater or
+equal to the size of the list, the element is added at the end of the list. Note
+that `[COMPUTATION*]` does not support use of the variable shorthand.
+
+### ADDING MEMBERS
+{{< fatecode >}}(add_all_elements! [COLLECTION] [COLLECTION VAR]){{< /fatecode >}}
+
+Adds all the elements of `[COLLECTION]` to `[COLLECTION VAR]`. If
+`[COLLECTION VAR]` is a `[LIST]`, the new members are added at the end of the
+list.
+
+### EMPTYING COLLECTIONS
+{{< fatecode >}}(clear [COLLECTION]){{< /fatecode >}}
+
+Removes all members of `[COLLECTION]`.
+
+### REMOVING MEMBER
+{{< fatecode >}}(remove [COMPUTATION] [COLLECTION]){{< /fatecode >}}
+
+Removes the first member of `[COLLECTION]` equal to `[COMPUTATION]`.
+
+### REMOVING MEMBERS
+{{< fatecode >}}(remove_all [COMPUTATION] [COLLECTION]){{< /fatecode >}}
+
+Removes all instances of `[COMPUTATION]` from `[COLLECTION]`.
+
+### REMOVING AT INDEX
+{{< fatecode >}}(remove_at [INT] [COLLECTION]){{< /fatecode >}}
+
+Removes the element of `[COLLECTION]` at `[INT]`.
+
+### REVERSING LISTS
+{{< fatecode >}}(reverse [LIST]){{< /fatecode >}}
+
+Reverses the order of the members of `[LIST]`.
+
+### FILTER ELEMENTS
+{{< fatecode >}}(filter! <LAMBDA BOOL (X)> [X COLLECTION VAR]){{< /fatecode >}}
+{{< fatecode >}}(filter! <LAMBDA BOOL (X Y0 ... YN)> [X COLLECTION VAR] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}}
+Modifies `[X COLLECTION VAR]` so that 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.
+
+### FILTER ELEMENTS (INDEXED)
+{{< fatecode >}}(indexed_filter! <LAMBDA BOOL (INT X)> [X COLLECTION VAR]){{< /fatecode >}}
+{{< fatecode >}}(indexed_filter! <LAMBDA BOOL (INT X Y0 ... YN)> [X COLLECTION VAR] [Y0 COMPUTATION*] ... [YN COMPUTATION*]){{< /fatecode >}}
+Modifies `[X COLLECTION VAR]` so that only the elements for which
+`<LAMBDA BOOL (INT X)>` (with the `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.