@@ -54,6 +54,7 @@ Lets look at two examples of using `fold`.
5454
5555Here we have a call to `fold` that we can see will produce a `(list @)` from a list of `@`. The first argument is a cell of `~` and `~[1 2 3 4]`.
5656
57+
5758The gate will simply add two to each element `e` and append that to the front of `s`. Let's run this in the `dojo`:
5859
5960```
@@ -64,6 +65,7 @@ The gate will simply add two to each element `e` and append that to the front of
6465 :_ s
6566 (add 2 e)
6667~[6 5 4 3]
68+
6769~zod:dojo>
6870```
6971
@@ -71,6 +73,7 @@ The list is in reverse order simply because it's easier to add to the front of a
7173
7274But `fold` does not have to produce a `list`. Let's look at another example:
7375
76+
7477```
7578%+ (fold @ @)
7679 [0 ~[1 2 3 4]]
@@ -78,9 +81,10 @@ But `fold` does not have to produce a `list`. Let's look at another example:
7881(add e s)
7982```
8083
84+
8185Here `fold` will produce a gate that takes an `atom` and applies a gate to a `list` of `atoms`. The difference here is that this call will produce a sum of the elements of the list, rather than the list itself.
8286
8387The key takeaway from both of these examples is that the gates provided are _iron polymorphic_ with respect to the definition of the type in `fold`. They are iron polymorphic because samples `s` and `e` nest under the types `state` and `elem`. In second case case, that's because when we provided those to `fold`, it was was stated they were `@` and `@`. In the first case, we stated that `state` was `(list @)` and `elem` was `@`. In both cases, the sample of each gate nest inside the types defined when we called the wet gate `fold`.
8488
8589
86−[Next Up: Reading -- Gall](../gall)
90+[Next Up: Reading -- Gall](../gall)