on master help sign in
fixed the shuffle-deck arm
a4fefdapoprox
learn/hoon/hoon-tutorial/libraries.md+10−8
@@ -46,10 +46,11 @@ In Hoon, like in other languages, it's often useful to create a library for othe
46 :_ shuffled
46 :_ shuffled
47 (snag 0 unshuffled)
47 (snag 0 unshuffled)
48 =^ index random (rads:random remaining)
48 =^ index random (rads:random remaining)
49− %^ $
49+ %= $
50− shuffled (snag index unshuffled)^shuffled
50+ shuffled (snag index unshuffled)^shuffled
51− remaining (dec remaining)
51+ remaining (dec remaining)
52− unshuffled (oust [index 1] unshuffled)
52+ unshuffled (oust [index 1] unshuffled)
53+ ==
53++ draw
54++ draw
54 |= [n=@ud d=deck]
55 |= [n=@ud d=deck]
55 ^- [hand=deck rest=deck]
56 ^- [hand=deck rest=deck]
@@ -136,10 +137,11 @@ The `?+` rune is the rune to switch against a value with a default. The default
136 :_ shuffled
137 :_ shuffled
137 (snag 0 unshuffled)
138 (snag 0 unshuffled)
138 =^ index random (rads:random remaining)
139 =^ index random (rads:random remaining)
139− %^ $
140+ %= $
140− shuffled (snag index unshuffled)^shuffled
141+ shuffled (snag index unshuffled)^shuffled
141− remaining (dec remaining)
142+ remaining (dec remaining)
142− unshuffled (oust [index 1] unshuffled)
143+ unshuffled (oust [index 1] unshuffled)
144+ ==
143```
145```
144
146
145Finally, in the code above, we come to `shuffle-deck`. This gate takes two arguments: a `deck`, and a `@` as a bit of `entropy` to seed the `og` core. It's going to produce a `deck`.
147Finally, in the code above, we come to `shuffle-deck`. This gate takes two arguments: a `deck`, and a `@` as a bit of `entropy` to seed the `og` core. It's going to produce a `deck`.