2title = "5a: Compiler Utilities"
7These functions are used internally by the compiler. They should not be used
8directly and are only listed here for completeness.
16This function is extremely large, please refer to `hoon.hoon` for the source.
27++ bool `type`(fork [%atom %f `0] [%atom %f `1] ~)
41 |= [hed=type tal=type]
43 ?:(=(%void hed) %void ?:(=(%void tal) %void [%cell hed tal]))
57 |= [pac=type con=coil]
59 ?:(=(%void pac) %void [%core pac con])
72 |= [p=(pair type note) q=type]
90 |= [giz=$@(term tune) der=type]
113 ?: ?=([* ~ ~] lez) n.lez
118 ?: =(%void i.yed) lez
119 ?: ?=([%fork *] i.yed) (~(uni in lez) p.i.yed)
120 (~(put in lez) i.yed)
153 |= [mal=nock buz=nock]
155 ?: ?&(?=([%0 *] mal) !=(0 p.mal))
156 ?: ?&(?=([%0 *] buz) !=(0 p.buz))
157 [%0 (peg p.mal p.buz)]
158 ?: ?=([%2 [%0 *] [%0 *]] buz)
159 [%2 [%0 (peg p.mal p.p.buz)] [%0 (peg p.mal p.q.buz)]]
161 ?: ?=([^ [%0 %1]] mal)
179 |= [pex=nock yom=nock woq=nock]
199 |= [vur=nock sed=nock]
201 :: this optimization can remove crashes which are essential
203 :: ?: ?=([[%0 *] [%0 *]] +<)
204 :: ?: ?&(=(+(p.vur) p.sed) =((div p.vur 2) (div p.sed 2)))
205 :: [%0 (div p.vur 2)]
207 ?: ?=([[%1 *] [%1 *]] +<)
223 |= [yaz=term wix=term]
225 |= mot=@ta ^- [p=@ q=@ta]
229 =+ tyl=(rsh [3 (dec len)] mot)
230 ?: &((gte tyl 'A') (lte tyl 'Z'))
231 [(sub tyl 64) (end [3 (dec len)] mot)]
233 =+ [yoz=(fiz yaz) wux=(fiz wix)]
236 &(!=(0 p.wux) (lte p.wux p.yoz))
240 ?& =((end 3 p.yoz) (end 3 p.wux))
241 $(p.yoz (rsh 3 p.yoz), p.wux (rsh 3 p.wux))
258 |= [bos=nock nif=nock]
270 * [%6 bos nif [%1 1]]
288 [%6 dyr [%1 1] [%1 0]]
302 |= [bos=nock nif=nock]
314 * [%6 bos [%1 0] nif]
330 |= [a=axis pac=(list (pair axis nock))]
331 |^ =/ rel=(map axis nock) (roll pac insert)
332 =/ ord=(list axis) (sort ~(tap in ~(key by rel)) gth)
337 =/ c=nock (~(got by rel) b)
338 =/ d=nock $(ord t.ord)
342 |= [container=axis contained=axis]
344 =/ big=@ (met 0 container)
345 =/ small=@ (met 0 contained)
347 =/ dif=@ (sub small big)
348 =(container (rsh [0 dif] contained))
362 |= [e=[axe=axis fol=nock] n=(map axis nock)]
375 |= [[axe=axis fol=nock] m=_n]
376 ?. (contains axe.e axe) m
378 =/ sib (sibling axe.e)
379 =/ un (~(get by n) sib)
380 ?~ un (~(put by n) axe.e fol.e)
381 :: replace sibling with parent
406 ?:(rad [%rock p.lot] [%sand p.lot])
411 ?@(p.lot [%sand %$ p.lot] [$(p.lot -.p.lot) $(p.lot +.p.lot)])
414 [%cltr (turn p.lot |=(a=coin ^$(lot a)))]
429 |= [cog=term dab=(map term hoon)]
431 |- ^- (unit [p=axis q=hoon])
436 ?:(=(cog p.n.dab) [~ axe q.n.dab] ~)
440 [~ (peg axe 2) q.n.dab]
443 $(axe (peg axe 3), dab r.dab)
447 [~ (peg axe 2) q.n.dab]
449 $(axe (peg axe 3), dab l.dab)
454 [~ (peg axe 2) q.n.dab]
456 $(axe (peg axe 6), dab l.dab)
457 $(axe (peg axe 7), dab r.dab)
472 |= [cog=term dom=(map term tome)]
474 |- ^- (unit [p=axis q=hoon])
479 %+ bind (look cog q.q.n.dom)
480 |=((pair axis hoon) [(peg axe p) q])
483 =+ yep=(look cog q.q.n.dom)
485 [~ (peg (peg axe 2) p.u.yep) q.u.yep]
486 $(axe (peg axe 3), dom r.dom)
489 =+ yep=(look cog q.q.n.dom)
491 [~ (peg (peg axe 2) p.u.yep) q.u.yep]
492 $(axe (peg axe 3), dom l.dom)
495 =+ yep=(look cog q.q.n.dom)
497 [~ (peg (peg axe 2) p.u.yep) q.u.yep]
498 =+ pey=$(axe (peg axe 6), dom l.dom)
500 $(axe (peg axe 7), dom r.dom)
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