on master help sign in
updated sieve.hoon to new syntax as well
commit4016255be20991e97324030b19b8933a7e4ffbd5 authorJoshua Reagan <joshuareagan@users.noreply.github.com> dateTue 8 May 2018, 07:00 (8 years ago) parent8f4837f
1 file changed+14−14
docs/hoon/examples.md+14−14
docs/hoon/examples.md+14−14
@@ -20,24 +20,24 @@ A function that produces the list of primes less than or equal to
2020its argument, an atom:
2121
2222```
23−|= thru/@ :: 1
23+|= thru=@ :: 1
2424^- (list @) :: 2
25−=/ field/(set @) (silt (gulf 2 thru)) :: 3
25+=/ field=(set @) (sy (gulf 2 thru)) :: 3
2626=< abet:main :: 4
2727|% :: 5
2828++ abet :: 6
2929 (sort ~(tap in field) lth) :: 7
3030:: :: 8
3131++ main :: 9
32− =/ factor/@ 2 :: 10
32+ =/ factor=@ 2 :: 10
3333 |- ^+ ..main :: 11
3434 ?: (gth (mul factor factor) thru) :: 12
3535 ..main :: 13
3636 $(factor +(factor), ..main (reap factor)) :: 14
3737:: :: 15
3838++ reap :: 16
39− |= factor/@ :: 17
40− =/ count/@ (mul 2 factor) :: 18
39+ |= factor=@ :: 17
40+ =/ count=@ (mul 2 factor) :: 18
4141 |- ^+ ..reap :: 19
4242 ?: (gth count thru) :: 20
4343 ..reap :: 21
@@ -51,9 +51,9 @@ its argument, an atom:
5151## `sieve`: explanation
5252
5353```
54−|= thru/@ :: 1
54+|= thru=@ :: 1
5555^- (list @) :: 2
56−=/ field/(set @) (silt (gulf 2 thru)) :: 3
56+=/ field=(set @) (sy (gulf 2 thru)) :: 3
5757```
5858
5959Line `1`: we are building a gate (function) whose sample
@@ -62,7 +62,7 @@ Line `1`: we are building a gate (function) whose sample
6262Line `2`: the product of this gate is a list of atoms.
6363
6464Line `3`: we introduce a variable `field`, whose type is a set of
65−atoms. The `silt` function converts a list to a set. The `gulf`
65+atoms. The `sy` function converts a list to a set. The `gulf`
6666function creates the range `2` through `thru` inclusive, as a
6767list of atoms.
6868
@@ -90,7 +90,7 @@ the set as a list. We sort this list in ascending order with
9090
9191```
9292++ main :: 9
93− =/ factor/@ 2 :: 10
93+ =/ factor=@ 2 :: 10
9494 |- ^+ ..main :: 11
9595```
9696
@@ -116,8 +116,8 @@ replacing the core with a version sieved by `reap`.
116116
117117```
118118++ reap :: 16
119− |= factor/@ :: 17
120− =/ count/@ (mul 2 factor) :: 18
119+ |= factor=@ :: 17
120+ =/ count=@ (mul 2 factor) :: 18
121121```
122122
123123Lines `16` and `17`: the `reap` arm, which produces a gate that
@@ -149,9 +149,9 @@ multiple of `factor`, and deleting it from `field`.
149149
150150Finally, the same code in a more concise "kernel" style.
151151```
152−|= top/@
152+|= top=@
153153^- (list @)
154−=+ fed=(silt (gulf 2 top))
154+=+ fed=(sy (gulf 2 top))
155155=< abet:main
156156|%
157157++ abet (sort (~(tap in fed)) lth)
@@ -163,7 +163,7 @@ Finally, the same code in a more concise "kernel" style.
163163 $(fac +(fac), ..main (reap fac))
164164::
165165++ reap
166− |= fac/@
166+ |= fac=@
167167 =+ cot=(mul 2 fac)
168168 |- ^+ ..reap
169169 ?: (gth cot top)