9Sets are constructed with `++silt`. A set is a non-ordered
10collection of unique elements.
13(silt `(list @t)`['urbit' 'arvo' 'hoon' 'arvo' ~])
16We'll refer to this particular set as `s` in the exercises. It
17is of type `(set @t)` since each element is a `@t`.
19The `++in` core contains library functions for dealing with sets.
20For example, `++has:in` checks whether an element is in the set.
21Thus, `(~(has in s) 'arvo')` returns yes. To complete these
22exercises, you'll need to refer to the [library reference for
23`++in`](/docs/hoon/library/2h).
251. Create another set, `l`, with members `'c'`, `'hoon'`,
26 `'javacript'`, `'python'`.
281. At the dojo, take the union of `s` and `l`. Delete
29 `'javascript'` from the result, and add `'coffescript'`.
311. Create an alphabetized list of the members of the set created
32 in the previous exercise.
341. Take the Cartesian product of `s` and `l`. The Cartesian
35 product of two sets is the set of all cells `[a b]` where
36 `a` is in `s` and `b` is in `l`.
38The `++by` core is to maps as `++in` is to sets. Refer to its
39[library reference](/docs/hoon/library/2i). Note that since a
40map is basically a set of pairs (although not every set of pairs
41is a map), most functions in `++in` have analogues in `++by`.
43The constructor for maps is `++malt`.
46(malt `(list {@t @ud})`[['kaylee' 3] ['wash' 2] ['mal' 4] ['summer' 1] ~])
511. Create another map, `s`, with `'spring'` mapped to `1`,
52 `'summer'` mapped to `2`, `'autumn'` mapped to `'3'`, and
53 `'winter'` mapped to `4`.
551. In `m`, change the value at `'mal'` to 5 and add `'cobb'`
581. Take the union of `m` and `s`, then get the value at the key
59 `summer`. Try taking the union of `s` and `m` (i.e. flip the
60 order) and see if it makes a difference. Try intersecting
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list