From 30faf9d0a870ec35088c7f26b6b82e677db25edb Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 29 Jan 2016 15:12:08 -0800 Subject: [PATCH] pre-merge: remove urb/zod/web/docs, coffee/stylus source --- web/docs.md | 24 - web/docs/dev.md | 28 - web/docs/dev/arvo.md | 13 - web/docs/dev/client.md | 11 - web/docs/dev/client/tree.md | 59 - web/docs/dev/contributing.md | 213 - web/docs/dev/hoon.md | 24 - web/docs/dev/hoon/leap-in.md | 8 - web/docs/dev/hoon/leap-in/1-basic.md | 421 - web/docs/dev/hoon/leap-in/2-network.md | 335 - web/docs/dev/hoon/leap-in/3-app.md | 55 - web/docs/dev/hoon/library.md | 7 - web/docs/dev/hoon/library/0.md | 37 - web/docs/dev/hoon/library/1.md | 1786 -- web/docs/dev/hoon/library/2a.md | 450 - web/docs/dev/hoon/library/2b.md | 907 - web/docs/dev/hoon/library/2c.md | 2134 -- web/docs/dev/hoon/library/2da.md | 437 - web/docs/dev/hoon/library/2db.md | 813 - web/docs/dev/hoon/library/2dc.md | 221 - web/docs/dev/hoon/library/2dd.md | 69 - web/docs/dev/hoon/library/2ea.md | 162 - web/docs/dev/hoon/library/2eb.md | 63 - web/docs/dev/hoon/library/2ec.md | 652 - web/docs/dev/hoon/library/2ed.md | 289 - web/docs/dev/hoon/library/2ee.md | 195 - web/docs/dev/hoon/library/2ef.md | 648 - web/docs/dev/hoon/library/2eg.md | 160 - web/docs/dev/hoon/library/2eh.md | 531 - web/docs/dev/hoon/library/2ei.md | 107 - web/docs/dev/hoon/library/2ej.md | 561 - web/docs/dev/hoon/library/2ek.md | 162 - web/docs/dev/hoon/library/2el.md | 1871 -- web/docs/dev/hoon/library/2em.md | 758 - web/docs/dev/hoon/library/2en.md | 378 - web/docs/dev/hoon/library/2eo.md | 453 - web/docs/dev/hoon/library/2ep.md | 586 - web/docs/dev/hoon/library/2ew.md | 439 - web/docs/dev/hoon/library/2ex.md | 717 - web/docs/dev/hoon/library/2ey.md | 399 - web/docs/dev/hoon/library/2ez.md | 250 - web/docs/dev/hoon/library/3ba.md | 67 - web/docs/dev/hoon/library/3bb.md | 600 - web/docs/dev/hoon/library/3bc.md | 382 - web/docs/dev/hoon/library/3bd.md | 1807 -- web/docs/dev/hoon/library/3be.md | 1316 -- web/docs/dev/hoon/library/3bf.md | 267 - web/docs/dev/hoon/library/3bg.md | 943 - web/docs/dev/hoon/library/3bh.md | 479 - web/docs/dev/hoon/library/3bi.md | 1483 -- web/docs/dev/hoon/principles.md | 18 - web/docs/dev/hoon/principles/0-nouns.md | 286 - web/docs/dev/hoon/principles/1-twigs.md | 286 - web/docs/dev/hoon/principles/2-syntax.md | 475 - web/docs/dev/hoon/principles/3-program.md | 350 - web/docs/dev/hoon/principles/4-functions.md | 327 - web/docs/dev/hoon/reference.md | 7 - web/docs/dev/hoon/reference/odors.md | 686 - web/docs/dev/hoon/reference/pronunciation.md | 68 - web/docs/dev/hoon/runes.md | 132 - web/docs/dev/hoon/runes/bc.md | 49 - web/docs/dev/hoon/runes/bc/bcbr.md | 52 - web/docs/dev/hoon/runes/bc/bccb.md | 43 - web/docs/dev/hoon/runes/bc/bccl.md | 44 - web/docs/dev/hoon/runes/bc/bccm.md | 61 - web/docs/dev/hoon/runes/bc/bccn.md | 64 - web/docs/dev/hoon/runes/bc/bckt.md | 49 - web/docs/dev/hoon/runes/bc/bcls.md | 62 - web/docs/dev/hoon/runes/bc/bcpm.md | 39 - web/docs/dev/hoon/runes/bc/bcpt.md | 37 - web/docs/dev/hoon/runes/bc/bctr.md | 38 - web/docs/dev/hoon/runes/bc/bcts.md | 53 - web/docs/dev/hoon/runes/bc/bcwt.md | 48 - web/docs/dev/hoon/runes/bc/bczp.md | 40 - web/docs/dev/hoon/runes/br.md | 47 - web/docs/dev/hoon/runes/br/brcb.md | 118 - web/docs/dev/hoon/runes/br/brcn.md | 135 - web/docs/dev/hoon/runes/br/brdt.md | 114 - web/docs/dev/hoon/runes/br/brfs.md | 105 - web/docs/dev/hoon/runes/br/brhp.md | 78 - web/docs/dev/hoon/runes/br/brkt.md | 103 - web/docs/dev/hoon/runes/br/brls.md | 63 - web/docs/dev/hoon/runes/br/brtr.md | 73 - web/docs/dev/hoon/runes/br/brts.md | 71 - web/docs/dev/hoon/runes/br/brwt.md | 54 - web/docs/dev/hoon/runes/cl.md | 44 - web/docs/dev/hoon/runes/cl/clcb.md | 56 - web/docs/dev/hoon/runes/cl/clfs.md | 47 - web/docs/dev/hoon/runes/cl/clhp.md | 85 - web/docs/dev/hoon/runes/cl/clkt.md | 68 - web/docs/dev/hoon/runes/cl/clls.md | 61 - web/docs/dev/hoon/runes/cl/clsg.md | 69 - web/docs/dev/hoon/runes/cl/cltr.md | 57 - web/docs/dev/hoon/runes/cn.md | 41 - web/docs/dev/hoon/runes/cn/cncb.md | 74 - web/docs/dev/hoon/runes/cn/cncl.md | 55 - web/docs/dev/hoon/runes/cn/cndt.md | 62 - web/docs/dev/hoon/runes/cn/cnhp.md | 39 - web/docs/dev/hoon/runes/cn/cnkt.md | 46 - web/docs/dev/hoon/runes/cn/cnls.md | 59 - web/docs/dev/hoon/runes/cn/cnsg.md | 70 - web/docs/dev/hoon/runes/cn/cntr.md | 60 - web/docs/dev/hoon/runes/cn/cnts.md | 71 - web/docs/dev/hoon/runes/cn/cnzy.md | 40 - web/docs/dev/hoon/runes/cn/cnzz.md | 43 - web/docs/dev/hoon/runes/dt.md | 33 - web/docs/dev/hoon/runes/dt/dtkt.md | 56 - web/docs/dev/hoon/runes/dt/dtls.md | 66 - web/docs/dev/hoon/runes/dt/dttr.md | 57 - web/docs/dev/hoon/runes/dt/dtts.md | 77 - web/docs/dev/hoon/runes/dt/dtwt.md | 59 - web/docs/dev/hoon/runes/dt/dtzy.md | 47 - web/docs/dev/hoon/runes/dt/dtzz.md | 52 - web/docs/dev/hoon/runes/hx.md | 19 - web/docs/dev/hoon/runes/hx/hxgl.md | 62 - web/docs/dev/hoon/runes/hx/hxgr.md | 83 - web/docs/dev/hoon/runes/kt.md | 40 - web/docs/dev/hoon/runes/kt/ktbr.md | 61 - web/docs/dev/hoon/runes/kt/ktdt.md | 47 - web/docs/dev/hoon/runes/kt/kthp.md | 70 - web/docs/dev/hoon/runes/kt/ktls.md | 80 - web/docs/dev/hoon/runes/kt/ktpm.md | 46 - web/docs/dev/hoon/runes/kt/ktsg.md | 47 - web/docs/dev/hoon/runes/kt/ktts.md | 52 - web/docs/dev/hoon/runes/kt/ktwt.md | 45 - web/docs/dev/hoon/runes/sg.md | 32 - web/docs/dev/hoon/runes/sg/sgbc.md | 43 - web/docs/dev/hoon/runes/sg/sgbr.md | 36 - web/docs/dev/hoon/runes/sg/sgcb.md | 41 - web/docs/dev/hoon/runes/sg/sgcn.md | 64 - web/docs/dev/hoon/runes/sg/sgfs.md | 44 - web/docs/dev/hoon/runes/sg/sggl.md | 50 - web/docs/dev/hoon/runes/sg/sggr.md | 48 - web/docs/dev/hoon/runes/sg/sgls.md | 50 - web/docs/dev/hoon/runes/sg/sgpm.md | 64 - web/docs/dev/hoon/runes/sg/sgts.md | 49 - web/docs/dev/hoon/runes/sg/sgwt.md | 64 - web/docs/dev/hoon/runes/sg/sgzp.md | 59 - web/docs/dev/hoon/runes/sm.md | 42 - web/docs/dev/hoon/runes/sm/smcl.md | 63 - web/docs/dev/hoon/runes/sm/smcn.md | 93 - web/docs/dev/hoon/runes/sm/smdq.md | 56 - web/docs/dev/hoon/runes/sm/smhp.md | 55 - web/docs/dev/hoon/runes/sm/smls.md | 58 - web/docs/dev/hoon/runes/sm/smsg.md | 162 - web/docs/dev/hoon/runes/sm/smsm.md | 52 - web/docs/dev/hoon/runes/sm/smtr.md | 61 - web/docs/dev/hoon/runes/sm/smzz.md | 84 - web/docs/dev/hoon/runes/ts.md | 49 - web/docs/dev/hoon/runes/ts/tsbr.md | 55 - web/docs/dev/hoon/runes/ts/tscl.md | 57 - web/docs/dev/hoon/runes/ts/tsdt.md | 55 - web/docs/dev/hoon/runes/ts/tsgl.md | 63 - web/docs/dev/hoon/runes/ts/tsgr.md | 68 - web/docs/dev/hoon/runes/ts/tshp.md | 62 - web/docs/dev/hoon/runes/ts/tskt.md | 66 - web/docs/dev/hoon/runes/ts/tsls.md | 65 - web/docs/dev/hoon/runes/ts/tssg.md | 49 - web/docs/dev/hoon/runes/ts/tstr.md | 51 - web/docs/dev/hoon/runes/wt.md | 39 - web/docs/dev/hoon/runes/wt/wtbr.md | 55 - web/docs/dev/hoon/runes/wt/wtcl.md | 54 - web/docs/dev/hoon/runes/wt/wtdt.md | 58 - web/docs/dev/hoon/runes/wt/wtgl.md | 52 - web/docs/dev/hoon/runes/wt/wtgr.md | 52 - web/docs/dev/hoon/runes/wt/wthp.md | 99 - web/docs/dev/hoon/runes/wt/wthz.md | 52 - web/docs/dev/hoon/runes/wt/wtkt.md | 70 - web/docs/dev/hoon/runes/wt/wtkz.md | 34 - web/docs/dev/hoon/runes/wt/wtls.md | 115 - web/docs/dev/hoon/runes/wt/wtlz.md | 35 - web/docs/dev/hoon/runes/wt/wtpm.md | 49 - web/docs/dev/hoon/runes/wt/wtpt.md | 59 - web/docs/dev/hoon/runes/wt/wtpz.md | 34 - web/docs/dev/hoon/runes/wt/wtsg.md | 50 - web/docs/dev/hoon/runes/wt/wtsz.md | 37 - web/docs/dev/hoon/runes/wt/wtts.md | 45 - web/docs/dev/hoon/runes/wt/wttz.md | 35 - web/docs/dev/hoon/runes/wt/wtzp.md | 46 - web/docs/dev/hoon/runes/zp.md | 23 - web/docs/dev/hoon/runes/zp/zpcb.md | 57 - web/docs/dev/hoon/runes/zp/zpcm.md | 36 - web/docs/dev/hoon/runes/zp/zpfs.md | 64 - web/docs/dev/hoon/runes/zp/zpgr.md | 62 - web/docs/dev/hoon/runes/zp/zpsm.md | 43 - web/docs/dev/hoon/runes/zp/zpts.md | 55 - web/docs/dev/hoon/runes/zp/zpwt.md | 49 - web/docs/dev/hoon/runes/zp/zpzp.md | 48 - web/docs/dev/interpreter.md | 12 - web/docs/dev/interpreter/u3.md | 1570 -- web/docs/dev/nock.md | 52 - web/docs/dev/nock/reference.md | 737 - web/docs/dev/nock/tutorial.md | 1044 - web/docs/theory.md | 26 - web/docs/theory/network-goals.md | 565 - web/docs/theory/old.md | 21 - web/docs/theory/part-i.md | 512 - web/docs/theory/part-ii.md | 462 - web/docs/theory/whitepaper.md | 2346 -- web/docs/user.md | 25 - web/docs/user/appliance.md | 274 - web/docs/user/basic.md | 143 - web/docs/user/clay.md | 418 - web/docs/user/dojo.md | 547 - web/docs/user/install.md | 111 - web/docs/user/intro.md | 137 - web/docs/user/launch.md | 112 - web/docs/user/talk.md | 314 - web/docs/user/tour.md | 209 - web/src/tree/css/fonts.styl | 69 - web/src/tree/css/leads.styl | 175 - web/src/tree/css/main.styl | 447 - web/src/tree/css/mobile.styl | 138 - web/src/tree/css/posts.styl | 50 - web/src/tree/css/video.styl | 15 - web/src/tree/js/actions/TreeActions.coffee | 28 - .../tree/js/components/AnchorComponent.coffee | 164 - web/src/tree/js/components/Async.coffee | 67 - .../tree/js/components/BodyComponent.coffee | 186 - web/src/tree/js/components/CodeMirror.coffee | 8 - web/src/tree/js/components/Components.coffee | 11 - .../tree/js/components/EmailComponent.coffee | 45 - .../tree/js/components/KidsComponent.coffee | 42 - .../tree/js/components/ListComponent.coffee | 109 - .../tree/js/components/LoadComponent.coffee | 18 - web/src/tree/js/components/Reactify.coffee | 30 - .../tree/js/components/SearchComponent.coffee | 48 - .../tree/js/components/TocComponent.coffee | 71 - web/src/tree/js/dispatcher/Dispatcher.coffee | 13 - web/src/tree/js/main.coffee | 135 - web/src/tree/js/package.json | 27 - .../js/persistence/TreePersistence.coffee | 26 - web/src/tree/js/stores/TreeStore.coffee | 130 - web/src/tree/readme.md | 12 - web/talk/css/fonts.styl | 84 - web/talk/css/main.styl | 565 - web/talk/css/mobile.styl | 91 - web/talk/js/actions/MessageActions.coffee | 75 - web/talk/js/actions/StationActions.coffee | 31 - web/talk/js/components/MemberComponent.coffee | 12 - .../js/components/MessagesComponent.coffee | 213 - .../js/components/StationComponent.coffee | 119 - .../js/components/StationsComponent.coffee | 61 - web/talk/js/components/TalkComponent.coffee | 15 - .../js/components/WritingComponent.coffee | 284 - web/talk/js/dep/director.js | 7 - web/talk/js/dispatcher/Dispatcher.coffee | 13 - web/talk/js/main.coffee | 42 - web/talk/js/module.js | 6360 ----- web/talk/js/move.coffee | 66 - web/talk/js/package.json | 18 - .../js/persistence/MessagePersistence.coffee | 45 - .../js/persistence/StationPersistence.coffee | 55 - web/talk/js/stores/MessageStore.coffee | 107 - web/talk/js/stores/StationStore.coffee | 165 - web/talk/js/test.js | 19439 ---------------- web/talk/js/util.coffee | 93 - web/talklog/js/MessagesComponent.coffee | 82 - web/talklog/js/main.coffee | 3 - web/talklog/js/util.coffee | 85 - web/work/css/fonts.styl | 84 - web/work/css/main.styl | 352 - web/work/css/mobile.styl | 86 - web/work/js/actions/WorkActions.coffee | 78 - web/work/js/components/FieldComponent.coffee | 95 - web/work/js/components/FilterComponent.coffee | 60 - web/work/js/components/ItemComponent.coffee | 162 - web/work/js/components/ListComponent.coffee | 175 - .../js/components/ListeningComponent.coffee | 7 - web/work/js/components/SortComponent.coffee | 27 - web/work/js/components/WorkComponent.coffee | 12 - web/work/js/dispatcher/dispatcher.coffee | 13 - web/work/js/main.coffee | 5 - web/work/js/package.json | 17 - web/work/js/persistence/Persistence.coffee | 21 - web/work/js/stores/WorkStore.coffee | 153 - web/work/js/util.coffee | 38 - 277 files changed, 76031 deletions(-) delete mode 100644 web/docs.md delete mode 100644 web/docs/dev.md delete mode 100644 web/docs/dev/arvo.md delete mode 100644 web/docs/dev/client.md delete mode 100644 web/docs/dev/client/tree.md delete mode 100644 web/docs/dev/contributing.md delete mode 100644 web/docs/dev/hoon.md delete mode 100644 web/docs/dev/hoon/leap-in.md delete mode 100644 web/docs/dev/hoon/leap-in/1-basic.md delete mode 100644 web/docs/dev/hoon/leap-in/2-network.md delete mode 100644 web/docs/dev/hoon/leap-in/3-app.md delete mode 100644 web/docs/dev/hoon/library.md delete mode 100644 web/docs/dev/hoon/library/0.md delete mode 100644 web/docs/dev/hoon/library/1.md delete mode 100644 web/docs/dev/hoon/library/2a.md delete mode 100644 web/docs/dev/hoon/library/2b.md delete mode 100644 web/docs/dev/hoon/library/2c.md delete mode 100644 web/docs/dev/hoon/library/2da.md delete mode 100644 web/docs/dev/hoon/library/2db.md delete mode 100644 web/docs/dev/hoon/library/2dc.md delete mode 100644 web/docs/dev/hoon/library/2dd.md delete mode 100644 web/docs/dev/hoon/library/2ea.md delete mode 100644 web/docs/dev/hoon/library/2eb.md delete mode 100644 web/docs/dev/hoon/library/2ec.md delete mode 100644 web/docs/dev/hoon/library/2ed.md delete mode 100644 web/docs/dev/hoon/library/2ee.md delete mode 100644 web/docs/dev/hoon/library/2ef.md delete mode 100644 web/docs/dev/hoon/library/2eg.md delete mode 100644 web/docs/dev/hoon/library/2eh.md delete mode 100644 web/docs/dev/hoon/library/2ei.md delete mode 100644 web/docs/dev/hoon/library/2ej.md delete mode 100644 web/docs/dev/hoon/library/2ek.md delete mode 100644 web/docs/dev/hoon/library/2el.md delete mode 100644 web/docs/dev/hoon/library/2em.md delete mode 100644 web/docs/dev/hoon/library/2en.md delete mode 100644 web/docs/dev/hoon/library/2eo.md delete mode 100644 web/docs/dev/hoon/library/2ep.md delete mode 100644 web/docs/dev/hoon/library/2ew.md delete mode 100644 web/docs/dev/hoon/library/2ex.md delete mode 100644 web/docs/dev/hoon/library/2ey.md delete mode 100644 web/docs/dev/hoon/library/2ez.md delete mode 100644 web/docs/dev/hoon/library/3ba.md delete mode 100644 web/docs/dev/hoon/library/3bb.md delete mode 100644 web/docs/dev/hoon/library/3bc.md delete mode 100644 web/docs/dev/hoon/library/3bd.md delete mode 100644 web/docs/dev/hoon/library/3be.md delete mode 100644 web/docs/dev/hoon/library/3bf.md delete mode 100644 web/docs/dev/hoon/library/3bg.md delete mode 100644 web/docs/dev/hoon/library/3bh.md delete mode 100644 web/docs/dev/hoon/library/3bi.md delete mode 100644 web/docs/dev/hoon/principles.md delete mode 100644 web/docs/dev/hoon/principles/0-nouns.md delete mode 100644 web/docs/dev/hoon/principles/1-twigs.md delete mode 100644 web/docs/dev/hoon/principles/2-syntax.md delete mode 100644 web/docs/dev/hoon/principles/3-program.md delete mode 100644 web/docs/dev/hoon/principles/4-functions.md delete mode 100644 web/docs/dev/hoon/reference.md delete mode 100644 web/docs/dev/hoon/reference/odors.md delete mode 100644 web/docs/dev/hoon/reference/pronunciation.md delete mode 100644 web/docs/dev/hoon/runes.md delete mode 100644 web/docs/dev/hoon/runes/bc.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcbr.md delete mode 100644 web/docs/dev/hoon/runes/bc/bccb.md delete mode 100644 web/docs/dev/hoon/runes/bc/bccl.md delete mode 100644 web/docs/dev/hoon/runes/bc/bccm.md delete mode 100644 web/docs/dev/hoon/runes/bc/bccn.md delete mode 100644 web/docs/dev/hoon/runes/bc/bckt.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcls.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcpm.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcpt.md delete mode 100644 web/docs/dev/hoon/runes/bc/bctr.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcts.md delete mode 100644 web/docs/dev/hoon/runes/bc/bcwt.md delete mode 100644 web/docs/dev/hoon/runes/bc/bczp.md delete mode 100644 web/docs/dev/hoon/runes/br.md delete mode 100644 web/docs/dev/hoon/runes/br/brcb.md delete mode 100644 web/docs/dev/hoon/runes/br/brcn.md delete mode 100644 web/docs/dev/hoon/runes/br/brdt.md delete mode 100644 web/docs/dev/hoon/runes/br/brfs.md delete mode 100644 web/docs/dev/hoon/runes/br/brhp.md delete mode 100644 web/docs/dev/hoon/runes/br/brkt.md delete mode 100644 web/docs/dev/hoon/runes/br/brls.md delete mode 100644 web/docs/dev/hoon/runes/br/brtr.md delete mode 100644 web/docs/dev/hoon/runes/br/brts.md delete mode 100644 web/docs/dev/hoon/runes/br/brwt.md delete mode 100644 web/docs/dev/hoon/runes/cl.md delete mode 100644 web/docs/dev/hoon/runes/cl/clcb.md delete mode 100644 web/docs/dev/hoon/runes/cl/clfs.md delete mode 100644 web/docs/dev/hoon/runes/cl/clhp.md delete mode 100644 web/docs/dev/hoon/runes/cl/clkt.md delete mode 100644 web/docs/dev/hoon/runes/cl/clls.md delete mode 100644 web/docs/dev/hoon/runes/cl/clsg.md delete mode 100644 web/docs/dev/hoon/runes/cl/cltr.md delete mode 100644 web/docs/dev/hoon/runes/cn.md delete mode 100644 web/docs/dev/hoon/runes/cn/cncb.md delete mode 100644 web/docs/dev/hoon/runes/cn/cncl.md delete mode 100644 web/docs/dev/hoon/runes/cn/cndt.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnhp.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnkt.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnls.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnsg.md delete mode 100644 web/docs/dev/hoon/runes/cn/cntr.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnts.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnzy.md delete mode 100644 web/docs/dev/hoon/runes/cn/cnzz.md delete mode 100644 web/docs/dev/hoon/runes/dt.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtkt.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtls.md delete mode 100644 web/docs/dev/hoon/runes/dt/dttr.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtts.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtwt.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtzy.md delete mode 100644 web/docs/dev/hoon/runes/dt/dtzz.md delete mode 100644 web/docs/dev/hoon/runes/hx.md delete mode 100644 web/docs/dev/hoon/runes/hx/hxgl.md delete mode 100644 web/docs/dev/hoon/runes/hx/hxgr.md delete mode 100644 web/docs/dev/hoon/runes/kt.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktbr.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktdt.md delete mode 100644 web/docs/dev/hoon/runes/kt/kthp.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktls.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktpm.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktsg.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktts.md delete mode 100644 web/docs/dev/hoon/runes/kt/ktwt.md delete mode 100644 web/docs/dev/hoon/runes/sg.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgbc.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgbr.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgcb.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgcn.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgfs.md delete mode 100644 web/docs/dev/hoon/runes/sg/sggl.md delete mode 100644 web/docs/dev/hoon/runes/sg/sggr.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgls.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgpm.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgts.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgwt.md delete mode 100644 web/docs/dev/hoon/runes/sg/sgzp.md delete mode 100644 web/docs/dev/hoon/runes/sm.md delete mode 100644 web/docs/dev/hoon/runes/sm/smcl.md delete mode 100644 web/docs/dev/hoon/runes/sm/smcn.md delete mode 100644 web/docs/dev/hoon/runes/sm/smdq.md delete mode 100644 web/docs/dev/hoon/runes/sm/smhp.md delete mode 100644 web/docs/dev/hoon/runes/sm/smls.md delete mode 100644 web/docs/dev/hoon/runes/sm/smsg.md delete mode 100644 web/docs/dev/hoon/runes/sm/smsm.md delete mode 100644 web/docs/dev/hoon/runes/sm/smtr.md delete mode 100644 web/docs/dev/hoon/runes/sm/smzz.md delete mode 100644 web/docs/dev/hoon/runes/ts.md delete mode 100644 web/docs/dev/hoon/runes/ts/tsbr.md delete mode 100644 web/docs/dev/hoon/runes/ts/tscl.md delete mode 100644 web/docs/dev/hoon/runes/ts/tsdt.md delete mode 100644 web/docs/dev/hoon/runes/ts/tsgl.md delete mode 100644 web/docs/dev/hoon/runes/ts/tsgr.md delete mode 100644 web/docs/dev/hoon/runes/ts/tshp.md delete mode 100644 web/docs/dev/hoon/runes/ts/tskt.md delete mode 100644 web/docs/dev/hoon/runes/ts/tsls.md delete mode 100644 web/docs/dev/hoon/runes/ts/tssg.md delete mode 100644 web/docs/dev/hoon/runes/ts/tstr.md delete mode 100644 web/docs/dev/hoon/runes/wt.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtbr.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtcl.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtdt.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtgl.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtgr.md delete mode 100644 web/docs/dev/hoon/runes/wt/wthp.md delete mode 100644 web/docs/dev/hoon/runes/wt/wthz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtkt.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtkz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtls.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtlz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtpm.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtpt.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtpz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtsg.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtsz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtts.md delete mode 100644 web/docs/dev/hoon/runes/wt/wttz.md delete mode 100644 web/docs/dev/hoon/runes/wt/wtzp.md delete mode 100644 web/docs/dev/hoon/runes/zp.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpcb.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpcm.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpfs.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpgr.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpsm.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpts.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpwt.md delete mode 100644 web/docs/dev/hoon/runes/zp/zpzp.md delete mode 100644 web/docs/dev/interpreter.md delete mode 100644 web/docs/dev/interpreter/u3.md delete mode 100644 web/docs/dev/nock.md delete mode 100644 web/docs/dev/nock/reference.md delete mode 100755 web/docs/dev/nock/tutorial.md delete mode 100644 web/docs/theory.md delete mode 100644 web/docs/theory/network-goals.md delete mode 100644 web/docs/theory/old.md delete mode 100644 web/docs/theory/part-i.md delete mode 100644 web/docs/theory/part-ii.md delete mode 100644 web/docs/theory/whitepaper.md delete mode 100644 web/docs/user.md delete mode 100644 web/docs/user/appliance.md delete mode 100644 web/docs/user/basic.md delete mode 100644 web/docs/user/clay.md delete mode 100644 web/docs/user/dojo.md delete mode 100644 web/docs/user/install.md delete mode 100644 web/docs/user/intro.md delete mode 100644 web/docs/user/launch.md delete mode 100644 web/docs/user/talk.md delete mode 100644 web/docs/user/tour.md delete mode 100644 web/src/tree/css/fonts.styl delete mode 100644 web/src/tree/css/leads.styl delete mode 100644 web/src/tree/css/main.styl delete mode 100644 web/src/tree/css/mobile.styl delete mode 100644 web/src/tree/css/posts.styl delete mode 100644 web/src/tree/css/video.styl delete mode 100644 web/src/tree/js/actions/TreeActions.coffee delete mode 100644 web/src/tree/js/components/AnchorComponent.coffee delete mode 100644 web/src/tree/js/components/Async.coffee delete mode 100644 web/src/tree/js/components/BodyComponent.coffee delete mode 100644 web/src/tree/js/components/CodeMirror.coffee delete mode 100644 web/src/tree/js/components/Components.coffee delete mode 100644 web/src/tree/js/components/EmailComponent.coffee delete mode 100644 web/src/tree/js/components/KidsComponent.coffee delete mode 100644 web/src/tree/js/components/ListComponent.coffee delete mode 100644 web/src/tree/js/components/LoadComponent.coffee delete mode 100644 web/src/tree/js/components/Reactify.coffee delete mode 100644 web/src/tree/js/components/SearchComponent.coffee delete mode 100644 web/src/tree/js/components/TocComponent.coffee delete mode 100644 web/src/tree/js/dispatcher/Dispatcher.coffee delete mode 100644 web/src/tree/js/main.coffee delete mode 100644 web/src/tree/js/package.json delete mode 100644 web/src/tree/js/persistence/TreePersistence.coffee delete mode 100644 web/src/tree/js/stores/TreeStore.coffee delete mode 100644 web/src/tree/readme.md delete mode 100644 web/talk/css/fonts.styl delete mode 100644 web/talk/css/main.styl delete mode 100644 web/talk/css/mobile.styl delete mode 100644 web/talk/js/actions/MessageActions.coffee delete mode 100644 web/talk/js/actions/StationActions.coffee delete mode 100644 web/talk/js/components/MemberComponent.coffee delete mode 100644 web/talk/js/components/MessagesComponent.coffee delete mode 100644 web/talk/js/components/StationComponent.coffee delete mode 100644 web/talk/js/components/StationsComponent.coffee delete mode 100644 web/talk/js/components/TalkComponent.coffee delete mode 100644 web/talk/js/components/WritingComponent.coffee delete mode 100644 web/talk/js/dep/director.js delete mode 100644 web/talk/js/dispatcher/Dispatcher.coffee delete mode 100644 web/talk/js/main.coffee delete mode 100644 web/talk/js/module.js delete mode 100644 web/talk/js/move.coffee delete mode 100644 web/talk/js/package.json delete mode 100644 web/talk/js/persistence/MessagePersistence.coffee delete mode 100644 web/talk/js/persistence/StationPersistence.coffee delete mode 100644 web/talk/js/stores/MessageStore.coffee delete mode 100644 web/talk/js/stores/StationStore.coffee delete mode 100644 web/talk/js/test.js delete mode 100644 web/talk/js/util.coffee delete mode 100644 web/talklog/js/MessagesComponent.coffee delete mode 100644 web/talklog/js/main.coffee delete mode 100644 web/talklog/js/util.coffee delete mode 100644 web/work/css/fonts.styl delete mode 100644 web/work/css/main.styl delete mode 100644 web/work/css/mobile.styl delete mode 100644 web/work/js/actions/WorkActions.coffee delete mode 100644 web/work/js/components/FieldComponent.coffee delete mode 100644 web/work/js/components/FilterComponent.coffee delete mode 100644 web/work/js/components/ItemComponent.coffee delete mode 100644 web/work/js/components/ListComponent.coffee delete mode 100644 web/work/js/components/ListeningComponent.coffee delete mode 100644 web/work/js/components/SortComponent.coffee delete mode 100644 web/work/js/components/WorkComponent.coffee delete mode 100644 web/work/js/dispatcher/dispatcher.coffee delete mode 100644 web/work/js/main.coffee delete mode 100644 web/work/js/package.json delete mode 100644 web/work/js/persistence/Persistence.coffee delete mode 100644 web/work/js/stores/WorkStore.coffee delete mode 100644 web/work/js/util.coffee diff --git a/web/docs.md b/web/docs.md deleted file mode 100644 index 42492474d..000000000 --- a/web/docs.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -anchor: none -layout: no-anchor -logo: black ---- - -
- -# Urbit documentation - -The Urbit doc is divided into three parts: [user doc](docs/user), -[developer doc](docs/dev), and [theory](docs/theory) (whitepaper, essays, -videos, etc). - -If you want to try Urbit, start with the user doc. If you want -to learn about Urbit, try the theory. Or just start with the -user doc; it doesn't assume any prior knowledge. - -The most fun thing to do with Urbit is code, but the developer -doc remains under construction. Sorry. We'll have more soon. - - - -
diff --git a/web/docs/dev.md b/web/docs/dev.md deleted file mode 100644 index a251b8930..000000000 --- a/web/docs/dev.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -logo: black -sort: 2 -title: Developer doc ---- -
- -# Developer documentation - -Urbit has three programming layers: [Nock](dev/nock) (combinator nano-VM), -[Hoon](dev/hoon) (strict functional language), and [Arvo](dev/arvo) (functional -OS). - -To code in Urbit, the least you need to learn is Hoon, plus a -little bit of Arvo. Nock is a sort of functional assembly -language -- you don't need to know it, but it's useful to. -Nock is also the easiest thing in the world to learn. - -You can program for Arvo without knowing much about Arvo -internals, but again it helps. But you need to know Hoon. -Don't worry, it's easier than it looks. - -Alas, the developer doc is still under construction. We'll have -more soon. - - - -
diff --git a/web/docs/dev/arvo.md b/web/docs/dev/arvo.md deleted file mode 100644 index 786728556..000000000 --- a/web/docs/dev/arvo.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -logo: black -sort: 3 -title: Arvo ---- -
- -# Arvo - -Arvo is a functional operating system. But hopefully you knew that! Sorry, -please watch this space for actual documentation. - -
diff --git a/web/docs/dev/client.md b/web/docs/dev/client.md deleted file mode 100644 index c6a65a024..000000000 --- a/web/docs/dev/client.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -hide: true -logo: black -sort: 4 -title: Frontend tools ---- - -Frontend tools -============== - - diff --git a/web/docs/dev/client/tree.md b/web/docs/dev/client/tree.md deleted file mode 100644 index 7234f5b30..000000000 --- a/web/docs/dev/client/tree.md +++ /dev/null @@ -1,59 +0,0 @@ -# `:tree` - -`:tree` is the web filesystem interface. Odds are this file has been rendered for you by `:tree`. - -`:tree` is a single-page app that uses a backend in `/home/tree` to load -contents from `%clay` as the user navigates around as `%json`. The frontend -lives in `/home/pub/tree` and is a fairly straightforward -[React](https://facebook.github.io/react/) / -[Flux](https://facebook.github.io/flux/) app. - -## Frontend - -The frontend code for `:tree` can be found in `/home/pub/tree/src/`. - -### CSS - -The CSS is written in [Stylus](https://learnboost.github.io/stylus/). The main entry point is `main.styl` and can be compiled with `stylus main.styl` which should output a `main.css` - -### JS - -The JS is written in [CoffeeScript](http://coffeescript.org/) and packaged with -[Browserify](http://browserify.org/). The main entry point is `main.coffee` and -is compiled with `browserify -t coffeeify main.coffee > main.js`. You'll need -to `npm install` first. - -Each page is loaded as JSON and then rendered using React on the page. This -allows us to write JSX in our markdown to implement simple components. Check -out `/home/pub/tree/src/js/components` to see the component library. - -You'll notice that some of these doc pages use things like `` in the raw markdown files. - -## JSON API -Async provides loading by schema - -`{path name sein sibs next prev}` are all immediately accesible from the store - -a `getPath` method, if present (defaulting to current url), is used to determine the query root node. - -## JSON Internals - -### `/[desk]/tree/{path}.json` -`tree/json.hook` accepts a query string schema `q` in light noun encoding - - ++ schema (dict ,[term $|(mark schema)]) - ++ dict |*(a=_,* $&([a (dict a)] a)) - -which is normalized and type-checked to a `query` list of -- `[%kids query]`, the only recursive value, which executes for all subpaths - XX descent is only currently supported to a single level as a performance optimization -- `[%name %t]`, the node name -- `[%path %t]`, the current path -- `[%snip %r]`, a snippet, extracted via `react-snip-json` -- `[%head %r]`, the first `

`, extracted via `react-head-json` -- `[%body %r]`, the `react-json` body -- `[%meta %j]`, json frontmatter per the `mdy` mark definition - -The request types above are `%t` text, `%r` html-derived tree, and `%j` -arbitrary json; an example query, used by the main content renderer, is -`"q=body.r__kids_name.t"` (`body:'r' kids:{name:'t'}` ) diff --git a/web/docs/dev/contributing.md b/web/docs/dev/contributing.md deleted file mode 100644 index 3375ed49f..000000000 --- a/web/docs/dev/contributing.md +++ /dev/null @@ -1,213 +0,0 @@ ---- -sort: 6 -title: Contributing ---- - -# Contributing to urbit - -Thank you for your interest in contributing to urbit. - -## Development practice - -You may have an identity on the live network, but doing all your -development on the live network would be cumbersome and unnecessary. -Standard practice in urbit development is to work on a fake `~zod`. A -fake `~zod` will get its initial files from the `urb/zod/` directory -rather than trying to sync them over the network, which is invaluable -for working in Hoon. Also, a fake `~zod` or any fake urbit instances you -start do not talk to the live network, but to a fake network that exists -only on your computer. - -To start a fake `~zod`, the command is: - - bin/urbit -F -I zod -c [pier directory] - -To resume one that was already created, just as on the live network, -remove `-c` (but leave the rest of the options there). `-F` uses the -fake network, and `-I` starts an "imperial" instance - that is, an 8-bit -galaxy. - -## Kernel development - -Working on either C or non-kernel Hoon should not bring any surprises, -but the Hoon kernel (anything under `urb/zod/arvo/`) is bootstrapped -from `urbit.pill` in `urb/`, and must be manually recompiled if any -changes are made. The command to manually recompile the kernel and -install the new kernel is `|reset` in `dojo`. This rebuilds from the -`arvo` directory in the `home` desk in `%clay`. Currently, `|reset` -does not reload apps like `dojo` itself, which will still reference the -old kernel. To force them to reload, make a trivial edit to their main -source file (under the `ape` directory) in `%clay`. - -If you do any kernel development, be sure to read the section below about -pills. - -## Git practice - -Since we use the GitHub issue tracker, it is helpful to contribute via a -GitHub pull request. If you already know what you are doing, skip down -to the Style section. - -Start by cloning the repository on your work machine: - - git clone https://github.com/urbit/urbit - -And, additionally, fork the repository on GitHub by clicking the "Fork" -button. Add your fork as a remote: - - git remote add [username] https://github.com/[username]/urbit - -and set it as the default remote to push to: - - git config --local remote.pushDefault [username] - -This is good practice for any project that uses git. You will pull -upstream branches from urbit/urbit and push to your personal urbit fork -by default. - -Next, check out `test`, which is the mainline development branch, and -base a new branch on it to do your work on: - - git checkout test - git checkout -b [branch name] - -Now you are free to do your work on this branch. When finished, you may -want to clean up your commits: - - git rebase -i test - -Then you can push to your public fork with `git push` and make a pull -request via the GitHub UI. Make sure you request to merge your branch -into `test`, not `master`. - -After your changes are merged upstream, you can delete your branch (via -github UI or `git push :[branch]` remotely, and with `git branch -d` -locally). - -## Style - -The urbit project uses two-space indentation and avoids tab characters. -In C code, it should not be too difficult to mimic the style of the code -around you, which is just fairly standard K&R with braces on every -compound statement. One thing to watch out for is top-level sections in -source files that are denoted by comments and are actually indented one -level. - -Hoon will be a less familiar language to many contributors. Some of our -less obvious stylistic rules are: - -- Keep your source files 80 characters or less wide. Many urbit - developers use 80 character terminals/tmux panes/&c. -- Tab characters are actually a syntax error, so be extra sure your - editor is not inserting any. Trailing whitespace is *usually* not a - syntax error, but avoiding it is encouraged. -- The kernel convention is that line comments start at column 57 with - the `::` followed by 2 spaces. This leaves 20 characters for the - comment. Outside the kernel, things are less strict. -- Tall arms within a core are conventionally separated by empty comments - (just `::`) at the same indentation level as the initial `++` or `+-`. - The last arm in a core is not followed by an empty comment, because it - is visually closed by the `--` that closes the core. The empty comment - is also sometimes omitted in data structure definitions. - -## The kernel and pills - -urbit bootstraps itself using a binary blob called `urbit.pill`, which -we do indeed keep in version control. This creates some special -requirements. If you are not changing anything in the kernel (everything -under `urb/zod/arvo/`) then you can skim this section (please do not -skip it entirely, though). If you *are* working there, then this -section is critically important! - -The procedure for creating `urbit.pill` is often called "soliding". It -is somewhat similar to `|reset`, but instead of replacing your running -kernel, it writes the compiled kernel to a file. The command to solid -is, on a fakezod: - - .urbit/pill +solid - -When the compilation finishes, your `urbit.pill` will be found in the -`[pier]/.urb/put/` directory. Copy it into `urb/` and add it to your -commit. - -The requirement here is that every commit that changes the kernel must -come with an `urbit.pill` built from the same code in `urb/zod/arvo/` -for that commit. (Only changing the actual Hoon code counts, so a change -to a jet with no corresponding Hoon change does not require a new pill.) -This is so that checking out an arbitrary revision and starting up a -fakezod actually works as expected. However you do this is fine, but I -like to do it as part of my committing process - just before `git -commit`, I fire up a new fakezod. This will use the previous -`urbit.pill`, but the kernel code in `%clay` will be copied from -`urb/zod/arvo/`, so `+solid` will compile it. Then I copy `urbit.pill` -into `urb/` and make my commit. - -If you rebase or interactive rebase your commits, be sure to preserve -this property on all the commits you end up with. If multiple people -were collaborating on your branch, you may end up with conflicts in -`urbit.pill` and have to merge the branch into itself to resolve them. -Just do the same procedure to create a new, merged pill before -committing the merge. Otherwise, just make sure to use the correct -`urbit.pill` for each commit. - -## Debug urbit with `gdb` - -Follow the build instructions in README.md but run `make` with argument `DEBUG=yes`: - -(If you've already built urbit first run `make clean`.) - - make DEBUG=yes - -Run `gdb`, while loading `bin/urbit` and its symbol table: - - gdb bin/urbit - -Set a breakpoint on `main()` (optional): - - break main - -Run your urbit comet `mycomet`: - - run mycomet - -Continue from the breakpoint on `main()`: - - continue - -## What to work on - -If you are not thinking of contributing with a specific goal in mind, -the GitHub issue tracker is the first place you should look for ideas. -Issues are tagged with a priority and a difficulty. A good place to -start is on either a low-difficulty issue or a low-priority issue. -Higher priority issues are likely to be assigned to someone - if this is -the case, then contacting that person to coordinate before starting to -work is probably a good idea. - -There is also a "help wanted" tag for things that we are especially -eager to have outside contributions on. Check here first! - -## Staying in touch - -The urbit developers communicate on urbit itself. Joining the -`~doznec/urbit-meta` channel on `talk` is highly recommended. -Subscribing to `urbit-dev` on Google Groups is also recommended, since -this is where continuity breach notifications are sent. - -You can also contact one of the following people: - -- Philip Monk - - email: philip.monk@tlon.io - - urbit: `~wictuc-folrex` - - GitHub: [@philipcmonk](https://github.com/philipcmonk/) - -- Raymond Pasco - - email: ray@the.ug - - urbit: `~ramtev-wisbyt` - - GitHub: [@juped](https://github.com/juped/) diff --git a/web/docs/dev/hoon.md b/web/docs/dev/hoon.md deleted file mode 100644 index 059861d33..000000000 --- a/web/docs/dev/hoon.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -logo: black -sort: 2 -title: Hoon ---- - -
- -# Hoon - -Hoon is a strict, typed, pure functional language. This site is -served by an urbit written in Hoon. - -If you're interested in learning the fundamentals of Hoon from -the bottom up, start with [Principles of -Hoon](hoon/principles). - -If you want to jump into building things right away and prefer to -learn from the top down, check out [Leap into -Hoon](hoon/leap-in/1-basic). - -Both of these are under active development. - -
diff --git a/web/docs/dev/hoon/leap-in.md b/web/docs/dev/hoon/leap-in.md deleted file mode 100644 index c62100745..000000000 --- a/web/docs/dev/hoon/leap-in.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -hide: false -next: false -sort: 1 -title: Leap into Hoon ---- - - diff --git a/web/docs/dev/hoon/leap-in/1-basic.md b/web/docs/dev/hoon/leap-in/1-basic.md deleted file mode 100644 index aabd4a2db..000000000 --- a/web/docs/dev/hoon/leap-in/1-basic.md +++ /dev/null @@ -1,421 +0,0 @@ ---- -logo: black -sort: 1 -next: true -title: Basic Hoon ---- - -# Basic Hoon - -Our goal is to get you programming interesting and useful things -as soon as possible. To get there we have to quickly cover some -of the fundamentals of hoon. To do this we'll walk through two -simple programs: the first [Project -Euler](https://projecteuler.net/) problem and -[fizzbuzz](https://en.wikipedia.org/wiki/Fizz_buzz). - -To run this code, you'll need an urbit, and you'll need the -`%examples` desk from `~wactex-ribmex`. If you haven't installed -urbit yet, check out the [installation -instructions](http://urbit.org/docs/user/install). Once urbit is -intalled, take a look at the [basic -operation](http://urbit.org/docs/user/basic) of your urbit. - -If you haven't pulled the examples desk from `~wactex-ribmex`, do -so now: - - ~fintud-macrep:dojo> |merge %examples ~wactex-ribmex %examples - >= - ; ~wactex-ribmex is your neighbor - ; ~wactex-ribmex is your neighbor - [time passes...] - merged with strategy %init - -The merge could take several minutes; you'll know it's done when -"merged with strategy %init" is printed. Mount the new files to -your Unix pier directory: - - ~fintud-macrep:dojo> |mount /=examples= - -Switch desks to run commands from the `%examples` desk: - - ~fintud-macrep:dojo> =dir /=examples= - =% /~fintud-macrep/examples/~2015.11.13..02.25.00..41e9/ - -Run an example: - - ~fintud-macrep:dojo> +euler1 - 233.168 - -## Euler 1 - -Let's check out the code for Euler 1. First, the problem: - -``` -If we list all the natural numbers below 10 that are multiples of -3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. - -Find the sum of all the multiples of 3 or 5 below 1000. -``` - -Here is the hoon solution (which should be in your pier directory -under `/examples/gen/euler1.hoon`): - -``` -:: project euler 1 -:: https://projecteuler.net/problem=1 -:: run in dojo with +euler1 -:: -:::: /hoon/euler1/gen - :: -:- %say |= * -:- %noun -=< (sum 1.000) -:: -:::: ~fintud-macrep - :: -|% -++ three - |= a=@ - =| b=@ - |- ^- @u - ?: (lth a b) - 0 - (add b $(b (add 3 b))) - -++ five - |= a=@ - =| b=@ - |- ^- @ - ?: (lte a b) - 0 - ?: =((mod b 3) 0) - $(b (add b 5)) - (add b $(b (add b 5))) - -++ sum - |= a=@u - (add (five a) (three a)) --- -``` - -> Hoon is not generally whitespace sensitive, but we do have two -> different kinds of whitespace: a single space and a gap, which -> is two or more spaces or a linebreak. Tabs are taboo. Do not -> use them. Really. For a more detailed explanation of when to -> use spaces vs. gaps, see the syntax section before the first -> excercises. - -### Lines 1-11: - -Any line that begins with `::` is a comment. - - :- %say |= * - :- %noun - =< (sum 1.000) - -All you need to know about the lines above is that they call the -`++sum` function with an argument of `1.000`. We'll cover them in -more detail later. - -### How to form expressions - -Hoon does not use reserved words to form expressions. Instead, -expressions are formed with runes, which are diagraphs of two -ascii symbols. Each rune takes a specific number of -children--either expressions formed by other runes or literals -that produce their own value. - -For example, the rune `?:` from line 17 is the classic -'if-then-else' statement, and thus takes three children: - - ?: (lth a b) :: if first child evals to true - 0 :: then produce result of second - (add b $(b (add 3 b))) :: else, produce result of third - -Since runes are such a fundamental structure in Hoon, we found -ourselves speaking them out loud frequently. It quickly grew -cumbersome to have to say "question mark, colon" to describe -`?:`. To alleviate this problem, we came up with our own naming -scheme: each ascii glyph has a single syllable pronunciation -phonetically designed to be both easily remembered and easily -pronounced in conjunction with the other glyphs (when forming a -rune). - -See the entire naming schema below/or link to it: - -``` - ace [1 space] gal < pel ( - bar | gap [>1 space, nl] per ) - bas \ gar > sel [ - buc $ hax # sem ; - cab _ hep - ser ] - cen % kel { soq ' - col : ker } tar * - com , ket ^ tec ` - doq " lus + tis = - dot . pam & wut ? - fas / pat @ zap ! -``` - -Using our naming scheme `?:` is said 'wut col'. - -### Lines 12-34 - -Now let's quickly walk through this code line-by-line. Lines -12-34 are wrapped in a `|%` (pronounced 'bar cen'), which -produces a core, a fundamental datatype in hoon similar to a -struct, class, or object. A core is just a map of names -to any kind of code, whether it be functions or data. Each -element in this map begins with a `++` followed by the name and -the corresponding code. Since `|%` takes an arbitrary number of -children, it needs to be closed with a `--`. - -> `++` is not technically a rune, since it is only used in core -> syntax as shown above - -Let's step into each of the three arms within our core. - -### `++ sum` - - ++ sum - |= a=@ - (add (five a) (three a)) - -- - -`|=` produces a function, much like a lambda in lisp. It takes two children: - -- A set of argument(s). In this case our argument set only - contains one: `a` which is required to be an atom or natural - number, denoted by `@`. - -- The body of the function itself, which is executed when the - function is called (in this case, with `(sum 1.000)`). This - particular function adds the results of evaluating the gates `++ - five` and `++three` with each of their respective input - parameters set to `a`. - -### ++ three - - ++ three - |= a=@ - =| b=@ - |- ^- @u - ?: (lth a b) - 0 - (add b $(b (add 3 b))) - -As above, `++three` takes an integer argument, `a`, and then -executes the remainder of the code with `a` set to the actual -arguments. - -Similarly, `=|` pushes its first child, `b` into our context (in -other words, it declares a variable `b`) and executes the -remainder of the code. However, `b` is not an argument; `=|` -sets `b` to the default value of whatever type it is declared as. -Since the default value of an atom is `0`, b is set to `0`. - -So now we have two variables: `a` is set to our input, and `b` is -initialized to `0`. - -The easiest way to think about `|-` that it lays down a recursion -point. More on this later. - -`^-` is just a cast that sets the result of the remainder of the -code to an unsigned integer, `@u`. - -In pseudocode, the last three lines read like this: if `a` is -less than `b`, produce zero. Else, add `b` to the result of -rerunning the segment of the function following the `|-` with the -value of `b` changed to `b` plus three. - -The only thing that should look completely unfamiliar to you here -is the `$(b (add 3 b))`, which causes us to recurse back to our -last recursion point with the value of `b` set to `(add 3 b)`. -Note that we only specify what changes (`b` in this case). If -you recurse by an actual function call, then you have to specify -every argument. - -> If you're familiar with Clojure, `|-` is `loop` and `$()` is -> recur. - - -## Excercises - -Please tweak your code to complete the following excercises. - -There are a few runes and some syntax that we have yet to cover that -you will need to complete the excercises below. For these, please -refer to our cheatsheat at the bottom. - -1. Read and understand `++five` line by line. - -2. Change `++sum` to accept two variables, `a` and `b`. Pass `a` - to three and `b` to five. Then run the code with `a` set to - `1.000` and b set to `2.000`. - -3. Check if this new result is under one thousand. If it is, - return the string 'result is less than one thousand'. If not, - return 'result is greater than or equal to one thousand'. - -``` -Review - -|% start core (collection of named ++ arms) -|= define function -=| define variable from type with default value -|- drop a recursion point -^- cast -?: if-then-else -=(a b) test equality -(function args ...) call function - -New material - -- :- make a cell of values. The irregular wide form of this is - [a b] with two expressions separated by a single space. - -- Cords are one datatype for text in hoon. They're just a big - atom formed from adjacent unicode bytes -- a "c string". To - produce a cord enclose text within single quotes. To set the type - of an argument to a cord, use @t. - -- There are two syntaxes for writing Hoon: tall form and wide - form. - - In tall form, expressions are formed with either two spaces or - a line break separating both a rune from its children and each - of its children from one another. We use tall form when writing - multiline expressions. - - For more concise expressions, we use wideform, which is always - a single line. Wideform can be used inside tall form - expressions, but not vice versa. - - Wideform expressions are formed with a rune followed by () - containing its children, all of which are separated by a - single space. For example to make a cell of two elements: - - :-(a b) - - We've already seen wideform in action, for example with - =((mod b 3) 0). In this case = is actually an irregular form - of .=, which tests its two children for equality. - - Another irregular form is [a b] for :-(a b) - - Surrounding a function with () is an irregular wide form - syntax for calling a function with n arguments. -``` - - -## The subject - -Now we're going to cover the boiler plate that we skimmed over -earlier. - - :- %say |= * - :- %noun - =< (sum [1.000 2.000]) - -This program is a cell of two elements: the first, `%say`, tells -the interpreter what to produce--in this case a value. - -The second element is `|=`, which we know produces a function. -`|=`'s first child is its argument(s), which in this case is any -noun (`*`). Its second child is the remainder of the program. - -Similarly, the rest of the program is a cell of the literal -`%noun`, which tells the shell that we're producing a value of -type `noun`, and the second child contains the code that we run -to actually produce our value of the type `noun`. - -`=<` is a rune that takes two children. The second child is the -context against which we run the first child. So in this case, we -are running the expression `(sum 1.000)` against everything -contained within the `|%`. In Hoon, we call the code executed the -"formula" and its context the "subject". - -``` -:::::::::::::::::::::::::::::: -=< (sum 1.000) :: formula -:::::::::::::::::::::::::::::: -|% :: -++ three :: - |= a=@ :: - =| b=@ :: - |- ^- @u :: - ?: (lth a b) :: - 0 :: - (add b $(b (add 3 b))) :: - :: -++ five :: - |= a=@ :: subject - =| b=@ :: - |- ^- @ :: - ?: (lte a b) :: - 0 :: - ?: =((mod b 3) 0) :: - $(b (add b 5)) :: - (add b $(b (add b 5))) :: - :: -++ sum :: - |= a=@u :: - (add (five a) (three a)) :: --- :: -:::::::::::::::::::::::::::::: -``` - -In nearly every language there is a similar concept of a -"context" in which expressions are executed. For example, in C -this includes things like the call stack, stack variables, and so -on. - -Hoon is unique in that this context is a first-class value. -Scheme allows a sort of reification of the context through -continutations, and some may see a parallel to Forth's stack, but -Hoon takes takes the concept one step further. - -Our starting subject is the standard library, which is defined in -`/arvo/hoon.hoon` and `/arvo/zuse.hoon`. This is where functions -like `add` are defined. When we define a core with `|%`, we -don't throw away the subject (i.e. the standard library); rather, -we stack the new core on top of the old subject so that both are -accessible. - -## Exercises: - -4. Pass `++sum` its arguments (`2000` and `3000`) from the - commandline. - -5. Comment out all of the arms of the `|%`. Now add another arm - and call it `++add`, have it accept two arguments and procduce - 42 (regardless of input). Change the `=<` line to `[(add 5 7) - (^add 5 7)]`. Can you recognize what's happening? - -6. Write fizbuzz: - - Write a program that prints the numbers from 1 to 100 - (entered from the command line). But for multiples of three - print 'Fizz' instead of the number and for the multiples of - five print 'Buzz'. For numbers which are multiples of both - three and five print 'FizzBuzz'. - -Cheatsheet: - -- To pass arguments from the command line to a program, you - replace the `*` in the first line of the boiler plate to - `[^ [[arg=TYPE ~] ~]]` where `TYPE` is replaced with the - type of argument you're expecting. Then `+euler1 a` from - the dojo sets `arg` to `a`. -- A list of strings is of type `(list ,@t)`, so the result of - the fizzbuzz function is of this type (hint: you'll need to - use `^-`) -- The empty list is `~` -- Lisp-style cons (construct a cell/prepend an element) is - `[new-element list]` -- For example, the first three positive integers are `[1 2 3 - ~]` -- `gte` tests whether `a` is greater than or equal to `b`. -- `mod` runs the modulo operation on two atoms. -- See the [basic math section]() for more info. diff --git a/web/docs/dev/hoon/leap-in/2-network.md b/web/docs/dev/hoon/leap-in/2-network.md deleted file mode 100644 index 718cd0938..000000000 --- a/web/docs/dev/hoon/leap-in/2-network.md +++ /dev/null @@ -1,335 +0,0 @@ ---- -next: false -sort: 2 -title: Network Messages ---- - -Enough of pure hoonery. Let's get to the good stuff. Let's get -our planets to talk to each other. - -Of course, for talking to be of any use, we need someone -listening. What we've written up until now are just shell -commands that produce a value and then disappear. We need an -actual app to listen for messages from another planet. Let's -take a look at a very basic one. - -``` -:: There is no love that is not an echo -:: -:::: /hoon/echo/ape - :: -/? 314 -!: -|_ [bowl state=~] -++ poke-noun - |= arg=* - ^- [(list) _+>.$] - ~& [%argument arg] - [~ +>.$] --- -``` - -This is a very simple app that does only one thing. If you poke -it with a value it prints that out. You have to start the app, -then you can poke it from the command line with the following -commands: - -``` -~fintud-macrep:dojo> |start %echo ->= -~fintud-macrep:dojo> :echo 5 -[%argument 5] ->= -~fintud-macrep:dojo> :echo [1 2] -[%argument [1 2]] ->= -``` - -> There is currently a bug where the `%argument` lines are -> printed *above* the line you entered, so your output may not -> look exactly like this. - -Most of the app code should be simple enough to guess its -function. The important part of this code is the definition of -`++poke-noun`. - -Once an app starts, it's always on in the background, and you -interact with it by sending it messages. The most -straightforward way to do that is to poke it from the command -line. When you do that, `++poke-noun` is called from your app. - -In our case, `++poke-noun` takes an argument `arg` and prints it -out with `~&`. This is an unusual rune that formally "does -nothing", but the interpreter detects it and printfs the first -child. This is a slightly hacky way of printing to the console, -and we'll get to the correct way later on. - -But what does `++poke-noun` produce? Recall that `^-` casts to a -type. In this case, it's declaring that end result of the -function will be of type `[(list) _+>.$]`. But what does this -mean? - -The phrase to remember is "a list of moves and our state". Urbit -is a message passing system, so whenver we want to do something -that interacts with the rest of the system we send a message. -Thus, a move is arvo's equivalent of a syscall. The first -thing that `++poke-noun` produces is a list of messages, called -"moves". In this case, we don't actually want the system to do -anything, so we produce the empty list, `~` (in the `[~ +>.$]` -line). - -The second thing `++poke-noun` produces is our state. `+>.$` -refers to a particular address in our subject where our formal -app state is stored. It'll become clear why this is later on, -but for now pretend that `+>.$` is a magic invocation that means -"app state". - -Let's look at another example. Say we want to only accept a -number, and then print out the square of that number. - -``` -/? 314 -!: -|_ [bowl state=~] -:: -++ poke-atom - |= arg=@ - ^- [(list) _+>.$] - ~& [%square (mul arg arg)] - [~ +>.$] --- -``` - -A few things have changed. Firstly, we no longer accept -arbitrary nouns because we can only square atoms. Thus, our -argument is now `arg=@`. Secondly, it's `++poke-atom` rather -than `++poke-noun`. - -Are there other `++poke`s? Definitely. In fact, `noun` and -`atom` are just two of arbitrarily many "marks". A mark is -fundamentally a type definition, but accessible at the arvo -level. Each mark is defined in the `/mar` directory. Some marks -have conversion routines to other marks, and some have diff, -patch, and merge algorithms. None of these are required for a -mark to exist, though. - -`noun` and `atom` are two of dozens of predefined marks, and the -user may add more at will. The type associated with `noun` is -`*`, and the type associated with `atom` is `@`. - -Data constructed on the command line is by default marked with -`noun`. In this case, the app is expecting an atom, so we have -to explicitly mark the data with `atom`. Try the following -commands: - -``` -~fintud-macrep:dojo> |start %square ->= -~fintud-macrep:dojo> :square 6 -gall: %square: no poke arm for noun -~fintud-macrep:dojo> :square &atom 6 -[%square 36] ->= -``` - -> Recall the bug where `%square` may get printed above the input -> line. - -Marks are powerful, and they're the backbone of urbit's data -pipeline, so we'll be getting quite used to them. - -**Exercises**: - -- Write an app that computes fizzbuzz on its input (as in the - previous section). - -- One way of representing strings is with double quoted strings - called "tapes". The hoon type is `tape`, and there is a - corresponding mark with the same name. Write an app that - accepts a tape and prints out `(flop argument)`, where - `argument` is the input. What does this do? - - -Let's write our first network message! Here's `/ape/pong.hoon`: - -``` -/? 314 -|% - ++ move ,[bone term path *] --- -!: -|_ [bowl state=~] -:: -++ poke-urbit - |= to=@p - ^- [(list move) _+>.$] - [[[ost %poke /sending [to %pong] %atom 'howdy'] ~] +>.$] -:: -++ poke-atom - |= arg=@ - ^- [(list move) _+>.$] - ~& [%receiving (,@t arg)] - [~ +>.$] -:: -++ coup |=(* [~ +>.$]) --- -``` - -Run it with these commands: - -``` -~fintud-macrep:dojo> |start %pong ->= -~fintud-macrep:dojo> :pong &urbit ~sampel-sipnym ->= -``` - -Replace `~sampel-sipnym` with another urbit. Don't forget to -start the `%pong` app on that urbit too. You should see, on the -foreign urbit, this output: - -``` -[%receiving 'howdy'] -``` - -Most of the code should be straightforward. In `++poke-atom`, -the only new thing is the expression `(,@t arg)`. As we already -know, `@t` is the type of "cord" text strings. `,` is an -operator that turns a type into a validator function -- that is, -a function whose domain is all nouns and range is the given type, -and which is identity when the domain is restricted to the given -type. In simpler terms, it's a function that coerces any value -to the given type. We call this `,@t` function on the argument. -This coerces the argument to text, so that we can print it out -prettily. - -The more interesting part is in `++poke-urbit`. The `urbit` mark -is an urbit identity, and the hoon type associated with it is -`@p` (the "p" stands for "phonetic base"). - -Recall that in a `++poke` arm we produce "a list of moves and our -state". Until now, we've left the list of moves empty, since we -haven't wanted to tell arvo to do anything in particular. Now we -want to send a message to another urbit. Thus, we produce a list -with one element: - -``` -[ost %poke /sending [to %pong] %atom 'howdy'] -``` - -The general form of a move is - -`[bone term path *]` - -If you look up `++bone` in `hoon.hoon`, you'll see that it's a -number (`@ud`), and that it's an opaque reference to a duct. -`++duct` in hoon.hoon is a list of `wire`s, where `wire` is an -alias for `path`. `++path` is a list of `span`s, which are ASCII -text. Thus, a duct is a list of paths, and a bone is an opaque -reference to that duct (in the same way that a Unix file -descriptor is an opaque reference to a file structure). Thus, -the center of all this is the concept of a "duct". - -A duct is stack of causes, represented as paths. At the bottom -of every duct is a unix event, such as a keystroke, network -packet, file change, or timer event. When arvo is given this -event, it routes the event to appropriate kernel module for -handling. - -Sometimes, the module can immediately handle the event and -produce any necessary results. Otherwise, it asks other kernel -modules or applications to do certain things, and produces the -result from that. When it sends a message to another kernel -module or application, it sends it "along" the duct it was given, -plus with a new path. Arvo pushes the new path onto the duct. -Now the duct has two entries, with the unix even on the bottom -and the kernel module that handled it next. This process can -continue indefinitely, adding more and more layers onto the duct. -When an entity produces a result, a layer is popped off the duct. - -In effect, a duct is an arvo-level call stack. The duct system -creates a structured message-passing system. It's worth noting -that while in traditional call stacks a function call happens -synchronously and returns exactly once, in arvo multiple moves -can be sent at once, they are evaluated asynchronously, and each -one may be responded to zero or more times. - -Anyhow, the point is that whatever caused `++poke-urbit` to be -called is also the root cause for the network message we're -trying to send. Thus, we say to send the network message along -the given bone `ost`. Of course, we have to push a layer to the -duct. This layer can have any data we want in it, but we don't -need anything specific here, so we just use `/sending`. If we -were expecting a response (which we're not), it would come back -along the `/sending` path. It's a good idea for debugging -purposes to make the path human-readable, but it's not necessary. - -Looking back at the general form of a move, there is a `term`, -which in this case is `%poke`. This is the name of the -particular kind of move we're sending. If you think of a move as -a syscall (which you should), then this `term` is the name of the -syscall. Common ones include: `%poke`, to message an app; -`%warp`, to read from the filesystem; `%wait`, to set a timer; -and `%them`, to send an http request. - -The general form ends with `*` since each type of move takes -different data. In our case, a `%poke` move takes a target -(urbit and app) and marked data and pokes that app on that urbit -with that data. `[to %pong]` is the target urbit and app, -`%atom` is the mark`, and `'howdy'` is the data. - -When arvo receives a `%poke` move, it calls the appropriate -`++poke`. The same mechanism is used for sending messages -between apps on the same urbit as for sending messages between -apps on different urbits. - -> We said earlier that we're not expecting a response. This is -> not entirely true: the `++coup` is called when we receive -> acknowledgment that the `++poke` was called. We don't do -> anything with this information right now, but we could. - -**Exercises**: - -- Extend either of the apps in the first two exercises to accept - input over the network in the same way as `pong`. - -- Modify `pong` to print out a message when it receives an ack. - -- Write two apps, `even` and `odd`. When you pass an atom to - `even`, check whether it's even. If so, divide it by two and - recurse; otherwise, poke `odd` with it. When `odd` recieves - an atom, check whether it's equal to one. If so, terminate, - printing "%success". Otherwise, check whether it's odd. If - so, multiply it by three, add one, and recurse; otherwise, poke - `even` with it. multiply it by three and add one. When either - app receives a number, print it out along with the name of the - app. In the end, you should be able to watch Collatz's - conjecture play out between the two apps. Sample output: - -``` -~fintud-macrep:dojo> :even &atom 18 -[%even 18] -[%odd 9] -[%even 28] -[%even 14] -[%odd 7] -[%even 22] -[%odd 11] -[%even 34] -[%odd 17] -[%even 52] -[%even 26] -[%odd 13] -[%even 40] -[%even 20] -[%even 10] -[%odd 5] -[%even 16] -[%even 8] -[%even 4] -[%even 2] -%success -``` - -- Put `even` and `odd` on two separate ships and pass the - messages over the network. diff --git a/web/docs/dev/hoon/leap-in/3-app.md b/web/docs/dev/hoon/leap-in/3-app.md deleted file mode 100644 index 15a259a43..000000000 --- a/web/docs/dev/hoon/leap-in/3-app.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -hide: true -next: false -sort: 3 -title: Advanced Applications ---- - -XXX PLACEHOLDER - -But what is our app state, exactly? In Unix systems, application -state is just a block of memory, which you need to serialize to -disk if you want to keep it around for very long. - -In urbit, app state is a single (usually complex) value. In our -example, we don't have any special state, so we defined -`state=~`, meaning that our state is null. Of course, `state` is -just a name we're assigning to it, and you're free to use -whatever name you want. - -Since urbit is purely functional, we can't just implicitly "have" -and "change" our state. Rather, it's explicitly passed to us, in -the `|_ [bowl state=~]` line, and we produce the new state with -`+>.$` in the `[~ +>.$]` line. - -Two points you may be wondering about. Firstly, `bowl` is a set -of general global state that is managed by the system. It -includes things like `now` (current time), `our` (our urbit -identity), and `eny` (256 bits of guaranteed-fresh entropy). For -the full list of things in `++bowl`, search for `++ bowl` (note -the double space) in `/arvo/zuse.hoon`. - -> This is a very common technique in learning hoon. While some -> documentation exists, often the easiest way to learn about an -> identifier you see in code is to search in `/arvo/zuse.hoon` -> and `/arvo/hoon.hoon` for it. These are our two "standard -> libraries", and they're usually not hard to read. Since -> urbit's codebase is relatively small (those two files are less -> than 15000 lines of code combined, and besides the standard -> library they include the hoon parser and compiler, plus the -> /arvo microkernel), you can usually use the code and the -> comments as reference doc. - -Second point is that urbit needs no "serialize to disk" step. -Everything you produce in the app state is persistent across -calls to the app, restarts of the urbit, and even power failure. -If you want to write to the filesystem, you can, but it's not -needed for persistence. Urbit has transactional events, which -makes it an ACID operating system. Persistence is just another -one of those things you don't have to worry about when -programming in urbit. - -As fascinating as state is, we don't actually need any state to -accomplish our immediate goal, which is to get apps on two urbits -talking to each other. We'll discuss state more in a later -chapter. diff --git a/web/docs/dev/hoon/library.md b/web/docs/dev/hoon/library.md deleted file mode 100644 index d3f688ee7..000000000 --- a/web/docs/dev/hoon/library.md +++ /dev/null @@ -1,7 +0,0 @@ -Library -======== - - - - - diff --git a/web/docs/dev/hoon/library/0.md b/web/docs/dev/hoon/library/0.md deleted file mode 100644 index 920cd8e4b..000000000 --- a/web/docs/dev/hoon/library/0.md +++ /dev/null @@ -1,37 +0,0 @@ -volume 0, Kelvin Versioning. -=========================== - -### `++hoon` - - ++ hoon %164 :: version stub - -Declares the current Hoon version number in degrees Kelvin. - -When normal people release normal software, they count by fractions, and -they count up. Thus, they can keep extending and revising their systems -incrementally. This is generally considered a good thing. It generally -is. - -In some cases, however, specifications needs to be permanently frozen. -This requirement is generally found in the context of standards. Some -standards are extensible or versionable, but some are not. ASCII, for -instance, is perma-frozen. So is IPv4 (its relationship to IPv6 is -little more than nominal - if they were really the same protocol, they'd -have the same ethertype). Moreover, many standards render themselves -incompatible in practice through excessive enthusiasm for extensibility. -They may not be perma-frozen, but they probably should be. - -The true, Martian way to perma-freeze a system is what I call Kelvin -versioning. In Kelvin versioning, releases count down by integer degrees -Kelvin. At absolute zero, the system can no longer be changed. At 1K, -one more modification is possible. And so on. For instance, Nock is at -5K. It might change, though it probably won't. Nouns themselves are at -0K - it is impossible to imagine changing anything about their three -sentence definition. - ------------------------------------------------------------------------- - - ~zod/try=> stub - 164 - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/1.md b/web/docs/dev/hoon/library/1.md deleted file mode 100644 index 5d8441940..000000000 --- a/web/docs/dev/hoon/library/1.md +++ /dev/null @@ -1,1786 +0,0 @@ -volume 1, Hoon Structures -========================= - ------------------------------------------------------------------------- - -### `++abel` - - ++ abel typo :: original sin: type - -Biblical names in hoon are primarily aliases for the compiler. - -See also: `++typo` - - ~zod/try=> *abel - %void - ------------------------------------------------------------------------- - -### `++axis` - - ++ axis ,@ :: tree address - -A Nock axis inside a noun. After the leading 1, in binary, a 1 signfies -right and 0 left. - -See also: `++clue`, `++limb`, `++slot`, `++peg`, and Section 2fC - - ~zod/try=> *axis - 0 - - ~zod/try=> :: 0 is not actually a valid axis - ~zod/try=> [[4 5] 6 7] - [[4 5] 6 7] - ~zod/try=> `axis`0b110 - 6 - ------------------------------------------------------------------------- - -### `++also` - - ++ also ,[p=term q=wing r=type] :: alias - -XX unused? - ------------------------------------------------------------------------- - -### `++base` - - ++ base ?([%atom p=odor] %noun %cell %bean %null) :: axils, @ * ^ ? ~ - -A base type that nouns are built from. Either a noun, a cell, loobean or -null labelled with an odor. - -See also: `++tile`, `++twig` - - ~zod/try=> *base - %null - - ~zod/try=> (ream '=|(^ !!)') - [%tsbr p=[%axil p=%cell] q=[%zpzp ~]] - ~zod/try=> :: p.p is a ++base - ~zod/try=> (ream '=|(@t !!)') - [%tsbr p=[%axil p=[%atom p=~.t]] q=[%zpzp ~]] - ~zod/try=> (ream '=|(? !!)') - [%tsbr p=[%axil p=%bean] q=[%zpzp ~]] - ------------------------------------------------------------------------- - -### `++bean` - - ++ bean ,? :: 0=&=yes, 1=|=no - -The Urbit version of a boolean, which we call a loobean. 0 or & is -"yes", 1 or | is "no". - - ~zod/try=> *bean - %.y - - ~zod/try=> `bean`& - %.y - ~zod/try=> `bean`| - %.n - ------------------------------------------------------------------------- - -### `++beer` - - ++ beer $|(@ [~ p=twig]) :: simple embed - -Used to build tapes internally. - -See also: `++phax`, `++scat`, section 2fD - - ~zod/try=> `beer`'as' - 29.537 - ~zod/try=> `beer`[~ (ream 'lan')] - [~ p=[%cnzz p=~[%lan]]] - ------------------------------------------------------------------------- - -### `++beet` - - ++ beet $| @ :: advanced embed - $% [%a p=twig] :: take tape - [%b p=twig] :: take manx - [%c p=twig] :: take marl - [%d p=twig] :: take $+(marl marl) - [%e p=twig q=(list tuna)] :: element literal - == :: - -Cases for XML interpolation. Used internally. - -See also: `++sail`, section 2fD - ------------------------------------------------------------------------- - -### `++bloq` - - ++ bloq ,@ :: blockclass - -Atom representing a blocksize, by convention expressed as a power of 2. - -See also: section 2cA - - ~zod/try=> :: ++met measures how many bloqs long an atom is - ~zod/try=> (met 3 256) - 2 - ~zod/try=> :: 256 is 2 bloqs of 2^3 - ------------------------------------------------------------------------- - -### `++calf` - - ++ calf ,[p=(map ,@ud wine) q=wine] :: - -Encodes cyclical backreferences in types. Used in pretty printing. - -See also: `++wine`, `++dole`, `++doge`, `++dish`, section 2fC - - ~zod/try=> `calf`[~ %atom %ta] - [p={} q=[%atom p=%ta]] - - ~zod/try=> `calf`~(dole ut p:!>(*^)) - [p={} q=[%plot p=~[%noun %noun]]] - - ~zod/try=> `calf`~(dole ut p:!>($:|-(?(~ [* $])))) - [ p={[p=1 q=[%pick p=~[[%pear p=%n q=0] [%plot p=~[%noun [%stop p=1]]]]]]} - q=[%stop p=1] - ] - ------------------------------------------------------------------------- - -### `++char` - - ++ char ,@tD :: UTF-8 byte - -A single character. Odor `@tD` designates a single Unicode byte. All -parsers consume `++tape` (a list of `++char`). - -See also: `++tape`, `++lust`, `++just`, `++mask`, chapter 2f - - ~zod/try=> *char - ~~ - - ~zod/try=> (char 97) - ~~a - ------------------------------------------------------------------------- - -### `++chub` - - ++ chub :: registered battery - $: p=(pair chum tyre) :: definition - q=* :: battery - r=(unit (pair axis chub)) :: parent - == :: - -Used by the compiler (implicitly by `%sgcn`) to attach jets. - -See also: Section 2fB. - ------------------------------------------------------------------------- - -### `++chum` - - ++ chum $? lef=term :: jet name - [std=term kel=@] :: kelvin version - [ven=term pro=term kel=@] :: vendor and product - [ven=term pro=term ver=@ kel=@] :: all of the above - == :: - -Jet hint information that must be present in the body of a \~/ or \~% -rune. A `++chum` can optionally contain a kelvin version, jet vendor, -and major.minor version number. - -XX there's a ++chum in zuse that's politely causing this not to work - -See also: `++twig`, `++clue` - - ~zod/try=> `chum`'hi' - lef=%hi - - ~zod/try=> (ream '~/(%lob.314 !!)') - [%sgfs p=[std=%lob kel=314] q=[%zpzp ~]] - ------------------------------------------------------------------------- - -### `++clue` - - ++ clue ,[p=axis q=chum r=tyre] :: battery definition - -Used by compiler to attach jets. - -XX implementation does not currenlty match docs - -See also: section 2fB - ------------------------------------------------------------------------- - -### `++coil` - - ++ coil $: p=?(%gold %iron %lead %zinc) :: core type - q=type :: - r=[p=?(~ ^) q=(map term foot)] :: - == :: - -Core information tuple: variance, subject type, optional compiled nock, -and arms. Used as an intermediate step within Section 2fB. Converted by -`++core` to %core type. - -See also: `++core`, Section 2fB - ------------------------------------------------------------------------- - -### `++coin` - - ++ coin $% [%$ p=dime] :: - [%blob p=*] :: - [%many p=(list coin)] :: - == :: - -Noun literal syntax cases: atoms, jammed nouns, and nestable tuples. -Parsed and printed using `++so` and `++co` cores in Section 2eL -respectively. - -See also: `++so`, `++co`, Section 2eL, `++dime` - - ~zod/try=> `coin`(need (slay '~s1')) - [%$ p=[p=~.dr q=18.446.744.073.709.551.616]] - ~zod/try=> `coin`(need (slay '0x2b59')) - [%$ p=[p=~.ux q=11.097]] - - ~zod/try=> ~(rend co [%many ~[[%$ %ud 1] [%$ %tas 'a'] [%$ %s -2]]]) - "._1_a_-2__" - ~zod/try=> ._1_a_-2__ - [1 %a -2] - - ~zod/try=> `@uv`(jam [3 4]) - 0v2cd1 - ~zod/try=> (slay '~02cd1') - [~ [%blob p=[3 4]]] - ~zod/try=> ~02cd1 - [3 4] - ------------------------------------------------------------------------- - -### `++cord` - - ++ cord ,@t :: text atom (UTF-8) - -One of Hoon's two string types (the other being `++tape`). A cord is an -atom of UTF-8 text. `++trip` and `++crip` convert between cord and -`++tape` - -Odor `@t` designates a Unicode atom, little-endian: the first character -in the text is the low byte. - -See also: `++trip`, `++crip`, Section 2eJ - - ~zod/try=> `@ux`'foobar' - 0x7261.626f.6f66 - - ~zod/try=> `@`'urbit' - 499.984.265.845 - ~zod/try=> (cord 499.984.265.845) - 'urbit' - ------------------------------------------------------------------------- - -### `++date` - - ++ date ,[[a=? y=@ud] m=@ud t=tarp] :: parsed date - -A point in time. A loobean designating AD or BC, a year atom, a month -atom, and a `++tarp`, which is a day atom and a time. - -See also: `++year`, `++yore`, Section 2cH, `++stud`, `++dust`, Section -3bc - - ~zod/try=> `date`(yore ~2014.6.6..21.09.15..0a16) - [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]] - ------------------------------------------------------------------------- - -### `++dime` - - ++ dime ,[p=@ta q=@] :: - -Odor-atom pair, used in `++coin`. - -Convenience methods `++scot` and `++scow` (in Section 2eL) print dimes -as cords/tapes, `++slat`, `++slav`, and `++slaw` are used to parse atoms -of specific odor. - -See also: `++so`, `++co`, Section 2eL, `++coin` - - ~zod/try=> +>:(slay '0x123') - p=[p=~.ux q=291] - ------------------------------------------------------------------------- - -### `++dram` - - ++ dram $% [| p=(map ,@tas dram)] :: simple unix dir - [& p=@ud q=@] :: - == :: - -The structure of a unix filesystem tree. A `++dram` is one of two cases: -`|` a directory - a map of names to deeper tree structures, `&` a file - -a numbered atom of data. - -XX Unused - ------------------------------------------------------------------------- - -### `++each` - - ++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: either a or b - -Tile generator: produces a discriminated fork between two types. - - ~zod/try=> :type; *(each cord time) - [%.y p=''] - {[%.y p=@t] [%.n p=@da]} - ------------------------------------------------------------------------- - -### `++edge` - - ++ edge ,[p=hair q=(unit ,[p=* q=nail])] :: parsing output - -Parsing location metadata: optional result and parsing continuation. - -See also: Section 2eD, `++rule` - - ~zod/try=> *edge - [p=[p=0 q=0] q=~] - ~zod/try=> (tall:vast [1 1] "a b") - [p=[p=1 q=2] q=[~ [p=[%cnzz p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]] - ------------------------------------------------------------------------- - -### `++foot` - - ++ foot $% [%ash p=twig] :: dry arm, geometric - [%elm p=twig] :: wet arm, generic - [%oak ~] :: XX not used - [%yew p=(map term foot)] :: XX not used - == :: - -Cases of arms by variance model. - -See also: `++ap`, `++ut`, Section 2fB, Section 2fC - - ~zod/try=> *foot - [%yew p={}] - - ~zod/try=> (ream '|% ++ $ foo --') - [%brcn p={[p=%$ q=[%ash p=[%cnzz p=~[%foo]]]]}] - ~zod/try=> +<+:(ream '|% ++ $ foo --') - t=~[%ash %cnzz %foo] - ~zod/try=> (foot +<+:(ream '|% ++ $ foo --')) - [%ash p=[%cnzz p=~[%foo]]] - ~zod/try=> (foot +<+:(ream '|% +- $ foo --')) - [%elm p=[%cnzz p=~[%foo]]] - ------------------------------------------------------------------------- - -### `++gate` - - ++ gate $+(* *) :: general gate - -An core with one arm, `$`, which transforms a sample noun into a product -noun. If used dryly as a type, subject must have a sample type of `*`. - -See also: `++lift`, `++cork`, Core Language Doc - - ~zod/try=> *gate - <1|mws [* <101.jzo 1.ypj %164>]> - ~zod/try=> `gate`|=(* 0) - <1|mws [* <101.jzo 1.ypj %164>]> - - ~zod/try=> (|=(a=* [a 'b']) 'c') - [99 'b'] - ~zod/try=> (`gate`|=(a=* [a 'b']) 'c') - [99 98] - ------------------------------------------------------------------------- - -### `++hair` - - ++ hair ,[p=@ud q=@ud] :: parsing trace - -A pair of two `@ud` used in parsing indicating line and column number. - -See also: `++last`, Section 2eB - - ~zod/try=> *hair - [p=0 q=0] - - ~zod/try=> `hair`[1 1] :: parsing starts at [1 1] as a convention. - [p=1 q=1] - ~zod/try=> ((plus ace) [1 1] " --") - [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]] - ~zod/try=> `hair`p:((plus ace) [1 1] " --") - [p=1 q=4] - ------------------------------------------------------------------------- - -### `++like` - - ++ like |* a=_,* :: generic edge - |= b=_`*`[(hair) ~] :: - :- p=(hair -.b) :: - ^= q :: - ?@ +.b ~ :: - :- ~ :: - u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] :: - -Tile generator for an `++edge`. `++like` generates an `++edge` with a -parsed result set to a specific type. - -See also: `++easy`, `++just`/`++jest`, `++knee`, `++mask`, `++shim`, -`++stir`, `++stun`, Section 2eC - - ~zod/try=> *(like char) - [p=[p=0 q=0] q=~] - - ~zod/try=> (ace [1 1] " a") - [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]] - ~zod/try=> `(like char)`(ace [1 1] " a") - [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]] - ~zod/try=> `(like ,@)`(ace [1 1] " a") - [p=[p=1 q=2] q=[~ [p=32 q=[p=[p=1 q=2] q="a"]]]] - ------------------------------------------------------------------------- - -### `++limb` - - ++ limb $|(term $%([%& p=axis] [%| p=@ud q=term])) :: - -XX move to `++ut` - -Reference into subject by name/axis - -See also: section 2fC-2fD - - ~zod/try=> (ream '^^$') - [%cnzz p=~[[%.n p=2 q=%$]]] - ~zod/try=> (limb &2:(ream '^^$')) - [%.n p=2 q=%$] - ~zod/try=> (limb &2:(ream '^^^$')) - [%.n p=3 q=%$] - ------------------------------------------------------------------------- - -### `++line` - - ++ line ,[p=[%leaf p=odor q=@] q=tile] :: %kelp case - -XX move to `++ut` - -Dicriminated union unionee XX - -Used in compilation and grammar, section 2fC-2fD - - ~zod/try=> (ream '$%([1 a] [%2 b])') - [ %bccm - p - [ %kelp - p - [ i=[p=[%leaf p=~.ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] - t=~[[p=[%leaf p=~.ud q=2] q=[%herb p=[%cnzz p=~[%b]]]]] - ] - ] - ] - ~zod/try=> &3:(ream '$%([1 a] [%2 b])') - p=[p=[%leaf p=%ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] - ~zod/try=> (line &3:(ream '$%([1 a] [%2 b])')) - [p=[%leaf p=~.ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] - ------------------------------------------------------------------------- - -### `++list` - - ++ list |* a=_,* :: null-term list - $|(~ [i=a t=(list a)]) :: - -Tile generator. `++list` generates a tile of a null-terminated list of -homogenous type. - -See also: `++turn`, `++snag`, section 2bB. - - ~zod/try=> *(list) - ~ - ~zod/try=> `(list ,@)`"abc" - ~[97 98 99] - ~zod/try=> (snag 0 "abc") - ~~a - ------------------------------------------------------------------------- - -### `++lone` - - ++ lone |*(a=$+(* *) ,p=a) :: just one thing - -XX unused - -Tile generator. `++lone` puts face of `p` on something. - ------------------------------------------------------------------------- - -### `++mane` - - ++ mane $|(@tas [@tas @tas]) :: XML name/space - -An XML name (tag name or attribute name) with an optional namespace. -Parsed by `++name`:poxa, rendered by `++name`:poxo. - -See also: `++sail` doc, Section 3bD - - ~zod/try=> *mane - %$ - - ~zod/try=> `mane`n.g:`manx`;div:namespace; - %div - ~zod/try=> `mane`n.g:`manx`;div_namespace; - [%div %namespace] - ------------------------------------------------------------------------- - -### `++manx` - - ++ manx ,[g=marx c=marl] :: XML node - -XML node. - -Parsed by `++apex`:poxa, rendered by `++poxo`, section 3bD - -See also: `++sail` doc, Section 3bD - ------------------------------------------------------------------------- - -### `++marl` - - ++ marl (list manx) :: XML node list - -List of XML nodes. - -Parsed within `++apex`:poxa, rendered by `++many`:poxo, section 3bD - -See also: `++sail` doc - ------------------------------------------------------------------------- - -### `++mars` - - ++ mars ,[t=[n=%$ a=[i=[n=%$ v=tape] t=~]] c=~] :: XML cdata - -XML CDATA. Implicitly produced by `++chrd`:poxa - -See also: `++sail` doc - ------------------------------------------------------------------------- - -### `++mart` - - ++ mart (list ,[n=mane v=tape]) :: XML attributes - -List of XML attributes. Each `++mart` is a list of pairs of `++mane` and -`++tape`. - -Parsed by `++attr`:poxa, rendered by `++attr`:poxo, section 3bD - -See also: `++sail` doc - ------------------------------------------------------------------------- - -### `++marx` - - ++ marx ,[n=mane a=mart] :: XML tag - -XML tag. A `++marx` is a pair of a tag name, `++mane` and a list of -attributes, `++mart`. - -Parsed by `++head`:poxa, rendered within `++poxo`, section 3bD - -See also: `++sail` doc - ------------------------------------------------------------------------- - -### `++metl` - - ++ metl ?(%gold %iron %zinc %lead) :: core variance - -XX move to `++ut` - -See also: `++coil` - ------------------------------------------------------------------------- - -### `++noun` - - ++ noun ,* :: any noun - -Used nowhere XX - - ~zod/try=> `noun`~[1 2 3] - [1 2 3 0] - ------------------------------------------------------------------------- - -### `++null` - - ++ null ,~ :: null, nil, etc - -Used nowhere XX - - ~zod/try=> :type; *null - ~ - %~ - ------------------------------------------------------------------------- - -### `++odor` - - ++ odor ,@ta :: atom format - -By convetion, a short name for a category of atom. `++odor` is -circularly defined, `@ta` being the `++odor` of the ASCII subset -commonly used in urbit. - -See also: `++base`, odor reference - - ~zod/try=> `odor`%ux - ~.ux - ------------------------------------------------------------------------- - -### `++tarp` - - ++ tarp ,[d=@ud h=@ud m=@ud s=@ud f=(list ,@ux)] :: parsed time - -The remaining part of a `++date`: day, hour, minute, second and a list -of `@ux` for precision. - -See also: `++date`, `++yell`/`++yule`, Section 2cH - - ~zod/try=> -<- - ~2014.9.20..00.43.33..b52a - ~zod/try=> :: the time is always in your context at -<- - ~zod/try=> (yell -<-) - [d=106.751.991.820.278 h=0 m=43 s=39 f=~[0x54d1]] - - ~zod/try=> (yell ~d20) - [d=20 h=0 m=0 s=0 f=~] - ------------------------------------------------------------------------- - -### `++time` - - ++ time ,@da :: galactic time - -The `@da` odor designates an absolute date atom. - -See also: `++date`, odor reference - - ~zod/try=> `time`-<- - ~2014.9.25..20.01.47..eeac - ~zod/try=> :: the time is always in your context at -<- - ~zod/try=> `time`~2014.1.1 - ~2014.1.1 - ------------------------------------------------------------------------- - -### `++tree` - - ++ tree |* a=_,* :: binary tree - $|(~ [n=a l=(tree a) r=(tree a)]) :: - -Tile generator. A `++tree` can be empty, or contain a node of a type and -left/right sub `++tree`s of the same type. Pretty-printed with `{}`. - - ~zod/try=> `(tree ,[@ tape])`[[1 "hi"] [[2 "bye"] ~ ~] ~] - {[2 "bye"] [1 "hi"]} - ------------------------------------------------------------------------- - -### `++nail` - - ++ nail ,[p=hair q=tape] :: parsing input - -Location in parsed text, and remainder of it. Indicates parsing position -and remaining text to be parsed. - -See also: `++roll` - - ~zod/try=> +<:;~(plug cab cab) - c=tub=[p=[p=0 q=0] q=""] - ~zod/try=> :: tub is a ++nail - ------------------------------------------------------------------------- - -### `++numb` - - ++ numb ,@ :: just a number - -Used nowhere XX - ------------------------------------------------------------------------- - -### `++pair` - - ++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair - -Tile generator. Produces a tuple of two of the types passed in. - - ~zod/try=> *(pair bean cord) - [p=%.y q=''] - ------------------------------------------------------------------------- - -### `++pass` - - ++ pass ,@ :: public key - -Atom alias. Used primarily in crypto. - -See also: `++acru`, `++crua`, `++crub` - ------------------------------------------------------------------------- - -### `++path` - - ++ path (list span) :: filesys location - -A filesystem path. A `++path` is a list of `++span`, `@ta`. Used in -`%clay` and `%eyre` extensively. - - ~zod/try=> `path`"abc" - /a/b/c - ------------------------------------------------------------------------- - -### `++pint` - - ++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range - -A parsing range, mostly used for stacktraces. A `++pint` is a pair of -hairs indicating from - to. - - ~zod/try=> !:(!!) - ! /~zod/try/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]> - ~zod/try=> :: !! always produces a crash - ~zod/try=> `pint`[[1 4] [1 6]] - [p=[p=1 q=4] q=[p=1 q=6]] - ------------------------------------------------------------------------- - -### `++pole` - - ++ pole |* a=_,* :: nameless list - $|(~ [a (pole a)]) :: - -A `++list` without the faces. A `++pole` is a null-terminated tuple -without the `i=` and `t=`. - - ~zod/try=> `(pole char)`"asdf" - [~~a [~~s [~~d [~~f ~]]]] - ------------------------------------------------------------------------- - -### `++port` - - ++ port $: p=axis :: - $= q :: - $% [%& p=type] :: - [%| p=axis q=(list ,[p=type q=foot])] :: - == :: - == :: - -XX move to `++ut` - -Type and location of core-shaped thing? XX Compiler Internals - - ~zod/try=> *port - [p=0 q=[%.y p=%void]] - ------------------------------------------------------------------------- - -### `++post` - - ++ post $: p=axis :: - $= q :: - $% [0 p=type] :: - [1 p=axis q=(list ,[p=type q=foot])] :: - [2 p=twin q=type] :: - == :: - == :: - -XX move to `++ut` - -Type and location of possibly core-shaped thing? XX Compiler Internals - - ~zod/try=> *post - [p=0 q=[%0 p=%void]] - ------------------------------------------------------------------------- - -### `++prop` - - ++ prop $: p=axis :: - $= q :: - [p=?(~ axis) q=(list ,[p=type q=foot])] :: - == :: - -XX move to `++ut` - -Verified core-shaped thing? XX Compiler Internals - - ~zod/try=> *prop - [p=0 q=[p=~ q=~]] - ------------------------------------------------------------------------- - -### `++qual` - - ++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple - ,[p=a q=b r=c s=d] :: - -Tile generator. A `++qual` is a tuple of four of the types passed in.. - - ~zod/try=> *(qual date time tape cord) - [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s=''] - ------------------------------------------------------------------------- - -### `++rege` - - ++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex - $% [%lite p=char] :: literal - [%pair p=rege q=rege] :: ordering - [%capt p=rege q=@u] :: capture group - [%brac p=@] :: p is 256 bitmask - [%eith p=rege q=rege] :: either - [%mant p=rege] :: greedy 0 or more - [%plls p=rege] :: greedy 1 or more - [%betw p=rege q=@u r=@u] :: between q and r - [%bint p=rege q=@u] :: min q - [%bant p=rege q=@u] :: exactly q - [%manl p=rege] :: lazy 0 or more - [%plll p=rege] :: lazy 1 or more - [%betl p=rege q=@u r=@u] :: between q and r lazy - [%binl p=rege q=@u] :: min q lazy - == :: - -Regular expressions. `++rege` defines the cases of a regex. - -See also: `++rexp`, `++repg`, `++pars` - - ~zod/try=> (pars "[a-z]") - [~ [%brac p=10.633.823.807.823.001.954.701.781.295.154.855.936]] - ~zod/try=> (rexp "[a-z]" "abc1") - [~ [~ {[p=0 q="a"]}]] - ------------------------------------------------------------------------- - -### `++ring` - - ++ ring ,@ :: private key - -Atom alias, used primarily in crypto. - -See also: `++acru`, `++crua`, `++crub`. - ------------------------------------------------------------------------- - -### `++rule` - - ++ rule |=(tub=nail `edge`[p.tub ~ ~ tub]) :: parsing rule - -Parsing rule. `++rule` is an empty parsing rule, but it is used to check -that parsing rules match this with `_`. - -See also: `++cold`, Section 2eC - - ~zod/try=> *rule - [p=[p=0 q=0] q=[~ [p=0 q=[p=[p=0 q=0] q=""]]]] - - ~zod/try=> ^+(rule [|=(a=nail [p.a ~])]:|6) - <1.dww [tub=[p=[p=@ud q=@ud] q=""] <101.jzo 1.ypj %164>]> - ~zod/try=> (^+(rule [|=(a=nail [p.a ~ u=['a' a]])]:|6) [1 1] "hi") - [p=[p=1 q=1] q=[~ [p=97 q=[p=[p=1 q=1] q="hi"]]]] - ~zod/try=> ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi") - [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]] - ------------------------------------------------------------------------- - -### `++span` - - ++ span ,@ta :: text-atom (ASCII) - -A restricted text atom for canonical atom syntaxes. The prefix is `~.`. -There are no escape sequences except `~~`, which means `~`, and `~-`, -which means `_`. `-` and `.` encode themselves. No other characters -besides numbers and lowercase letters are permitted. - - ~zod/try=> *span - ~. - - ~zod/try=> `@t`~.foo - 'foo' - ~zod/try=> `@t`~.foo.bar - 'foo.bar' - ~zod/try=> `@t`~.foo~~bar - 'foo~bar' - ~zod/try=> `@t`~.foo~-bar - 'foo_bar' - ~zod/try=> `@t`~.foo-bar - 'foo-bar' - ------------------------------------------------------------------------- - -### `++spot` - - ++ spot ,[p=path q=pint] :: range in file - -Stack trace line. A `++spot` is what we print after crashing. - -See also: `++pint` - - ~zod/try=> :into /=main=/bin/fail/hoon '!: !!' - + /~zod/main/359/bin/fail/hoon - ~zod/try=> :fail - ! /~zod/main/~2014.9.22..18.40.56..ef04/bin/fail/:<[1 5].[1 7]> - ! exit - ------------------------------------------------------------------------- - -### `++tang` - - ++ tang (list tank) :: general error - -Unused XX - ------------------------------------------------------------------------- - -### `++tank` - - ++ tank $% [%leaf p=tape] :: printing formats - $: %palm :: - p=[p=tape q=tape r=tape s=tape] :: - q=(list tank) :: - == :: - $: %rose :: delimeted list - p=[p=tape q=tape r=tape] :: mid open close - q=(list tank) :: - == :: - == - -Pretty-printing structure. A `++tank` is one of three cases. A `%leaf` -is just a string. A `%palm` is XX need more information. A `%rose` is a -list of `++tank` delimted by the strings in `p`. - - ~zod/try=> >(bex 20) (bex 19)< - [%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="1.048.576"] [%leaf p="524.288"]]] - ~zod/try=> (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols - <<"[1.048.576 524.288]">> - ~zod/try=> (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols (two lines) - <<"[ 1.048.576" " 524.288" "]">> - - ~zod/try=> [(bex 150) (bex 151)] :: at 80 cols - [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624 - 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248 - ] - ------------------------------------------------------------------------- - -### `++tape` - - ++ tape (list char) :: like a string - -One of Hoon's two string types, the other being `++cord`. A tape is a -list of chars. - - ~zod/try=> `(list ,char)`"foobar" - "foobar" - ~zod/try=> `(list ,@)`"foobar" - ~[102 111 111 98 97 114] - ------------------------------------------------------------------------- - -### `++term` - - ++ term ,@tas :: Hoon ASCII subset - -A restricted text atom for Hoon constants. The only characters permitted -are lowercase ASCII, - except as the first or last character, and 0-9 -except as the first character. The syntax for `@tas` is the text itself, -always preceded by `%`. This means a term is always cubical. The empty -`@tas` has a special syntax, `$`: - - ~zod/try=> *term - %$ - - ~zod/try=> %dead-fish9 - %dead-fish9 - ~zod/try=> -:!>(%dead-fish9) - [%cube p=271.101.667.197.767.630.546.276 q=[%atom p=%tas]] - ------------------------------------------------------------------------- - -### `++tiki` - - ++ tiki :: test case - $% [& p=(unit term) q=wing] :: simple wing - [| p=(unit term) q=twig] :: named wing - == :: - -XX move to `++ut` - -A `++wing` or `++twig`. - - ~zod/try=> (ream '=+ a=4 ?-(a @ ~)') - [ %tsls - p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]] - q - [ %wthz - p=[%.y p=~ q=~[%a]] - q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]] - ] - ] - ~zod/try=> (ream '=+ a=4 ?-(4 @ ~)') - [ %tsls - p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]] - q - [ %wthz - p=[%.n p=~ q=[%dtzy p=%ud q=4]] - q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]] - ] - ] - ------------------------------------------------------------------------- - -### `++tile` - -See the Tile section of the Hoon Reference. - ------------------------------------------------------------------------- - -### `++toga` - - ++ toga :: face control - $| p=term :: two togas - $% [0 ~] :: no toga - [1 p=term q=toga] :: deep toga - [2 p=toga q=toga] :: cell toga - == :: - -XX move to `++ut` and rune doc (for \^= examples) - -A face, or tree of faces. A `++toga` is applied to anything assigned -using `^=`. - - ~zod/try=> a=1 - a=1 - ~zod/try=> (ream 'a=1') - [%ktts p=p=%a q=[%dtzy p=%ud q=1]] - ~zod/try=> [a b]=[1 2 3] - [a=1 b=[2 3]] - ~zod/try=> (ream '[a b]=[1 2 3]') - [ %ktts - p=[%2 p=p=%a q=p=%b] - q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] - ] - - ~zod/try=> [a ~]=[1 2 3] - [a=1 2 3] - ~zod/try=> (ream '[a ~]=[1 2 3]') - [ %ktts - p=[%2 p=p=%a q=[%0 ~]] - q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] - ] - ------------------------------------------------------------------------- - -### `++trap` - - ++ trap ,_|.(_*) :: makes perfect sense - -A trap is a core with one arm `++$`. - -See also: `|.` - - ~zod/try=> *trap - <1.mws 101.jzo 1.ypj %164> - ~zod/try=> (*trap) - 0 - ~zod/try=> (|.(42)) - 42 - ------------------------------------------------------------------------- - -### `++trel` - - ++ trel |* [a=$+(* *) b=$+(* *) c=$+(* *)] :: just a triple - ,[p=a q=b r=c] :: - -Tile generator. `++trel` is a tuple of three of the types passed in. - - ~zod/try=> *(trel ,@ud ,@t ,@s) - [p=0 q='' r=--0] - ------------------------------------------------------------------------- - -### `++tuna` - - ++ tuna :: tagflow - $% [%a p=twig] :: plain text - [%b p=twig] :: single tag - [%c p=twig] :: simple list - [%d p=twig] :: dynamic list - [%e p=twig q=(list tuna)] :: element - [%f p=(list tuna)] :: subflow - == :: - -An XML template tree. - -Leaf %a contains plain-text, %b an empty tag, %c a static list, %d a -dynamic list, %e a full node element containing a twig and a list of -tuna, and %f is a empty node. - -See also: `++sail` - ------------------------------------------------------------------------- - -### `++twig` - -See Twig section of Hoon reference - ------------------------------------------------------------------------- - -### `++tine` - - ++ tine (list ,[p=tile q=twig]) :: - -Switch statement cases. In `?-`, for example, your list of cases is a -`++tine`. - -See also: `++twig` - - ~zod/try=> (ream '?-(!! @ |, ^ &)') - [ %wthz - p=[%.n p=~ q=[%zpzp ~]] - q - ~[ - [p=[%axil p=[%atom p=~.]] q=[%dtzy p=%f q=1]] - [p=[%axil p=%cell] q=[%dtzy p=%f q=0]] - ] - ] - ~zod/try=> (tine |2:(ream '?-(!! @ |, ^ &)')) - ~[ - [p=[%axil p=[%atom p=~.]] q=[%dtzy p=%f q=1]] - [p=[%axil p=%cell] q=[%dtzy p=%f q=0]] - ] - ------------------------------------------------------------------------- - -### `++tusk` - - ++ tusk (list twig) :: - -Variable-arity expression list. In `:*`, for example, your contents are -a `++tusk`. - -See also: `++twig` - - ~zod/try=> (ream '[1 2 3]') - [%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] - ~zod/try=> (tusk +:(ream '[1 2 3]')) - ~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]] - ------------------------------------------------------------------------- - -### `++tyre` - - ++ tyre (list ,[p=term q=twig]) :: - -Associative list of term to twig, used in jet hint processing. - -See also: `++twig` - ------------------------------------------------------------------------- - -### `++tyke` - - ++ tyke (list (unit twig)) :: - -List of twigs, or gaps left to be inferred, in path parsing. When you -use a path such as `/=main=/pub/src/doc` the path is in fact a `++tyke`, -where the `=` are inferred from your current path. - - ~zod/try=> (scan "/==as=" porc:vast) - [0 ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]] - ~zod/try=> `tyke`+:(scan "/==as=" porc:vast) - ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~] - ------------------------------------------------------------------------- - -### `++tram` - - ++ tram (list ,[p=wing q=twig]) :: - -List of changes by location in context. When using `%=`, for example, -the list of changes is a `++tram`. - -See also: `++twig` - - ~zod/try=> (ream '$(a 1, b 2)') - [ %cnts - p=~[%$] - q=~[[p=~[%a] q=[%dtzy p=%ud q=1]] [p=~[%b] q=[%dtzy p=%ud q=2]]] - ] - ~zod/try=> (tram +:(ream '$(a 1, b 2)')) - ~[[p=~ q=[% p=0]] [p=~[%a] q=[%dtzy p=%ud q=1]] [p=~[%b] q=[%dtzy p=%ud q=2]]] - ------------------------------------------------------------------------- - -### `++nock` - - ++ nock $& [p=nock q=nock] :: autocons - $% [%0 p=@] :: axis select - [%1 p=*] :: constant - [%2 p=nock q=nock] :: compose - [%3 p=nock] :: cell test - [%4 p=nock] :: increment - [%5 p=nock q=nock] :: equality test - [%6 p=nock q=nock r=nock] :: if, then, else - [%7 p=nock q=nock] :: serial compose - [%8 p=nock q=nock] :: push onto subject - [%9 p=@ q=nock] :: select arm and fire - [%10 p=?(@ [p=@ q=nock]) q=nock] :: hint - [%11 p=nock] :: grab data from sky - == :: - -See Nock doc - - ~zod/try=> !=([+(.) 20 -<]) - [[4 0 1] [1 20] 0 4] - ~zod/try=> (nock !=([+(.) 20])) - [p=[%4 p=[%0 p=1]] q=[%1 p=20]] - ------------------------------------------------------------------------- - -### `++tone` - - ++ tone $% [%0 p=*] :: success - [%1 p=(list)] :: blocks - [%2 p=(list ,[@ta *])] :: error ~_s - == :: - -Intermediate Nock computation result. Similar to `++toon`, but stack -trace is not yet rendered. - - ~zod/try=> (mink [[20 21] 0 3] ,~) - [%0 p=21] - - ~zod/try=> (mink [[0] !=(.^(cy//=main/1))] ,~) - [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]] - ~zod/try=> (path [31.075 1.685.027.454 1.852.399.981 49 0]) - /cy/~zod/main/1 - - ~zod/try=> (mink [[1 2] !=(~|(%hi +(.)))] ,~) - [%2 p=~[[~.yelp 26.984]]] - ~zod/try=> (mink [[1 2] !=(!:(+(.)))] ,~) - [ %2 - p - ~[ - [ ~.spot - [ [ 1.685.027.454 - 7.959.156 - \/159.445.990.350.374.058.574.398.238.344.143.957.205.628.479.572.65\/ - 8.112.403.878.526 - \/ \/ - 0 - ] - [1 20] - 1 - 24 - ] - ] - ] - ] - ------------------------------------------------------------------------- - -### `++toon` - - ++ toon $% [%0 p=*] :: success - [%1 p=(list)] :: blocks - [%2 p=(list tank)] :: stack trace - == :: - -Nock computation result. Either success (`%0`), a block with list of -requests blocked on (`%1`), or failure with stack trace (`%2`). - - ~zod/try=> (mock [[20 21] 0 3] ,~) - [%0 p=21] - - ~zod/try=> (mock [[0] !=(.^(cy//=main/1))] ,~) - [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]] - ~zod/try=> (path [31.075 1.685.027.454 1.852.399.981 49 0]) - /cy/~zod/main/1 - - ~zod/try=> (mock [[1 2] !=(!:(+(.)))] ,~) - [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]] - ------------------------------------------------------------------------- - -### `++tune` - - ++ tune $% [%0 p=vase] :: - [%1 p=(list)] :: - [%2 p=(list ,[@ta *])] :: - == :: - -XX Unused - -Probably typed `tone`? - ------------------------------------------------------------------------- - -### `++twin` - - ++ twin ,[p=term q=wing r=axis s=type] :: alias info - -Aliasing. Used in `%bull` `++type` to typecheck aliased faces. - - ~zod/try=> (~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~) - [ %bull - p=[p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] - q=[%cell p=%noun q=[%atom p=%ud]] - ] - ~zod/try=> &2:(~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~) - p=[p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] - ~zod/try=> (twin &2:(~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~)) - [p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] - ------------------------------------------------------------------------- - -### `++type` - -See Type section of Hoon reference - ------------------------------------------------------------------------- - -### `++typo` - - ++ typo type :: old type - -Pointer for `++type`. `++typo` preserves the previous `++type` in your -context when upating. - -See also: `++seem`, `++vise`, `++type` - ------------------------------------------------------------------------- - -### `++udal` - - ++ udal :: atomic change (%b) - $: p=@ud :: blockwidth - q=(list ,[p=@ud q=(unit ,[p=@ q=@])]) :: indels - == :: - -XX Unused - ------------------------------------------------------------------------- - -### `++udon` - - ++ udon :: abstract delta - $: p=umph :: preprocessor - $= q :: patch - $% [%a p=* q=*] :: trivial replace - [%b p=udal] :: atomic indel - [%c p=(urge)] :: list indel - [%d p=upas q=upas] :: tree edit - == :: - == :: - -See `%clay` doc - ------------------------------------------------------------------------- - -### `++umph` - - ++ umph :: change filter - $| $? %a :: no filter - %b :: jamfile - %c :: LF text - == :: - $% [%d p=@ud] :: blocklist - == :: - -See `%clay` doc - ------------------------------------------------------------------------- - -### `++unce` - - ++ unce |* a=_,* :: change part - $% [%& p=@ud] :: skip[copy] - [%| p=(list a) q=(list a)] :: p -> q[chunk] - == :: - -See `%clay` doc - ------------------------------------------------------------------------- - -### `++unit` - - ++ unit |* a=_,* :: maybe - $|(~ [~ u=a]) :: - -Tile generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the -type that was passed in. - -See also: `++bind`, Section 2bA - - ~zod/try=> :type; *(unit time) - ~ - u(@da) - ~zod/try=> `(unit time)`[~ -<-] - [~ ~2014.9.24..19.25.10..7dd5] - ------------------------------------------------------------------------- - -### `++upas` - - ++ upas :: tree change (%d) - $& [p=upas q=upas] :: cell - $% [%0 p=axis] :: copy old - [%1 p=*] :: insert new - [%2 p=axis q=udon] :: mutate! - == :: - -See `%clay` doc - ------------------------------------------------------------------------- - -### `++urge` - - ++ urge |*(a=_,* (list (unce a))) :: list change - -See `%clay` doc - ------------------------------------------------------------------------- - -### `++vase` - - ++ vase ,[p=type q=*] :: type-value pair - -Typed data. A `++vase` is used wherever typed data is explicitly worked -with. - -See `%arvo` doc - - ~zod/try=> `vase`!>(~) - [p=[%cube p=0 q=[%atom p=%n]] q=0] - ------------------------------------------------------------------------- - -### `++vise` - - ++ vise ,[p=typo q=*] :: old vase - -Used to convert from previously-typed data during reboot. - -See `++typo`, `++seer` - ------------------------------------------------------------------------- - -### `++wall` - - ++ wall (list tape) :: text lines (no \n) - -A list of lines. A `++wall` is used instead of a single `++tape` with -`\n`. - -See also: `++wash` - - ~zod/try=> `wall`(wash [0 20] leaf/<(bex 256)>) - << - "\/115.792.089.237.\/" - " 316.195.423.570." - " 985.008.687.907." - " 853.269.984.665." - " 640.564.039.457." - " 584.007.913.129." - " 639.936" - "\/ \/" - >> - ------------------------------------------------------------------------- - -### `++wain` - - ++ wain (list cord) :: text lines (no \n) - -A list of lines. A `++wain` is used instead of a single `++cord` with -`\n`. - -See also: `++lore`, `++role` - - ~zod/try=> `wain`/som/del/rok - <|som del rok|> - ~zod/try=> `wain`(lore ^:@t/=main=/bin/tree/hoon) - <| - !: - :: /===/bin/tree/hoon - |= ^ - |= [pax=path fla=$|(~ [%full ~])] - =- ~[te/-]~ - =+ len=(lent pax) - =+ rend=?~(fla |=(a=path +:(spud (slag len a))) spud) - |- ^- wain - =+ ark=;;(arch .^(cy/pax)) - =- ?~ q.ark - - [(crip (rend pax)) -] - %- zing - %- turn :_ |=(a=@t ^$(pax (weld pax `path`/[a]))) - %- sort :_ aor - %- turn :_ |=([a=@t ~] a) - (~(tap by r.ark)) - |> - ------------------------------------------------------------------------- - -### `++wing` - - ++ wing (list limb) :: - -Address in subject. A `++wing` is a path to a value in the subject. A -term alone is the trivial case of a `++wing`. - -See also: `++twig` - - ~zod/try=> (ream 'a.+.c') - [%cnzz p=~[%a [%.y p=3] %c]] - ~zod/try=> (wing +:(ream 'a.+.c')) - ~[%a [%.y p=3] %c] - ------------------------------------------------------------------------- - -### `++wine` - - ++ wine $| ?(%noun %path %tank %void %wall %wool %yarn) - $% [%atom p=term] :: - [%core p=(list ,@ta) q=wine] :: - [%face p=term q=wine] :: - [%list p=term q=wine] :: - [%pear p=term q=@] :: - [%pick p=(list wine)] :: - [%plot p=(list wine)] :: - [%stop p=@ud] :: - [%tree p=term q=wine] :: - [%unit p=term q=wine] :: - == :: - -Printable type. `++wine` is used for pretty printing. - -See also: `++calf` - - ~zod/try=> ~(dole ut p:!>(*@tas)) - [p={} q=[%atom p=%tas]] - ~zod/try=> `wine`q:~(dole ut p:!>(*@tas)) - [%atom p=%tas] - - ~zod/try=> ~(dole ut p:!>(*path)) - [ p - { [ p=1 - q - [ %pick - p - ~[ - [%pear p=%n q=0] - [%plot p=~[[%face p=%i q=[%atom p=%ta]] [%face p=%t q=[%stop p=1]]]] - ] - ] - ] - } - q=%path - ] - ~zod/try=> `wine`q:~(dole ut p:!>(*path)) - %path - - ~zod/try=> ~(dole ut p:!>(*(map time cord))) - [ p - { [ p=1 - q - [ %pick - p - ~[ - [%pear p=%n q=0] - [ %plot - p - ~[ - [ %face - p=%n - q - [ %plot - p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]] - ] - ] - [%face p=%l q=[%stop p=1]] - [%face p=%r q=[%stop p=1]] - ] - ] - ] - ] - ] - } - q - [ %tree - p=%nlr - q=[%plot p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]]] - ] - ] - ~zod/try=> `wine`q:~(dole ut p:!>(*(map time cord))) - [ %tree - p=%nlr - q=[%plot p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]]] - ] - ------------------------------------------------------------------------- - -### `++wonk` - - ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) :: - :: :: - :: :: - -XX Not a model? - - ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) :: - -Pull result out of a `++edge`, or crash if there's no result. - -See also: `++edge`, Section 2eC - - ~zod/try=> (wide:vast [1 1] "(add 2 2)") - [ p=[p=1 q=10] - q - [ ~ - [ p=[%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]] - q=[p=[p=1 q=10] q=""] - ] - ] - ] - ~zod/try=> (wonk (wide:vast [1 1] "(add 2 2)")) - [%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]] - ------------------------------------------------------------------------- - -### `++map` - - ++ map |* [a=_,* b=_,*] :: associative tree - $|(~ [n=[p=a q=b] l=(map a b) r=(map a b)]) :: - -Tile generator. A `++map` is a -[treap](http://en.wikipedia.org/wiki/Treap) of key, value pairs. - -See also: `++by` - - ~zod/try=> :type; *(map ,@t ,@u) - {} - nlr([p=@t q=@u]) - ~zod/try=> `(map ,@ta ,@ud)`(mo (limo a/1 b/2 ~)) - {[p=~.a q=1] [p=~.b q=2]} - ------------------------------------------------------------------------- - -### `++qeu` - - ++ qeu |* a=_,* :: queue - $|(~ [n=a l=(qeu a) r=(qeu a)]) :: - -Tile generator. A `++qeu` is an ordered -[treap](http://en.wikipedia.org/wiki/Treap) of items. - -See also: `++to` - - ~zod/try=> (qeu time) - <1.qyo [* <1.sxx [a=<1.ebd [* <101.jzo 1.ypj %164>]> <101.jzo 1.ypj %164>]>]> - ~zod/try=> (~(gas to *(qeu time)) [~2014.1.1 ~2014.1.2 ~]) - {~2014.1.2 ~2014.1.1} - ------------------------------------------------------------------------- - -### `++set` - - ++ set |* a=_,* :: set - $|(~ [n=a l=(set a) r=(set a)]) :: - -Tile generator. A `++set` is a -[treap](http://en.wikipedia.org/wiki/Treap) with unique values. - -See also: `++in` - - ~zod/try=> (sa "abc") - {~~a ~~c ~~b} - ~zod/try=> (~(put in (sa "abc")) %d) - {~~d ~~a ~~c ~~b} - ~zod/try=> (~(put in (sa "abc")) %a) - {~~a ~~c ~~b} - ------------------------------------------------------------------------- - -### `++jar` - - ++ jar |*([a=_,* b=_,*] (map a (list b))) :: map of lists - -Tile generator. A `++jar` is a `++map` of `++list`. - -See also: `++ja`, `++by`, `++map`, `++list` - - ~zod/try=> =a (limo [1 2 ~]) - ~zod/try=> a - [i=1 t=[i=2 t=~]] - ~zod/try=> =b (limo [3 4 ~]) - ~zod/try=> b - [i=3 t=[i=4 t=~]] - ~zod/try=> =c (mo (limo [[%a a] [%b b] ~])) - ~zod/try=> c - {[p=%a q=[i=1 t=[i=2 t=~]]] [p=%b q=[i=3 t=[i=4 t=~]]]} - ~zod/try=> (~(get ja c) %a) - [i=1 t=[i=2 t=~]] - ~zod/try=> (~(get ja c) %c) - ~ - ------------------------------------------------------------------------- - -### `++jug` - - ++ jug |*([a=_,* b=_,*] (map a (set b))) :: map of sets - -Tile generator. Similar to `++jar`, but with `++set`. A `++jug` is a -`++map` of `++set`. - -See also: `++ju`, `++by`, `++map`, `++set` - - ~zod/try=> =a (sa (limo [1 2 ~])) - ~zod/try=> a - {1 2} - ~zod/try=> =b (sa (limo [3 4 ~])) - ~zod/try=> b - {4 3} - ~zod/try=> =c (mo (limo [[%a a] [%b b] ~])) - ~zod/try=> c - {[p=%a q={1 2}] [p=%b q={4 3}]} - ~zod/try=> (~(get ju c) %b) - {4 3} - ~zod/try=> (~(put ju c) [%b 5]) - {[p=%a q={1 2}] [p=%b q={5 4 3}]} - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2a.md b/web/docs/dev/hoon/library/2a.md deleted file mode 100644 index 9a89c8700..000000000 --- a/web/docs/dev/hoon/library/2a.md +++ /dev/null @@ -1,450 +0,0 @@ -chapter 2a, basic unsigned math -=============================== - -### `++add` - -Add - - ++ add :: add - ~/ %add - |= [a=@ b=@] - ^- @ - ?: =(0 a) b - $(a (dec a), b +(b)) - :: - -Produces the sum of `a` and `b` as an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (add 2 2) - 4 - ~zod/try=> (add 1 1.000.000) - 1.000.001 - ~zod/try=> (add 1.333 (mul 2 2)) - 1.337 - ------------------------------------------------------------------------- - -### `++cap` - -Tree head - - ++ cap :: tree head - ~/ %cap - |= a=@ - ^- ?(%2 %3) - ?- a - %2 %2 - %3 %3 - ?(%0 %1) !! - * $(a (div a 2)) - == - :: - -Tests whether an `a` is in the head or tail of a noun. Produces the -[cube]() `%2` if it is within the head, or the [cube]() `%3` if is is -within the tail. - -`a` is an [atom](). - - ~zod/try=> (cap 4) - %2 - ~zod/try=> (cap 6) - %3 - ~zod/try=> (cap (add 10 9)) - %2 - ------------------------------------------------------------------------- - -### `++dec` - -Decrement - - ++ dec :: decrement - ~/ %dec - |= a=@ - ~| %decrement-underflow - ?< =(0 a) - =+ b=0 - |- ^- @ - ?: =(a +(b)) b - $(b +(b)) - :: - -Produces `a-1` as an atom. - -`a` is an [atom](). - - ~zod/try=> (dec 7) - 6 - ~zod/try=> (dec 0) - ! decrement-underflow - ! exit - ------------------------------------------------------------------------- - -### `++div` - -Divide - - ++ div :: divide - ~/ %div - |= [a=@ b=@] - ^- @ - ~| 'div' - ?< =(0 b) - =+ c=0 - |- - ?: (lth a b) c - $(a (sub a b), c +(c)) - :: - -Computes `a` divided by `b`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (div 4 2) - 2 - ~zod/try=> (div 17 8) - 2 - ~zod/try=> (div 20 30) - 0 - ------------------------------------------------------------------------- - -### `++fac` - -Factorial - - ++ fac :: factorial - ~/ %fac - |= a=@ - ^- @ - ?: =(0 a) 1 - (mul a $(a (dec a))) - :: - -Computes the factorial of `a`, producing an atom. - -`a` is an [atom](). - - ~zod/try=> (fac 3) - 6 - ~zod/try=> (fac 0) - 1 - ~zod/try=> (fac 11) - 39.916.800 - ------------------------------------------------------------------------- - -### `++gte` - -Greater-than/equal - - ++ gte :: greater-equal - ~/ %gte - |= [a=@ b=@] - ^- ? - !(lth a b) - :: - -Tests whether `a` is greater than a number `b`, producing a loobean. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (gte 100 10) - %.y - ~zod/try=> (gte 4 4) - %.y - ~zod/try=> (gte 3 4) - %.n - ------------------------------------------------------------------------- - -### `++gth` - -Greater-than - - ++ gth :: greater-than - ~/ %gth - |= [a=@ b=@] - ^- ? - !(lte a b) - :: - -Tests whether `a` is greater than `b`, producing a loobean. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (gth 'd' 'c') - %.y - ~zod/try=> (gth ~h1 ~m61) - %.n - ------------------------------------------------------------------------- - -### `++lte` - -Less-than/equal - - ++ lte :: less-equal - ~/ %lte - |= [a=@ b=@] - |(=(a b) (lth a b)) - :: - -Tests whether `a` is less than or equal to `b`, producing a loobean. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (lte 4 5) - %.y - ~zod/try=> (lte 5 4) - %.n - ~zod/try=> (lte 5 5) - %.y - ~zod/try=> (lte 0 0) - %.y - ------------------------------------------------------------------------- - -### `++lth` - -Less-than - - ++ lth :: less-than - ~/ %lth - |= [a=@ b=@] - ^- ? - ?& !=(a b) - |- - ?| =(0 a) - ?& !=(0 b) - $(a (dec a), b (dec b)) - == == == - :: - -Tests whether `a` is less than `b`, producing a loobean. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (lth 4 5) - %.y - ~zod/try=> (lth 5 4) - %.n - ~zod/try=> (lth 5 5) - %.n - ~zod/try=> (lth 5 0) - %.n - ------------------------------------------------------------------------- - -### `++mas` - -Axis within head/tail - - ++ mas :: tree body - ~/ %mas - |= a=@ - ^- @ - ?- a - 1 !! - 2 1 - 3 1 - * (add (mod a 2) (mul $(a (div a 2)) 2)) - == - :: - -Computes the axis of `a` within the head or the tail, producing an atom. - -`a` is an [atom](). - - ~zod/try=> (mas 3) - 1 - ~zod/try=> (mas 4) - 2 - ~zod/try=> (mas 5) - 3 - ~zod/try=> (mas 6) - 2 - ~zod/try=> (mas 0) - ! exit - ~zod/try=> (mas 1) - ! exit - ------------------------------------------------------------------------- - -### `++max` - -Maximum - - ++ max :: maximum - ~/ %max - |= [a=@ b=@] - ^- @ - ?: (gth a b) a - b - :: - -Computes the maximum of `a` and `b`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (max 10 100) - 100 - ~zod/try=> (max 10.443 9) - 10.443 - ~zod/try=> (max 0 1) - 1 - ------------------------------------------------------------------------- - -### `++min` - -Minimum - - ++ min :: minimum - ~/ %min - |= [a=@ b=@] - ^- @ - ?: (lth a b) a - b - :: - -Computes the minimum of `a` and `b`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (min 10 100) - 10 - ~zod/try=> (min 10.443 9) - 9 - ~zod/try=> (min 0 1) - 0 - ------------------------------------------------------------------------- - -### `++mod` - -Modulus - - ++ mod :: remainder - ~/ %mod - |= [a=@ b=@] - ^- @ - ?< =(0 b) - (sub a (mul b (div a b))) - :: - -Computes the remainder of dividing `a` by `b`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - ------------------------------------------------------------------------- - -### `++mul` - -Multiply - - ++ mul :: multiply - ~/ %mul - |= [a=@ b=@] - ^- @ - =+ c=0 - |- - ?: =(0 a) c - $(a (dec a), c (add b c)) - :: - -Multiplies `a` by `b`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (mul 3 4) - 12 - ~zod/try=> (mul 0 1) - 0 - ------------------------------------------------------------------------- - -### `++peg` - -Axis within axis - - ++ peg :: tree connect - ~/ %peg - |= [a=@ b=@] - ^- @ - ?- b - 1 a - 2 (mul a 2) - 3 +((mul a 2)) - * (add (mod b 2) (mul $(b (div b 2)) 2)) - == - :: - -Computes the axis of `b` within axis `a`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (peg 4 1) - 4 - ~zod/try=> (peg 4 2) - 8 - ~zod/try=> (peg 8 45) - 269 - ------------------------------------------------------------------------- - -### `++sub` - -Subtract - - ++ sub :: subtract - ~/ %sub - |= [a=@ b=@] - ~| %subtract-underflow - ^- @ - ?: =(0 b) a - $(a (dec a), b (dec b)) - -Subtracts `b` from `a`, producing an atom. - -`a` is an [atom](). - -`b` is an [atom](). - - ~zod/try=> (sub 10 5) - 5 - ~zod/try=> (sub 243 44) - 199 - ~zod/try=> (sub 5 0) - 5 - ~zod/try=> (sub 0 5) - ! subtract-underflow - ! exit - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2b.md b/web/docs/dev/hoon/library/2b.md deleted file mode 100644 index 0ae4d45fd..000000000 --- a/web/docs/dev/hoon/library/2b.md +++ /dev/null @@ -1,907 +0,0 @@ -chapter 2b, basic containers -============================ - -Section 2bA, units ------------------- - -### `++biff` - -Unit as argument - - ++ biff :: apply - |* [a=(unit) b=$+(* (unit))] - ?~ a ~ - (b u.a) - -Applies a gate that produces a unit, `b`, to the value (`u.a`) of a unit -`a`. If `a` is empty, `~` is produced. - -`a` is a [unit](). - -`b` is a [gate]() that accepts a noun and produces a unit. - - ~zod/try=> (biff (some 5) |=(a=@ (some (add a 2)))) - [~ u=7] - ~zod/try=> (biff ~ |=(a=@ (some (add a 2)))) - ~ - ------------------------------------------------------------------------- - -### `++bind` - -Bind - - ++ bind :: argue - |* [a=(unit) b=gate] - ?~ a ~ - [~ u=(b u.a)] - -Applies a function `b` to the value (`u.a`) of a unit `a`, producing a -unit. - -`a` is a [unit]() - -`b` is a [gate](). - - ~zod/try=> (bind ((unit ,@) [~ 97]) ,@t) - [~ `a`] - ~zod/try=> =a |=(a=@ (add a 1)) - ~zod/try=> (bind ((unit ,@) [~ 2]) a) - [~ 3] - ------------------------------------------------------------------------- - -### `++bond` - -Replace null - - ++ bond :: replace - |* a=trap - |* b=(unit) - ?~ b $:a - u.b - -Replaces an empty unit `b` with the product of a kicked trap `a`. If the -unit is not empty, then the original unit is produced. - -`a` is a [trap](). - -`b` is a [unit](). - - ~zod/try=> (bex 10) - 1.024 - ~zod/try=> ((bond |.((bex 10))) ~) - 1.024 - ~zod/try=> ((bond |.((bex 10))) (slaw %ud '123')) - 123 - ------------------------------------------------------------------------- - -### `++both` - -Group unit values - - ++ both :: all the above - |* [a=(unit) b=(unit)] - ?~ a ~ - ?~ b ~ - [~ u=[u.a u.b]] - -Produces a unit whose value is a cell of the values of two input units -`a` and `b`. If either of the two units are empty, `~` is produced. - -`a` is a [unit](). - -`b` is a [unit](). - - ~zod/try=> (both (some 1) (some %b)) - [~ u=[1 %b]] - ~zod/try=> (both ~ (some %b)) - ~ - ------------------------------------------------------------------------- - -### `++clap` - -Apply gate to two units - - ++ clap :: combine - |* [a=(unit) b=(unit) c=_|=(^ +<-)] - ?~ a b - ?~ b a - [~ u=(c u.a u.b)] - -Applies a binary operation `c` which produces a unit to the values of -two units `a` and `b`. - -`a` is a [unit](). - -`b` is a [unit](). - -`c` is a [gate]() that performs a binary operation. - - ~zod/try=> =u ((unit ,@t) [~ 'a']) - ~zod/try=> =v ((unit ,@t) [~ 'b']) - ~zod/try=> (clap u v |=([a=@t b=@t] (welp (trip a) (trip b)))) - [~ u="ab"] - ~zod/try=> =a ((unit ,@u) [~ 1]) - ~zod/try=> =b ((unit ,@u) [~ 2]) - ~zod/try=> =c |=([a=@ b=@] (add a b)) - ~zod/try=> (clap a b c) - [~ 3] - - ------------------------------------------------------------------------- - -### `++drop` - -Unit list - - ++ drop :: enlist - |* a=(unit) - ?~ a ~ - [i=u.a t=~] - -Produces a [list]() of the value from a unit `a`. - -`a` is a [unit](). - - ~zod/try=> =a ((unit ,@) [~ 97]) - ~zod/try=> (drop a) - [i=97 t=~] - ~zod/try=> =a ((unit ,@) [~]) - ~zod/try=> (drop a) - ~ - ------------------------------------------------------------------------- - -### `++fall` - -Default unit - - ++ fall :: default - |* [a=(unit) b=*] - ?~(a b u.a) - -Produces a default value `b` for a unit `a` in cases where the unit is -null. - -`a` is a [unit](). - -`b` is a [noun]() used as the default value. - - ~zod/try=> (fall ~ `a`) - `a` - ~zod/try=> (fall [~ u=0] `a`) - 0 - ------------------------------------------------------------------------- - -### `++lift` - -Fmap - - ++ lift :: lift gate (fmap) - |* a=gate :: flipped - |* b=(unit) :: curried - (bind b a) :: bind - -Similar to `fmap` in Haskell: accepts a gate `a` that accepts and -produces an unwrapped value, passes it the value of a unit `b`, and then -produces a unit value. - -`a` is a [gate](). - -`b` is a [unit](). - - ~zod/try=> ((lift dec) `(unit ,@)`~) - ~ - ~zod/try=> ((lift dec) `(unit ,@)`[~ 20]) - [~ 19] - ------------------------------------------------------------------------- - -### `++mate` - -Choose - - ++ mate :: choose - |* [a=(unit) b=(unit)] - ?~ b a - ?~ a b - ?.(=(u.a u.b) ~|('mate' !!) a) - -Accepts two units `a` and `b` whose values are expected to be -equivalent. If either is empty, then the value of the other is produced. -If neither are empty, it asserts that both values are the same and -produces that value. If the assertion fails, `++mate` crashes with -`'mate'` in the stack trace. - -`a` is a [unit](). - -`b` is a [unit](). - - ~zod/try=> =a ((unit ,@) [~ 97]) - ~zod/try=> =b ((unit ,@) [~ 97]) - ~zod/try=> (mate a b) - [~ 97] - ~zod/try=> =a ((unit ,@) [~ 97]) - ~zod/try=> =b ((unit ,@) [~]) - ~zod/try=> (mate a b) - [~ 97] - ~zod/try=> =a ((unit ,@) [~ 97]) - ~zod/try=> =b ((unit ,@) [~ 98]) - ~zod/try=> (mate a b) - ! 'mate' - ! exit - ------------------------------------------------------------------------- - -### `++need` - -Unwrap - - ++ need :: demand - |* a=(unit) - ?~ a !! - u.a - -Retrieve the value from a unit and crash if the unit is null. - -`a` is a [unit](). - - ~zod/try=> =a ((unit ,[@t @t]) [~ ['a' 'b']]) - ~zod/try=> (need a) - ['a' 'b'] - ~zod/try=> =a ((unit ,@ud) [~ 17]) - ~zod/try=> (need a) - 17 - ~zod/try=> =a ((unit ,@) [~]) - ~zod/try=> (need a) - ! exit - ------------------------------------------------------------------------- - -### `++some` - -Unify - - ++ some :: lift (pure) - |* a=* - [~ u=a] - -Takes any atom `a` and produces a unit with the value set to `a`. - -`a` is a [noun](). - - ~zod/try=> (some [`a` `b`]) - [~ u=[`a` `b`]] - ~zod/try=> (some &) - [~ u=%.y] - ------------------------------------------------------------------------- - -section 2bB, lists ------------------- - -### `++flop` - -Reverse - - ++ flop :: reverse - ~/ %flop - |* a=(list) - => .(a (homo a)) - ^+ a - =+ b=`_a`~ - |- - ?~ a b - $(a t.a, b [i.a b]) - -Produces the list `a` in reverse order. - -`a` is a [list](). - - ~zod/try=> =a (limo [1 2 3 ~]) - ~zod/try=> (flop a) - ~[3 2 1] - ------------------------------------------------------------------------- - -### `++homo` - -Homogenize - - ++ homo :: homogenize - |* a=(list) - ^+ =< $ - |% +- $ ?:(_? ~ [i=(snag 0 a) t=$]) - -- - a - -Produces a list whose type is a fork of all the contained types in the -list `a`. - -`a` is a [list](). - - ~zod/try=> lyst - [i=1 t=[i=97 t=[i=2 t=[i=98 t=[i=[~ u=10] t=~]]]]] - ~zod/try=> (homo lyst) - ~[1 97 2 98 [~ u=10]] - ~zod/try=> =a (limo [1 2 3 ~]) - ~zod/try=> a - [i=1 t=[i=2 t=[i=3 t=~]]] - ~zod/try=> (homo a) - ~[1 2 3] - ------------------------------------------------------------------------- - -### `++limo` - -List Constructor - - ++ limo :: listify - |* a=* - ^+ =< $ - |% +- $ ?~(a ~ ?:(_? i=-.a t=$ $(a +.a))) - -- - a - -Turns a null-terminated tuple into a list. - -`a` is a null-terminated tuple. - - ~zod/try=> (limo [1 2 3 ~]) - [i=1 t=[i=2 t=[i=3 t=~]]] - ------------------------------------------------------------------------- - -### `++lent` - -List length - - ++ lent :: length - ~/ %lent - |= a=(list) - ^- @ - =+ b=0 - |- - ?~ a b - $(a t.a, b +(b)) - -Produces the length of any list `a` as an atom. - -`a` is a [list](). - - ~zod/try=> (lent (limo [1 2 3 4 ~])) - 4 - ~zod/try=> (lent (limo [1 'a' 2 'b' (some 10) ~])) - 5 - ------------------------------------------------------------------------- - -### `++levy` - -"and" to list - - ++ levy - ~/ %levy :: all of - |* [a=(list) b=_|=(p=* .?(p))] - |- ^- ? - ?~ a & - ?. (b i.a) | - $(a t.a) - -Produces the Boolean "and" of the result of every element in list `a` -passed to gate `b`. - -`a` is a [list](). - -`b` is a [gate](). - - ~zod/try=> =a |=(a=@ (lte a 1)) - ~zod/try=> (levy (limo [0 1 2 1 ~]) a) - %.n - ~zod/try=> =a |=(a=@ (lte a 3)) - ~zod/try=> (levy (limo [0 1 2 1 ~]) a) - %.y - ------------------------------------------------------------------------- - -### `++lien` - -"or" to list - - ++ lien :: some of - ~/ %lien - |* [a=(list) b=$+(* ?)] - |- ^- ? - ?~ a | - ?: (b i.a) & - $(a t.a) - -Produces the Boolean "or" of the result of every element in list `a` -passed to gate `b`. - -`a` is a [list](). - -`b` is a [gate](). - - ~zod/try=> =a |=(a=@ (gte a 1)) - ~zod/try=> (lien (limo [0 1 2 1 ~]) a) - %.y - ~zod/try=> =a |=(a=@ (gte a 3)) - ~zod/try=> (lien (limo [0 1 2 1 ~]) a) - %.n - ------------------------------------------------------------------------- - -### `++murn` - -Maybe transform - - ++ murn :: maybe transform - |* [a=(list) b=$+(* (unit))] - |- - ?~ a ~ - =+ c=(b i.a) - ?~ c - $(a t.a) - [i=u.c t=$(a t.a)] - -Passes each member of list `a` to gate `b`, which must produce a unit. -Produces a new list with all the results that do not produce `~`. - -`a` is a [list](). - -`b` is a [gate]() that produces a [unit](). - - ~zod/try=> =a |=(a=@ ?.((gte a 2) ~ (some (add a 10)))) - ~zod/try=> (murn (limo [0 1 2 3 ~]) a) - [i=12 t=[i=13 t=~]] - ------------------------------------------------------------------------- - -### `++reap` - -Replicate - - ++ reap :: replicate - |* [a=@ b=*] - |- ^- (list ,_b) - ?~ a ~ - [b $(a (dec a))] - -Replicate: produces a list containing `a` copies of `b`. - -`a` is an [atom]() - -`b` is a [noun]() - - ~zod/try=> (reap 20 %a) - ~[%a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a] - ~zod/try=> (reap 5 ~s1) - ~[~s1 ~s1 ~s1 ~s1 ~s1] - ~zod/try=> `@dr`(roll (reap 5 ~s1) add) - ~s5 - ------------------------------------------------------------------------- - -### `++reel` - -Right fold - - ++ reel :: right fold - ~/ %reel - |* [a=(list) b=_|=([* *] +<+)] - |- ^+ +<+.b - ?~ a - +<+.b - (b i.a $(a t.a)) - -Right fold: moves right to left across a list `a`, recursively slamming -a binary gate `b` with an element from `a` and an accumulator, producing -the final value of the accumulator. - -`a` is a [list](). - -`b` is a binary [gate](). - - ~zod/try=> =sum =|([p=@ q=@] |.((add p q))) - ~zod/try=> (reel (limo [1 2 3 4 5 ~]) sum) - 15 - ~zod/try=> =a =|([p=@ q=@] |.((sub p q))) - ~zod/try=> (reel (limo [6 3 1 ~]) a) - 4 - ~zod/try=> (reel (limo [3 6 1 ~]) a) - ! subtract-underflow - ! exit - ------------------------------------------------------------------------- - -### `++roll` - -Left fold - - ++ roll :: left fold - ~/ %roll - |* [a=(list) b=_|=([* *] +<+)] - |- ^+ +<+.b - ?~ a - +<+.b - $(a t.a, b b(+<+ (b i.a +<+.b))) - -Left fold: moves left to right across a list `a`, recursively slamming a -binary gate `b` with an element from the list and an accumulator, -producing the final value of the accumulator. - -`a` is a [list](). - -`b` is a binary [gate](). - - ~zod/try=> =sum =|([p=@ q=@] |.((add p q))) - ~zod/try=> (roll (limo [1 2 3 4 5 ~]) sum) - q=15 - ~zod/try=> =a =|([p=@ q=@] |.((sub p q))) - ~zod/try=> (roll (limo [6 3 1 ~]) a) - ! subtract-underflow - ! exit - ~zod/try=> (roll (limo [1 3 6 ~]) a) - q=4 - ------------------------------------------------------------------------- - -### `++skid` - -Separate - - ++ skid :: separate - |* [a=(list) b=$+(* ?)] - |- ^+ [p=a q=a] - ?~ a [~ ~] - =+ c=$(a t.a) - ?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]]) - -Seperates a list `a` into two lists - Those elements of `a` who produce -true when slammed to gate `b` and those who produce `%.n`. - -`a` is a [list](). - -`b` is a [gate]() that accepts one argument and produces a loobean. - - ~zod/try=> =a |=(a=@ (gth a 1)) - ~zod/try=> (skid (limo [0 1 2 3 ~]) a) - [p=[i=2 t=[i=3 t=~]] q=[i=0 t=[i=1 t=~]]] - ------------------------------------------------------------------------- - -### `++skim` - -Suffix - - ++ skim :: only - ~/ %skim - |* [a=(list) b=_|=(p=* .?(p))] - |- - ^+ a - ?~ a ~ - ?:((b i.a) [i.a $(a t.a)] $(a t.a)) - -Cycles through the members of a list `a`, passing them to a gate `b` and -producing a list of all of the members that produce `%.y`. Inverse of -`++skip`. - -`a` is a [list](). - -`b` is a [gate]() that accepts one argument and produces a loobean. - - ~zod/try=> =a |=(a=@ (gth a 1)) - ~zod/try=> (skim (limo [0 1 2 3 ~]) a) - [i=2 t=[i=3 t=~]] - ------------------------------------------------------------------------- - -### `++skip` - -Except - - ++ skip :: except - ~/ %skip - |* [a=(list) b=_|=(p=* .?(p))] - |- - ^+ a - ?~ a ~ - ?:((b i.a) $(a t.a) [i.a $(a t.a)]) - -Cycles through the members of a list `a`, passing them to a gate `b` and -producing a list of all of the members that produce `%.n`. Inverse of -`++skim`. - -`a` is a [list](). - -`b` is a [gate]() that accepts one argument and produces a loobean. - - ~zod/try=> =a |=(a=@ (gth a 1)) - ~zod/try=> (skip (limo [0 1 2 3 ~]) a) - [i=0 t=[i=1 t=~]] - ------------------------------------------------------------------------- - -### `++scag` - -Prefix - - ++ scag :: prefix - ~/ %scag - |* [a=@ b=(list)] - |- ^+ b - ?: |(?=(~ b) =(0 a)) ~ - [i.b $(b t.b, a (dec a))] - -Accepts an atom `a` and list `b`, producing the first `a` elements of -the front of the list. - -`a` is an [atom](). - -`b` is a [list](). - - ~zod/try=> (scag 2 (limo [0 1 2 3 ~])) - [i=0 t=[i=1 t=~]] - ~zod/try=> (scag 10 (limo [1 2 3 4 ~])) - [i=1 t=[i=2 t=[i=3 t=[i=4 t=~]]]] - ------------------------------------------------------------------------- - -### `++slag` - -Suffix - - ++ slag :: suffix - ~/ %slag - |* [a=@ b=(list)] - |- ^+ b - ?: =(0 a) b - ?~ b ~ - $(b t.b, a (dec a)) - -Accepts an atom `a` and list `b`, producing the remaining elements from -`b` starting at `a`. - -`a` is an [atom](). - -`b` is a [list](). - - ~zod/try=> (slag 2 (limo [1 2 3 4 ~])) - [i=3 t=[i=4 t=~]] - ~zod/try=> (slag 1 (limo [1 2 3 4 ~])) - [i=2 t=[i=3 t=[i=4 t=~]]] - ------------------------------------------------------------------------- - -### `++snag` - -Index - - ++ snag :: index - ~/ %snag - |* [a=@ b=(list)] - |- - ?~ b - ~|('snag-fail' !!) - ?: =(0 a) i.b - $(b t.b, a (dec a)) - -Accepts an atom `a` and a list `b`, producing the element at the index -of `a`and failing if the list is null. Lists are 0-indexed. - -`a` is an [atom](). - -`b` is a [list](). - - ~zod/try=> (snag 2 "asdf") - ~~d - ~zod/try=> (snag 0 `(list ,@ud)`~[1 2 3 4]) - 1 - ------------------------------------------------------------------------- - -### `++sort` - -Quicksort - - ++ sort :: quicksort - ~/ %sort - |* [a=(list) b=$+([* *] ?)] - => .(a ^.(homo a)) - |- ^+ a - ?~ a ~ - %+ weld - $(a (skim t.a |=(c=_i.a (b c i.a)))) - ^+ t.a - [i.a $(a (skim t.a |=(c=_i.a !(b c i.a))))] - -Quicksort: accepts a list `a` and a gate `b` which accepts two nouns and -produces a loobean. `++sort` then produces a list of the elements of `a` -sorted according to `b`. - -`a` is an [atom](). - -`b` is a [gate]() which accepts two nouns and produces a loobean. - - ~zod/try=> =a =|([p=@ q=@] |.((gth p q))) - ~zod/try=> (sort (limo [0 1 2 3 ~]) a) - ~[3 2 1 0] - ------------------------------------------------------------------------- - -### `++swag` - -Infix - - ++ swag :: infix - |* [[a=@ b=@] c=(list)] - (scag b (slag a c)) - -Similar to `substr` in JavaScript: extracts a string infix, beginning at -inclusive index `a`, producing `b` number of characters. - -`a` and `b` are [atom]()s. - -`c` is a [list](). - - ~zod/try=> (swag [2 5] "roly poly") - "ly po" - ~zod/try=> (swag [2 2] (limo [1 2 3 4 ~])) - [i=3 t=[i=4 t=~]] - ------------------------------------------------------------------------- - -### `++turn` - -Gate to list - - ++ turn :: transform - ~/ %turn - |* [a=(list) b=_,*] - |- - ?~ a ~ - [i=(b i.a) t=$(a t.a)] - -Accepts a list `a` and a gate `b`. Produces a list with the gate applied -to each element of the original list. - -`a` is a [list](). - -`b` is a [gate](). - - ~zod/try=> (turn (limo [104 111 111 110 ~]) ,@t) - <|h o o n|> - ~zod/try=> =a |=(a=@ (add a 4)) - ~zod/try=> (turn (limo [1 2 3 4 ~]) a) - ~[5 6 7 8] - ------------------------------------------------------------------------- - -### `++weld` - -Concatenate - - ++ weld :: concatenate - ~/ %weld - |* [a=(list) b=(list)] - => .(a ^.(homo a), b ^.(homo b)) - |- ^+ b - ?~ a b - [i.a $(a t.a)] - -Concatenate two lists `a` and `b`. - -`a` and `b` are [list]()s. - - ~zod/try=> (weld "urb" "it") - ~[~~u ~~r ~~b ~~i ~~t] - ~zod/try=> (weld (limo [1 2 ~]) (limo [3 4 ~])) - ~[1 2 3 4] - ------------------------------------------------------------------------- - -### `++welp` - -Perfect weld - - ++ welp :: perfect weld - =| [* *] - |% - +- $ - ?~ +<- - +<-(. +<+) - +<-(+ $(+<- +<->)) - -- - -Concatenate two lists `a` and `b` without losing their type information -to homogenization. - -`a` and `b` are [list]()s. - - ~zod/try=> (welp "foo" "bar") - "foobar" - ~zod/arvo=/hoon/hoon> (welp ~[60 61 62] ~[%a %b %c]) - [60 61 62 %a %b %c ~] - ~zod/arvo=/hoon/hoon> :type; (welp ~[60 61 62] ~[%a %b %c]) - [60 61 62 %a %b %c ~] - [@ud @ud @ud %a %b %c %~] - ~zod/arvo=/hoon/hoon> (welp [sa/1 so/2 ~] si/3) - [[%sa 1] [%so 2] %si 3] - ------------------------------------------------------------------------- - -### `++wild` - -XXDELETE - - ++ wild :: concatenate - |* [a=(list) b=(list)] - => .(a ^.(homo a), b ^.(homo b)) - |- - ?~ a b - [i=i.a $(a t.a)] - -Concatenates two lists `a` and `b`, homogenizing their types -individually. - -`a` and `b` are [list]()s. - - ~zod/try=> (wild (limo ~[1 2 3]) (limo [4]~)) - ~[1 2 3 4] - ~zod/try=> (wild (limo 60 61 62 ~) (limo %a %b %c ~)) - [i=60 [i=61 [i=62 ~[%a %b %c]]]] - ~zod/try=> (weld (limo 60 61 62 ~) (limo %a %b %c ~)) - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.000 15].[10.016 57]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.001 15].[10.016 57]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.002 15].[10.016 57]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.004 15].[10.016 57]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.006 15].[10.016 57]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.006 29].[10.006 44]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.056 3].[10.061 13]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.058 3].[10.061 13]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.059 3].[10.061 13]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.060 5].[10.060 47]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.826 7].[9.844 35]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.827 7].[9.844 35]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.827 11].[9.838 13]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.828 11].[9.838 13]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.829 13].[9.831 47]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.830 13].[9.831 47]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.706 7].[9.712 25]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.707 7].[9.712 25]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.708 7].[9.712 25]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.712 7].[9.712 25]> - ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.712 8].[9.712 25]> - ! exit - ------------------------------------------------------------------------- - -### `++zing` - -Cons - - ++ zing :: promote - =| * - |% - +- $ - ?~ +< - +< - (welp +<- $(+< +<+)) - -- - -Turns a list of lists into a single list by promoting the elements of -each sublist into the higher. - -Accepts a [list]() of lists. - - ~zod/try=> (zing (limo [(limo ['a' 'b' 'c' ~]) (limo ['e' 'f' 'g' ~]) (limo ['h' 'i' 'j' ~]) ~])) - ~['a' 'b' 'c' 'e' 'f' 'g' 'h' 'i' 'j'] - ~zod/try=> (zing (limo [(limo [1 'a' 2 'b' ~]) (limo [3 'c' 4 'd' ~]) ~])) - ~[1 97 2 98 3 99 4 100] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2c.md b/web/docs/dev/hoon/library/2c.md deleted file mode 100644 index 7aacb19d9..000000000 --- a/web/docs/dev/hoon/library/2c.md +++ /dev/null @@ -1,2134 +0,0 @@ -chapter 2c, simple noun surgery -=============================== - -section 2cA, bit surgery ------------------------- - -### `++bex` - -Binary exponent - - ++ bex :: binary exponent - ~/ %bex - |= a=@ - ^- @ - ?: =(0 a) 1 - (mul 2 $(a (dec a))) - -Computes the result of `2^a`, producing an atom. - -`a` is an [atom](atom). - - ~zod/try=> (bex 4) - 16 - ~zod/try=> (bex (add 19 1)) - 1.048.576 - ~zod/try=> (bex 0) - 1 - ------------------------------------------------------------------------- - -### `++xeb` - -Binary logarithm - - ++ xeb :: binary logarithm - :: ~/ %xeb - |= a=@ - ^- @ - (met 0 a) - -Computes the base-2 logarithm of `a`, producing an atom. - -`a` is an [atom](atom). - - ~zod/try=> (xeb 31) - 5 - ~zod/try=> (xeb 32) - 6 - ~zod/try=> (xeb 49) - 6 - ~zod/try=> (xeb 0) - 0 - ~zod/try=> (xeb 1) - 1 - ~zod/try=> (xeb 2) - 2 - ------------------------------------------------------------------------- - -### `++can` - -Assemble - - ++ can :: assemble - ~/ %can - |= [a=bloq b=(list ,[p=@ q=@])] - ^- @ - ?~ b 0 - (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) - -Produces an atom from a list `b` of length-value pairs `p` and `q`, -where `p` is the length in bloqs of size `a`, and `q` is an atomic -value. - -`a` is a block size (see [++bloq]()). - -`b` is a [list](list) of length value pairs, `p` and `q`. - - ~zod/try=> `@ub`(can 3 ~[[1 1]]) - 0b1 - ~zod/try=> `@ub`(can 0 ~[[1 255]]) - 0b1 - ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] ~) - 0xa00.00c1 - ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~) - 0x23.0a00.00c1 - ~zod/try=> `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~) - 0x23.000a.0000.0000.00c1 - ~zod/try=> `@ux`(can 3 ~[[1 'a'] [2 'bc']]) - 0x63.6261 - ------------------------------------------------------------------------- - -### `++cat` - -Concatenate - - ++ cat :: concatenate - ~/ %cat - |= [a=bloq b=@ c=@] - (add (lsh a (met a b) c) b) - -Concatenates two atoms, `b` and `c`, using bloq size `a`, producing an -atom. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@ub`(cat 3 1 0) - 0b1 - ~zod/try=> `@ub`(cat 0 1 1) - 0b11 - ~zod/try=> `@ub`(cat 0 2 1) - 0b110 - ~zod/try=> `@ub`(cat 2 1 1) - 0b1.0001 - ~zod/try=> `@ub`256 - 0b1.0000.0000 - ~zod/try=> `@ub`255 - 0b1111.1111 - ~zod/try=> `@ub`(cat 3 256 255) - 0b1111.1111.0000.0001.0000.0000 - ~zod/try=> `@ub`(cat 2 256 255) - 0b1111.1111.0001.0000.0000 - ~zod/try=> (cat 3 256 255) - 16.711.936 - ------------------------------------------------------------------------- - -### `++cut` - -Slice - - ++ cut :: slice - ~/ %cut - |= [a=bloq [b=@ c=@] d=@] - (end a c (rsh a b d)) - -Slices `c` blocks of size `a` that are `b` blocks from the end of `d`. -Produces an atom. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> (cut 0 [1 1] 2) - 1 - ~zod/try=> (cut 0 [2 1] 4) - 1 - ~zod/try=> `@t`(cut 3 [0 3] 'abcdefgh') - 'abc' - ~zod/try=> `@t`(cut 3 [1 3] 'abcdefgh') - 'bcd' - ~zod/try=> `@ub`(cut 0 [0 3] 0b1111.0000.1101) - 0b101 - ~zod/try=> `@ub`(cut 0 [0 6] 0b1111.0000.1101) - 0b1101 - ~zod/try=> `@ub`(cut 0 [4 6] 0b1111.0000.1101) - 0b11.0000 - ~zod/try=> `@ub`(cut 0 [3 6] 0b1111.0000.1101) - 0b10.0001 - ------------------------------------------------------------------------- - -### `++end` - -Tail - - ++ end :: tail - ~/ %end - |= [a=bloq b=@ c=@] - (mod c (bex (mul (bex a) b))) - -Produces an atom by taking the last `b` blocks of size `a` from `c`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@ub`12 - 0b1100 - ~zod/try=> `@ub`(end 0 3 12) - 0b100 - ~zod/try=> (end 0 3 12) - 4 - ~zod/try=> `@ub`(end 1 3 12) - 0b1100 - ~zod/try=> (end 1 3 12) - 12 - ~zod/try=> `@ux`'abc' - 0x63.6261 - ~zod/try=> `@ux`(end 3 2 'abc') - 0x6261 - ~zod/try=> `@t`(end 3 2 'abc') - 'ab' - ------------------------------------------------------------------------- - -### `++fil` - -Fill bloqstream - - ++ fil :: fill bloqstream - |= [a=bloq b=@ c=@] - =+ n=0 - =+ d=c - |- ^- @ - ?: =(n b) - (rsh a 1 d) - $(d (add c (lsh a 1 d)), n +(n)) - -Produces an atom by repeating `c` for `b` blocks of size `a`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@t`(fil 3 5 %a) - 'aaaaa' - ~zod/try=> `@t`(fil 5 10 %ceeb) - 'ceebceebceebceebceebceebceebceebceebceeb' - ~zod/try=> `@t`(fil 4 10 %eced) - 'ʇʇʇʇʇʇʇʇʇʇed' - ~zod/try=> `@tas`(fil 4 10 %bf) - %bfbfbfbfbfbfbfbfbfbf - ------------------------------------------------------------------------- - -### `++lsh` - -Left-shift - - ++ lsh :: left-shift - ~/ %lsh - |= [a=bloq b=@ c=@] - (mul (bex (mul (bex a) b)) c) - -Produces an atom by left-shifting `c` by `b` blocks of size `a`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@ub`1 - 0b1 - ~zod/try=> `@ub`(lsh 0 1 1) - 0b10 - ~zod/try=> (lsh 0 1 1) - 2 - ~zod/try=> `@ub`255 - 0b1111.1111 - ~zod/try=> `@ub`(lsh 3 1 255) - 0b1111.1111.0000.0000 - ~zod/try=> (lsh 3 1 255) - 65.280 - ------------------------------------------------------------------------- - -### `++met` - -Measure - - ++ met :: measure - ~/ %met - |= [a=bloq b=@] - ^- @ - =+ c=0 - |- - ?: =(0 b) c - $(b (rsh a 1 b), c +(c)) - -Computes the number of blocks of size `a` in `b`, producing an atom. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - - ~zod/try=> (met 0 1) - 1 - ~zod/try=> (met 0 2) - 2 - ~zod/try=> (met 3 255) - 1 - ~zod/try=> (met 3 256) - 2 - ~zod/try=> (met 3 'abcde') - 5 - ------------------------------------------------------------------------- - -### `++rap` - -Assemble non-zero - - ++ rap :: assemble nonzero - ~/ %rap - |= [a=bloq b=(list ,@)] - ^- @ - ?~ b 0 - (cat a i.b $(b t.b)) - -Concatenate a list of atoms `b` using blocksize `a`, producing an atom. - -`a` is a block size (see [++bloq]()). - -`b` is a [list]() of [atoms](). - - ~zod/try=> `@ub`(rap 2 (limo [1 2 3 4 ~])) - 0b100.0011.0010.0001 - ~zod/try=> `@ub`(rap 1 (limo [1 2 3 4 ~])) - 0b1.0011.1001 - ~zod/try=> (rap 0 (limo [0 0 0 ~])) - 0 - ~zod/try=> (rap 0 (limo [1 0 1 ~])) - 3 - ------------------------------------------------------------------------- - -### `++rep` - -Assemble single - - ++ rep :: assemble single - ~/ %rep - |= [a=bloq b=(list ,@)] - ^- @ - =+ c=0 - |- - ?~ b 0 - (con (lsh a c (end a 1 i.b)) $(c +(c), b t.b)) - -Produces an atom by assembling a list of atoms `b` using block size `a`. - -`a` is a block size (see [++bloq]()). - -`b` is a list of [atoms](). - - ~zod/try=> `@ub`(rep 2 (limo [1 2 3 4 ~])) - 0b100.0011.0010.0001 - ~zod/try=> (rep 0 (limo [0 0 1 ~])) - 4 - ~zod/try=> (rep 0 (limo [0 0 0 1 ~])) - 8 - ~zod/try=> (rep 0 (limo [0 1 0 0 ~])) - 2 - ~zod/try=> (rep 0 (limo [0 1 0 1 ~])) - 10 - ~zod/try=> (rep 0 (limo [0 1 0 1 0 1 ~])) - 42 - ~zod/try=> `@ub`42 - 0b10.1010 - ------------------------------------------------------------------------- - -### `++rip` - -Disassemble - - ++ rip :: disassemble - ~/ %rip - |= [a=bloq b=@] - ^- (list ,@) - ?: =(0 b) ~ - [(end a 1 b) $(b (rsh a 1 b))] - -Produces a list of atoms from the bits of `b` using block size `a`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - - ~zod/try=> `@ub`155 - 0b1001.1011 - ~zod/try=> (rip 0 155) - ~[1 1 0 1 1 0 0 1] - ~zod/try=> (rip 2 155) - ~[11 9] - ~zod/try=> (rip 1 155) - ~[3 2 1 2] - ~zod/try=> `@ub`256 - 0b1.0000.0000 - ~zod/try=> (rip 0 256) - ~[0 0 0 0 0 0 0 0 1] - ~zod/try=> (rip 2 256) - ~[0 0 1] - ~zod/try=> (rip 3 256) - ~[0 1] - ------------------------------------------------------------------------- - -### `++rsh` - -Right-shift - - ++ rsh :: right-shift - ~/ %rsh - |= [a=bloq b=@ c=@] - (div c (bex (mul (bex a) b))) - -Right-shifts `c` by `b` blocks of size `a`, producing an atom. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@ub`145 - 0b1001.0001 - ~zod/try=> `@ub`(rsh 1 1 145) - 0b10.0100 - ~zod/try=> (rsh 1 1 145) - 36 - ~zod/try=> `@ub`(rsh 2 1 145) - 0b1001 - ~zod/try=> (rsh 2 1 145) - 9 - ~zod/try=> `@ub`10 - 0b1010 - ~zod/try=> `@ub`(rsh 0 1 10) - 0b101 - ~zod/try=> (rsh 0 1 10) - 5 - ~zod/try=> `@ux`'abc' - 0x63.6261 - ~zod/try=> `@t`(rsh 3 1 'abc') - 'bc' - ~zod/try=> `@ux`(rsh 3 1 'abc') - 0x6362 - ------------------------------------------------------------------------- - -### `++swap` - -Reverse block order - - ++ swap |=([a=bloq b=@] (rep a (flop (rip a b)))) :: reverse bloq order - -Switches little ending to big and vice versa: produces an atom by -reversing the block order of `b` using block size `a`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom]() - - ~zod/try=> `@ub`24 - 0b1.1000 - ~zod/try=> (swap 0 24) - 3 - ~zod/try=> `@ub`3 - 0b11 - ~zod/try=> (swap 0 0) - 0 - ~zod/try=> (swap 0 128) - 1 - ------------------------------------------------------------------------- - -section 2cB, bit logic ----------------------- - -### `++con` - -Binary OR - - ++ con :: binary or - ~/ %con - |= [a=@ b=@] - =+ [c=0 d=0] - |- ^- @ - ?: ?&(=(0 a) =(0 b)) d - %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) - c +(c) - d %+ add d - %^ lsh 0 c - ?& =(0 (end 0 1 a)) - =(0 (end 0 1 b)) - == - == - -Computes the bit-wise logical OR of two atoms, `a` and `b`, producing an -atom. - -`a` is an [atom]() - -`b` is an [atom]() - - ~zod/try=> (con 0b0 0b1) - 1 - ~zod/try=> (con 0 1) - 1 - ~zod/try=> (con 0 0) - 0 - ~zod/try=> `@ub`(con 0b1111.0000 0b1.0011) - 0b1111.0011 - ~zod/try=> (con 4 4) - 4 - ~zod/try=> (con 10.000 234) - 10.234 - ------------------------------------------------------------------------- - -### `++dis` - -Binary AND - - ++ dis :: binary and - ~/ %dis - |= [a=@ b=@] - =| [c=@ d=@] - |- ^- @ - ?: ?|(=(0 a) =(0 b)) d - %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) - c +(c) - d %+ add d - %^ lsh 0 c - ?| =(0 (end 0 1 a)) - =(0 (end 0 1 b)) - == - == - -Computes the bit-wise logical AND of two atoms `a` and `b`, producing an -atom. - -`a` is an [atom]() - -`b` is an [atom]() - - ~zod/try=> `@ub`9 - 0b1001 - ~zod/try=> `@ub`5 - 0b101 - ~zod/try=> `@ub`(dis 9 5) - 0b1 - ~zod/try=> (dis 9 5) - 1 - ~zod/try=> `@ub`534 - 0b10.0001.0110 - ~zod/try=> `@ub`987 - 0b11.1101.1011 - ~zod/try=> `@ub`(dis 534 987) - 0b10.0001.0010 - ~zod/try=> (dis 534 987) - 530 - ------------------------------------------------------------------------- - -### `++mix` - -Binary XOR - - ++ mix :: binary xor - ~/ %mix - |= [a=@ b=@] - ^- @ - =+ [c=0 d=0] - |- - ?: ?&(=(0 a) =(0 b)) d - %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) - c +(c) - d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) - == - -Produces the bit-wise logical XOR of `a` and `b`, producing an atom. - -`a` is an [atom]() - -`b` is an [atom]() - - ~zod/try=> `@ub`2 - 0b10 - ~zod/try=> `@ub`3 - 0b11 - ~zod/try=> `@ub`(mix 2 3) - 0b1 - ~zod/try=> (mix 2 3) - 1 - ~zod/try=> `@ub`(mix 2 2) - 0b0 - ~zod/try=> (mix 2 2) - 0 - ------------------------------------------------------------------------- - -### `++not` - -Binary NOT - - ++ not |= [a=bloq b=@ c=@] :: binary not (sized) - (mix c (dec (bex (mul b (bex a))))) - -Computes the bit-wise logical NOT of the bottom `b` blocks of size `a` -of `c`. - -`a` is a block size (see [++bloq]()). - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> `@ub`24 - 0b1.1000 - ~zod/try=> (not 0 5 24) - 7 - ~zod/try=> `@ub`7 - 0b111 - ~zod/try=> (not 2 5 24) - 1.048.551 - ~zod/try=> (not 2 5 1.048.551) - 24 - ~zod/try=> (not 1 1 (not 1 1 10)) - 10 - ------------------------------------------------------------------------- - -section 2cC, noun orders ------------------------- - -### `++aor` - -Alphabetic order - - ++ aor :: alphabetic-order - ~/ %aor - |= [a=* b=*] - ^- ? - ?: =(a b) & - ?. ?=(@ a) - ?: ?=(@ b) | - ?: =(-.a -.b) - $(a +.a, b +.b) - $(a -.a, b -.b) - ?. ?=(@ b) & - |- - =+ [c=(end 3 1 a) d=(end 3 1 b)] - ?: =(c d) - $(a (rsh 3 1 a), b (rsh 3 1 b)) - (lth c d) - -Computes whether `a` and `b` are in alphabetical order, producing a -loobean. - -`a` is a [noun](). - -`b` is a [noun](). - - ~zod/try=> (aor 'a' 'b') - %.y - ~zod/try=> (aor 'b' 'a') - %.n - ~zod/try=> (aor "foo" "bar") - %.n - ~zod/try=> (aor "bar" "foo") - %.y - ~zod/try=> (aor "abcdefz" "abcdefa") - %.n - ~zod/try=> (aor "abcdefa" "abcdefz") - %.y - ~zod/try=> (aor 10.000 17.000) - %.y - ~zod/try=> (aor 10 9) - %.n - ------------------------------------------------------------------------- - -### `++dor` - -Numeric order - - ++ dor :: d-order - ~/ %dor - |= [a=* b=*] - ^- ? - ?: =(a b) & - ?. ?=(@ a) - ?: ?=(@ b) | - ?: =(-.a -.b) - $(a +.a, b +.b) - $(a -.a, b -.b) - ?. ?=(@ b) & - (lth a b) - -Computes whether `a` and `b` are in ascending numeric order, producing a -loobean. - -`a` is a [noun](). - -`b` is a [noun](). - - ~zod/try=> (dor 1 2) - %.y - ~zod/try=> (dor 2 1) - %.n - ~zod/try=> (dor ~[1 2 3] ~[1 2 4]) - %.y - ~zod/try=> (dor ~[1 2 4] ~[1 2 3]) - %.n - ~zod/try=> (dor (limo ~[99 100 10.000]) ~[99 101 10.000]) - %.y - ~zod/try=> (dor ~[99 101 10.999] (limo ~[99 100 10.000])) - %.n - ------------------------------------------------------------------------- - -### `++gor` - -Hash order - - ++ gor :: g-order - ~/ %gor - |= [a=* b=*] - ^- ? - =+ [c=(mug a) d=(mug b)] - ?: =(c d) - (dor a b) - (lth c d) - -XX revisit - - ~zod/try=> (gor 'd' 'c') - %.y - ~zod/try=> 'd' - 'd' - ~zod/try=> 'c' - ~zod/try=> `@ud`'d' - 100 - ~zod/try=> `@ud`'c' - 99 - ~zod/try=> (mug 'd') - 1.628.185.714 - ~zod/try=> (mug 'c') - 1.712.073.811 - ~zod/try=> (gor 'd' 'c') - %.y - ~zod/try=> (gor 'c' 'd') - %.n - ~zod/try=> (gor "foo" "bar") - %.n - ~zod/try=> (gor (some 10) (limo [1 2 3 ~])) - %.n - ------------------------------------------------------------------------- - -### `++hor` - -Hash order - - ++ hor :: h-order - ~/ %hor - |= [a=* b=*] - ^- ? - ?: ?=(@ a) - ?. ?=(@ b) & - (gor a b) - ?: ?=(@ b) | - ?: =(-.a -.b) - (gor +.a +.b) - (gor -.a -.b) - -XX revisit - -Recursive hash comparator gate. - - ~zod/try=> (hor . 1) - %.n - ~zod/try=> (hor 1 2) - %.y - ~zod/try=> (hor "abc" "cba") - %.y - ~zod/try=> (hor 'c' 'd') - %.n - ------------------------------------------------------------------------- - -### `++vor` - - ++ vor :: v-order - ~/ %vor - |= [a=* b=*] - ^- ? - =+ [c=(mug (mug a)) d=(mug (mug b))] - ?: =(c d) - (dor a b) - (lth c d) - -XX revisit - -Double hash comparator gate. - - ~zod/try=> (vor 'f' 'g') - %.y - ~zod/try=> (vor 'a' 'z') - %.n - ~zod/try=> (vor 43.326 41.106) - %.n - -section 2cD, insecure hashing ------------------------------ - -### `++fnv` - - ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler - -Hashes an atom with the 32-bit FNV non-cryptographic hash algorithm. -Multiplies `a` by the prime number 16,777,619 and then takes the block -of size 5 off the product's end, producing atom. - -`a` is an [atom](). - - ~zod/try=> (fnv 10.000) - 272.465.456 - ~zod/try=> (fnv 10.001) - 289.243.075 - ~zod/try=> (fnv 1) - 16.777.619 - ------------------------------------------------------------------------- - -### `++mum` - - ++ mum :: mug with murmur3 - ~/ %mum - |= a=* - |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a))))) - ++ spec :: standard murmur3 - |= [syd=@ key=@] - ?> (lte (met 5 syd) 1) - =+ ^= row - |= [a=@ b=@] - (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) - =+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) - =+ len=(met 5 key) - =- =. goc (mix goc len) - =. goc (mix goc (rsh 4 1 goc)) - =. goc (mow goc 0x85eb.ca6b) - =. goc (mix goc (rsh 0 13 goc)) - =. goc (mow goc 0xc2b2.ae35) - (mix goc (rsh 4 1 goc)) - ^= goc - =+ [inx=0 goc=syd] - |- ^- @ - ?: =(inx len) goc - =+ kop=(cut 5 [inx 1] key) - =. kop (mow kop 0xcc9e.2d51) - =. kop (row 15 kop) - =. kop (mow kop 0x1b87.3593) - =. goc (mix kop goc) - =. goc (row 13 goc) - =. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc))) - $(inx +(inx)) - :: - ++ trim :: 31-bit nonzero - |= key=@ - =+ syd=0xcafe.babe - |- ^- @ - =+ haz=(spec syd key) - =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz)) - ?.(=(0 ham) ham $(syd +(syd))) - -- - :: - -XX document - - ~zod/try=> (mum 10.000) - 1.232.632.901 - ~zod/try=> (mum 10.001) - 658.093.079 - ~zod/try=> (mum 1) - 818.387.364 - ~zod/try=> (mum (some 10)) - 1.177.215.703 - ~zod/try=> (mum ~[1 2 3 4 5]) - 1.517.902.092 - -### `++mug` - - ++ mug :: 31bit nonzero FNV1a - ~/ %mug - |= a=* - ?^ a - =+ b=[p=$(a -.a) q=$(a +.a)] - |- ^- @ - =+ c=(fnv (mix p.b (fnv q.b))) - =+ d=(mix (rsh 0 31 c) (end 0 31 c)) - ?. =(0 c) c - $(q.b +(q.b)) - =+ b=2.166.136.261 - |- ^- @ - =+ c=b - =+ [d=0 e=(met 3 a)] - |- ^- @ - ?: =(d e) - =+ f=(mix (rsh 0 31 c) (end 0 31 c)) - ?. =(0 f) f - ^$(b +(b)) - $(c (fnv (mix c (cut 3 [d 1] a))), d +(d)) - -Hashes `a` with the 31-bit nonzero FNV-1a non-cryptographic hash -algorithm, producing an atom. - - ~zod/try=> (mug 10.000) - 178.152.889 - ~zod/try=> (mug 10.001) - 714.838.017 - ~zod/try=> (mug 1) - 67.918.732 - ~zod/try=> (mug (some 10)) - 1.872.403.737 - ~zod/try=> (mug (limo [1 2 3 4 5 ~])) - 1.067.931.605 - -section 2cE, phonetic base --------------------------- - -### `++po` - - ++ po - ~/ %po - =+ :- ^= sis :: prefix syllables - 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ - /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ - /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ - /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ - /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ - /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ - /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ - /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ - /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ - /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ - /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ - /havsaplindibhosdabbitbarracparloddosbortochilmac\ - /tomdigfilfasmithobharmighinradmashalraglagfadtop\ - /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ - /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ - /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' - ^= dex :: suffix syllables - 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\ - /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\ - /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\ - /pyldulhetmevruttylwydtepbesdexsefwycburderneppur\ - /rysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\ - /secmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\ - /selrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\ - /syptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\ - /lytdusnebrumtynseglyxpunresredfunrevrefmectedrus\ - /bexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\ - /tenlusnussyltecmexpubrymtucfyllepdebbermughuttun\ - /bylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\ - /wedducfurfexnulluclennerlexrupnedlecrydlydfenwel\ - /nydhusrelrudneshesfetdesretdunlernyrsebhulryllud\ - /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\ - /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes' - |% - -Provides the phonetic syllables and name generators for the Urbit naming -system. The two faces, `sis` and `dex` are available to the arms -contained in this section. - ------------------------------------------------------------------------- - -### `++ind` - -Parse prefix - - ++ ind ~/ %ind :: parse prefix - |= a=@ - =+ b=0 - |- ^- (unit ,@) - ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b)))) - -Produces the byte of the right-hand syllable `a`. - -`a` is an [atom](). - - ~zod/try=> (ind:po 'zod') - [~ 0] - ~zod/try=> (ind:po 'zam') - ~ - ~zod/try=> (ind:po 'del') - [~ 37] - ------------------------------------------------------------------------- - -### `++ins` - -Parse suffix - - ++ ins ~/ %ins :: parse suffix - |= a=@ - =+ b=0 - |- ^- (unit ,@) - ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b)))) - -Produces the byte of the left-hand phonetic syllable `b`. - -`a` is an [atom](). - - ~zod/try=> (ins:po 'mar') - [~ 1] - ~zod/try=> (ins:po 'son') - [~ 164] - ~zod/try=> (ins:po 'pit') - [~ 242] - ~zod/try=> (ins:po 'pok') - ~ - ------------------------------------------------------------------------- - -### `++tod` - -Fetch prefix - - ++ tod ~/ %tod :: fetch prefix - |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) - -Produces the phonetic prefix syllable from index `a` within `dex` as an -atom. - -`a` is an [atom]() - - ~zod/try=> `@t`(tod:po 1) - 'nec' - ~zod/try=> `@t`(tod:po 98) - 'dec' - ~zod/try=> `@t`(tod:po 0) - 'zod' - ~zod/try=> `@t`(tod:po 150) - 'ryg' - ~zod/try=> `@t`(tod:po 255) - 'fes' - ~zod/try=> `@t`(tod:po 256) - ! exit - ------------------------------------------------------------------------- - -### `++tos` - -Fetch suffix - - ++ tos ~/ %tos :: fetch suffix - |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) - -Produces the phonetic prefix syllable from index `a` within `sis` as an -atom. - - ~zod/try=> `@t`(tos:po 0) - 'doz' - ~zod/try=> `@t`(tos:po 120) - 'fab' - ~zod/try=> `@t`(tos:po 43) - 'pid' - ~zod/try=> `@t`(tos:po 253) - 'mat' - ------------------------------------------------------------------------- - -section 2cF, signed and modular ints ------------------------------------- - -### `++si` - - ++ si !: :: signed integer - |% - -Container for the signed integer functions. - ------------------------------------------------------------------------- - -### `++abs` - - ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value - -Produces the absolute value of a signed integer. - -`a` is a signed integer, `@s`. - - ~zod/try=> (abs:si -2) - 2 - ~zod/try=> (abs:si -10.000) - 10.000 - ~zod/try=> (abs:si --2) - 2 - ------------------------------------------------------------------------- - -### `++dif` - - ++ dif |= [a=@s b=@s] :: subtraction - (sum a (new !(syn b) (abs b))) - -Produces the difference between two signed integers `b` and `c`. - -`a` is a signed integer, `@s`. - -`b` is a signed integer, `@s`. - - ~zod/try=> (dif:si --10 -7) - --17 - ~zod/try=> (dif:si --10 --7) - --3 - ~zod/try=> (dif:si `@s`0 --7) - -7 - ~zod/try=> (dif:si `@s`0 `@s`7) - --4 - ------------------------------------------------------------------------- - -### `++dul` - - ++ dul |= [a=@s b=@] :: modulus - =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))) - -Produces the modulus of two signed integers. - -`a` is a signed integer, `@s`. - -`b` is an [atom](). - - ~zod/try=> (dul:si --9 3) - 0 - ~zod/try=> (dul:si --9 4) - 1 - ~zod/try=> (dul:si --9 5) - 4 - ~zod/try=> (dul:si --9 6) - 3 - ~zod/try=> (dul:si --90 --10) - 10 - ------------------------------------------------------------------------- - -### `++fra` - - ++ fra |= [a=@s b=@s] :: divide - (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b))) - -Produces the quotient of two signed integers. - -`a` is a signed integer, `@s`. - -`b` is a signed integer, `@s`. - - ~zod/try=> (fra:si --10 -2) - -5 - ~zod/try=> (fra:si -20 -5) - --4 - ------------------------------------------------------------------------- - -### `++new` - - ++ new |= [a=? b=@] :: [sign value] to @s - `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))) - -Produces a signed integer from a loobean sign value `a` and an atom `b`. - -`a` is a loobean. - -`b` is an [atom](). - - ~zod/try=> (new:si [& 10]) - --10 - ~zod/try=> (new:si [| 10]) - -10 - ~zod/try=> (new:si [%.y 7]) - --7 - ------------------------------------------------------------------------- - -### `++old` - - ++ old |=(a=@s [(syn a) (abs a)]) :: [sign value] - -Produces the cell `[sign value]` representations of a signed integer. - -`a` is a signed integer, `@s`. - - ~zod/try=> (old:si 7) - ! type-fail - ! exit - ~zod/try=> (old:si -7) - [%.n 7] - ~zod/try=> (old:si --7) - [%.y 7] - ~zod/try=> (old:si `@s`7) - [%.n 4] - ~zod/try=> (old:si -0) - [%.y 0] - ------------------------------------------------------------------------- - -### `++pro` - - ++ pro |= [a=@s b=@s] :: multiplication - (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b))) - -Produces the product of two signed integers. - -`a` is a signed integer, `@s`. - -`b` is a signed integer, `@s`. - - ~zod/try=> (pro:si -4 --2) - -8 - ~zod/try=> (pro:si -4 -2) - --8 - ~zod/try=> (pro:si --10.000.000 -10) - -100.000.000 - ~zod/try=> (pro:si -1.337 --0) - --0 - ------------------------------------------------------------------------- - -### `++rem` - - ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b)))) :: remainder - -Produces the remainder from a division of two signed integers. - -`a` is a signed integer, `@s`. - -`b` is a signed integer, `@s`. - - ~zod/try=> (rem:si -10 -4) - -2 - ~zod/try=> (rem:si --10 --4) - --2 - ~zod/try=> (rem:si --10 -4) - --2 - ~zod/try=> (rem:si --7 --3) - --1 - ~zod/try=> (rem:si --0 --10.000) - --0 - ------------------------------------------------------------------------- - -### `++sum` - - ++ sum |= [a=@s b=@s] :: addition - ~| %si-sum - =+ [c=(old a) d=(old b)] - ?: -.c - ?: -.d - (new & (add +.c +.d)) - ?: (gte +.c +.d) - (new & (sub +.c +.d)) - (new | (sub +.d +.c)) - ?: -.d - ?: (gte +.c +.d) - (new | (sub +.c +.d)) - (new & (sub +.d +.c)) - (new | (add +.c +.d)) - -Sum two signed integers. - -`b` is a signed integer, `@s`. - -`c` is a signed integer, `@s`. - - ~zod/try=> (sum:si --10 --10) - --20 - ~zod/try=> (sum:si --10 -0) - --10 - ~zod/try=> (sum:si -10 -7) - -17 - ~zod/try=> (sum:si -10 --7) - -3 - ------------------------------------------------------------------------- - -### `++sun` - - ++ sun |=(a=@u (mul 2 a)) :: @u to @s - -Produces a signed integer from an unsigned integer. - -Note that the result must be manually cast to some @s odor to be -inferred as an unsigned integer in the type system. - -`a` is an unsigned integer, `@u`. - - ~zod/try=> `@s`10 - --5 - ~zod/try=> (sun:si 10) - 20 - ~zod/try=> `@s`(sun:si 10) - --10 - ~zod/try=> `@sd`(sun:si 10) - --10 - ~zod/try=> `@sd`(sun:si 12.345) - --12.345 - ------------------------------------------------------------------------- - -### `++syn` - - ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test - -Produce the sign of a signed integer, `&` being posiitve, `|` negative. - -`a` is a signed integer, `@s`. - - ~zod/try=> (syn:si -2) - %.n - ~zod/try=> (syn:si --2) - %.y - ~zod/try=> (syn:si -0) - %.y - ------------------------------------------------------------------------- - -### `++cmp` - - ++ cmp |= [a=@s b=@s] :: compare - ^- @s - ?: =(a b) - --0 - ?: (syn a) - ?: (syn b) - ?: (gth a b) - --1 - -1 - --1 - ?: (syn b) - -1 - ?: (gth a b) - -1 - --1 - -Compare two signed integers. - -`b` is a signed integer, `@s`. - -`c` is a signed integer, `@s`. - - ~zod/try=> (cmp:si --10 --10) - --0 - ~zod/try=> (cmp:si --10 -0) - --1 - ~zod/try=> (cmp:si -10 -7) - -1 - ~zod/try=> (cmp:si -10 --7) - -1 - ------------------------------------------------------------------------- - -### `++dif` - - ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c)))) - -Produces the difference between two atoms in the modular basis -representation. - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> (~(dif fe 3) 63 64) - 255 - ~zod/try=> (~(dif fe 3) 5 10) - 251 - ~zod/try=> (~(dif fe 3) 0 1) - 255 - ~zod/try=> (~(dif fe 0) 9 10) - 1 - ~zod/try=> (~(dif fe 0) 9 11) - 0 - ~zod/try=> (~(dif fe 0) 9 12) - 1 - ~zod/try=> (~(dif fe 2) 9 12) - 13 - ~zod/try=> (~(dif fe 2) 63 64) - 15 - ------------------------------------------------------------------------- - -### `++inv` - - ++ inv |=(b=@ (sub (dec out) (sit b))) - -Inverts the order of the modular field. - -`b` is an [atom](). - - ~zod/try=> (~(inv fe 3) 255) - 0 - ~zod/try=> (~(inv fe 3) 256) - 255 - ~zod/try=> (~(inv fe 3) 0) - 255 - ~zod/try=> (~(inv fe 3) 1) - 254 - ~zod/try=> (~(inv fe 3) 2) - 253 - ~zod/try=> (~(inv fe 3) 55) - 200 - ------------------------------------------------------------------------- - -### `++net` - - ++ net |= b=@ ^- @ - => .(b (sit b)) - ?: (lte a 3) - b - =+ c=(dec a) - %+ con - (lsh c 1 $(a c, b (cut c [0 1] b))) - $(a c, b (cut c [1 1] b)) - -Reverse bytes within block. - -`b` is an [atom](). - - ~zod/try=> (~(net fe 3) 64) - 64 - ~zod/try=> (~(net fe 3) 128) - 128 - ~zod/try=> (~(net fe 3) 255) - 255 - ~zod/try=> (~(net fe 3) 256) - 0 - ~zod/try=> (~(net fe 3) 257) - 1 - ~zod/try=> (~(net fe 3) 500) - 244 - ~zod/try=> (~(net fe 3) 511) - 255 - ~zod/try=> (~(net fe 3) 512) - 0 - ~zod/try=> (~(net fe 3) 513) - 1 - ~zod/try=> (~(net fe 3) 0) - 0 - ~zod/try=> (~(net fe 3) 1) - 1 - ~zod/try=> (~(net fe 0) 1) - 1 - ~zod/try=> (~(net fe 0) 2) - 0 - ~zod/try=> (~(net fe 0) 3) - 1 - ~zod/try=> (~(net fe 6) 1) - 72.057.594.037.927.936 - ~zod/try=> (~(net fe 6) 2) - 144.115.188.075.855.872 - ~zod/try=> (~(net fe 6) 3) - 216.172.782.113.783.808 - ~zod/try=> (~(net fe 6) 4) - 288.230.376.151.711.744 - ~zod/try=> (~(net fe 6) 5) - 360.287.970.189.639.680 - ~zod/try=> (~(net fe 6) 6) - 432.345.564.227.567.616 - ~zod/try=> (~(net fe 6) 7) - 504.403.158.265.495.552 - ~zod/try=> (~(net fe 6) 512) - 562.949.953.421.312 - ~zod/try=> (~(net fe 6) 513) - 72.620.543.991.349.248 - ------------------------------------------------------------------------- - -### `++out` - - ++ out (bex (bex a)) - -The maximum integer value that the current block can store. - - ~zod/try=> ~(out fe 0) - 2 - ~zod/try=> ~(out fe 1) - 4 - ~zod/try=> ~(out fe 2) - 16 - ~zod/try=> ~(out fe 3) - 256 - ~zod/try=> ~(out fe 4) - 65.536 - ~zod/try=> ~(out fe 10) - \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.\/ - 273.430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113. - 879.871.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767. - 893.424.865.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838. - 150.682.342.462.881.473.913.110.540.827.237.163.350.510.684.586.298.239. - 947.245.938.479.716.304.835.356.329.624.224.137.216 - \/ \/ - ------------------------------------------------------------------------- - -### `++rol` - - ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left - =+ e=(sit d) - =+ f=(bex (sub a b)) - =+ g=(mod c f) - (sit (con (lsh b g e) (rsh b (sub f g) e))) - -Roll `d` to the left by `c` `b`-sized blocks. - -`b` is a block size (see [++bloq]()). - -`c` is an [atom](). - -`d` is an [atom](). - - ~zod/try=> `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213) - 0x1213.0000.abac.dedf - ~zod/try=> `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213) - 0xdedf.1213.0000.abac - ~zod/try=> `@t`(~(rol fe 5) 3 1 'dfgh') - 'hdfg' - ~zod/try=> `@t`(~(rol fe 5) 3 2 'dfgh') - 'ghdf' - ~zod/try=> `@t`(~(rol fe 5) 3 0 'dfgh') - 'dfgh' - ------------------------------------------------------------------------- - -### `++ror` - - ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right - =+ e=(sit d) - =+ f=(bex (sub a b)) - =+ g=(mod c f) - (sit (con (rsh b g e) (lsh b (sub f g) e))) - -Roll `d` to the right by `c` `b`-sized blocks. - -`b` is a block size (see [++bloq]()). - -`c` is an [atom](). - -`d` is an [atom](). - - ~zod/try=> `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213) - 0x1213.0000.abac.dedf - ~zod/try=> `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213) - 0xacde.df12.1300.00ab - ~zod/try=> `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213) - 0xdf12.1300.00ab.acde - ~zod/try=> `@t`(~(rol fe 5) 3 0 'hijk') - 'hijk' - ~zod/try=> `@t`(~(rol fe 5) 3 1 'hijk') - 'khij' - ~zod/try=> `@t`(~(rol fe 5) 3 2 'hijk') - 'jkhi' - ------------------------------------------------------------------------- - -### `++sum` - - ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add - -Sum two numbers in this modular field. - -`b` is an [atom](). - -`c` is an [atom](). - - ~zod/try=> (~(sum fe 3) 10 250) - 4 - ~zod/try=> (~(sum fe 0) 0 1) - 1 - ~zod/try=> (~(sum fe 0) 0 2) - 0 - ~zod/try=> (~(sum fe 2) 14 2) - 0 - ~zod/try=> (~(sum fe 2) 14 3) - 1 - ~zod/try=> (~(sum fe 4) 10.000 256) - 10.256 - ~zod/try=> (~(sum fe 4) 10.000 100.000) - 44.464 - ------------------------------------------------------------------------- - -### `++sit` - - ++ sit |=(b=@ (end a 1 b)) :: enforce modulo - -Produce an atom in the current modular block representation. - -`b` is an [atom](). - - ~zod/try=> (~(sit fe 3) 255) - 255 - ~zod/try=> (~(sit fe 3) 256) - 0 - ~zod/try=> (~(sit fe 3) 257) - 1 - ~zod/try=> (~(sit fe 2) 257) - 1 - ~zod/try=> (~(sit fe 2) 10.000) - 0 - ~zod/try=> (~(sit fe 2) 100) - 4 - ~zod/try=> (~(sit fe 2) 19) - 3 - ~zod/try=> (~(sit fe 2) 17) - 1 - ~zod/try=> (~(sit fe 0) 17) - 1 - ~zod/try=> (~(sit fe 0) 0) - 0 - ~zod/try=> (~(sit fe 0) 1) - 1 - ------------------------------------------------------------------------- - -section 2cG, floating point ---------------------------- - -XX awaiting interface rewrite - -section 2cH, urbit time ------------------------ - -Note that entering '-\<-' in the shell produces the current time in @da -format. We use this for many of our examples. - - ~zod/try=> -<- - ~2014.8.4..19.39.59..9288 - -### `++year` - - ++ year :: date to @d - |= det=date - ^- @d - =+ ^= yer - ?: a.det - (add 292.277.024.400 y.det) - (sub 292.277.024.400 (dec y.det)) - =+ day=(yawn yer m.det d.t.det) - (yule day h.t.det m.t.det s.t.det f.t.det) - -Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce -its `@d`representation. - -`det` is a [`++date`]() - - ~zod/try=> (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]]) - 0x8000000d227df4e9d940000000000000 - ------------------------------------------------------------------------- - -### `++yore` - - ++ yore :: @d to date - |= now=@d - ^- date - =+ rip=(yell now) - =+ ger=(yall d.rip) - :- ?: (gth y.ger 292.277.024.400) - [a=& y=(sub y.ger 292.277.024.400)] - [a=| y=+((sub 292.277.024.400 y.ger))] - [m.ger d.ger h.rip m.rip s.rip f.rip] - -Produces a `++date` from a `@d` - -`now` is a `@d`. - - ~zod/try=> (yore -<-) - [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=17 s=1 f=~[0x700d]]] - ~zod/try=> (yore -<-) - [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=28 s=53 f=~[0x7b82]]] - ------------------------------------------------------------------------- - -### `++yell` - - ++ yell :: tarp from @d - |= now=@d - ^- tarp - =+ sec=(rsh 6 1 now) - =+ ^= fan - =+ [muc=4 raw=(end 6 1 now)] - |- ^- (list ,@ux) - ?: |(=(0 raw) =(0 muc)) - ~ - => .(muc (dec muc)) - [(cut 4 [muc 1] raw) $(raw (end 4 muc raw))] - =+ day=(div sec day:yo) - => .(sec (mod sec day:yo)) - =+ hor=(div sec hor:yo) - => .(sec (mod sec hor:yo)) - =+ mit=(div sec mit:yo) - => .(sec (mod sec mit:yo)) - [day hor mit sec fan] - -Produce a parsed daily time format from an atomic date. - -`now` is a `@d`. - - ~zod/try=> (yell ~2014.3.20..05.42.53..7456) - [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]] - ~zod/try=> (yell ~2014.6.9..19.09.40..8b66) - [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]] - ~zod/try=> (yell ~1776.7.4) - [d=106.751.991.733.273 h=0 m=0 s=0 f=~] - ------------------------------------------------------------------------- - -### `++yule` - - ++ yule :: time atom - |= rip=tarp - ^- @d - =+ ^= sec ;: add - (mul d.rip day:yo) - (mul h.rip hor:yo) - (mul m.rip mit:yo) - s.rip - == - =+ ^= fac =+ muc=4 - |- ^- @ - ?~ f.rip - 0 - => .(muc (dec muc)) - (add (lsh 4 muc i.f.rip) $(f.rip t.f.rip)) - (con (lsh 6 1 sec) fac) - -Accept a [`++tarp`](/doc/hoon/library/1#++tarp), a parsed daily time, and produces a time atom, -`@d`. - -`rip` is a [`++tarp`](/doc/hoon/library/1#++tarp). - - ~zod/try=> =murica (yell ~1776.7.4) - ~zod/try=> murica - [d=106.751.991.733.273 h=0 m=0 s=0 f=~] - ~zod/try=> (yule murica) - 0x8000000b62aaf5800000000000000000 - ~zod/try=> `@da`(yule murica) - ~1776.7.4 - ~zod/try=> `@da`(yule (yell ~2014.3.20..05.42.53..7456)) - ~2014.3.20..05.42.53..7456 - ~zod/try=> `tarp`[31 12 30 0 ~] - [d=31 h=12 m=30 s=0 f=~] - ~zod/try=> `@dr`(yule `tarp`[31 12 30 0 ~]) - ~d31.h12.m30 - ------------------------------------------------------------------------- - -### `++yall` - - ++ yall :: day # to day of year - |= day=@ud - ^- [y=@ud m=@ud d=@ud] - =+ [era=0 cet=0 lep=_?] - => .(era (div day era:yo), day (mod day era:yo)) - => ^+ . - ?: (lth day +(cet:yo)) - .(lep &, cet 0) - => .(lep |, cet 1, day (sub day +(cet:yo))) - .(cet (add cet (div day cet:yo)), day (mod day cet:yo)) - =+ yer=(add (mul 400 era) (mul 100 cet)) - |- ^- [y=@ud m=@ud d=@ud] - =+ dis=?:(lep 366 365) - ?. (lth day dis) - =+ ner=+(yer) - $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner))) - |- ^- [y=@ud m=@ud d=@ud] - =+ [mot=0 cah=?:(lep moy:yo moh:yo)] - |- ^- [y=@ud m=@ud d=@ud] - =+ zis=(snag mot cah) - ?: (lth day zis) - [yer +(mot) +(day)] - $(mot +(mot), day (sub day zis)) - -Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and -day from a number of days from the beginning of time. - -`day` is an unsigned decimal, `@ud`. - - ~zod/try=> (yall 198) - [y=0 m=7 d=17] - ~zod/try=> (yall 90.398) - [y=247 m=7 d=3] - ~zod/try=> (yall 0) - [y=0 m=1 d=1] - ------------------------------------------------------------------------- - -### `++yawn` - - ++ yawn :: days since Jesus - |= [yer=@ud mot=@ud day=@ud] - ^- @ud - => .(mot (dec mot), day (dec day)) - => ^+ . - %= . - day - =+ cah=?:((yelp yer) moy:yo moh:yo) - |- ^- @ud - ?: =(0 mot) - day - $(mot (dec mot), cah (slag 1 cah), day (add day (snag 0 cah))) - == - |- ^- @ud - ?. =(0 (mod yer 4)) - =+ ney=(dec yer) - $(yer ney, day (add day ?:((yelp ney) 366 365))) - ?. =(0 (mod yer 100)) - =+ nef=(sub yer 4) - $(yer nef, day (add day ?:((yelp nef) 1.461 1.460))) - ?. =(0 (mod yer 400)) - =+ nec=(sub yer 100) - $(yer nec, day (add day ?:((yelp nec) 36.525 36.524))) - (add day (mul (div yer 400) (add 1 (mul 4 36.524)))) - -Inverse of `yall`, computes number of days A.D. from y/m/d date as the -tuple `[yer=@ud mot=@ud day=@ud]`. - -`yer` is an unsigned decimal, `@ud`. - -`mon` is an unsigned decimal, `@ud`. - -`day` is an unsigned decimal, `@ud`. - - ~zod/try=> (yawn 2.014 8 4) - 735.814 - ~zod/try=> (yawn 1.776 7 4) - 648.856 - ~zod/try=> (yawn 1.990 10 11) - 727.116 - ------------------------------------------------------------------------- - -### `++yelp` - - ++ yelp :: leap year - |= yer=@ud ^- ? - &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400)))) - -Determines whether a year contains an ISO 8601 leap week. Produces a -loobean. - -`yer` is an unsigned decimal, `@ud`. - - ~zod/try=> (yelp 2.014) - %.n - ~zod/try=> (yelp 2.008) - %.y - ~zod/try=> (yelp 0) - %.y - ~zod/try=> (yelp 14.011) - %.n - ------------------------------------------------------------------------- - -### `++yo` - - ++ yo :: time constants - - -Useful constants for interacting with earth time. - -### `++cet` - - |% ++ cet 36.524 :: (add 24 (mul 100 365)) - -Days in a century. Derived by multiplying the number of days in a year -(365) by the number of years in a century (100), then adding the number -days from leap years in a century (24). - - ~zod/try=> cet:yo - 36.524 - ~zod/try=> (add 365 cet:yo) - 36.889 - ~zod/try=> (sub (add 24 (mul 100 365)) cet:yo) - 0 - ------------------------------------------------------------------------- - -### `++day` - - ++ day 86.400 :: (mul 24 hor) - -Number of seconds in a day. - - ~zod/try=> day:yo - 86.400 - ~zod/try=> (add 60 day:yo) - 86.460 - ------------------------------------------------------------------------- - -### `++era` - - ++ era 146.097 :: (add 1 (mul 4 cet)) - -XX Revisit - ------------------------------------------------------------------------- - -### `++hor` - - ++ hor 3.600 :: (mul 60 mit) - -The number of seconds in an hour. Derived by multiplying the number of -seconds in a minute by the minutes in an hour. - - ~zod/try=> hor:yo - 3.600 - ~zod/try=> (div hor:yo 60) - 60 - ------------------------------------------------------------------------- - -### `++jes` - - ++ jes 106.751.991.084.417 :: (mul 730.692.561 era) - -XX Revisit - - ~zod/try=> jes:yo - 106.751.991.084.417 - ------------------------------------------------------------------------- - -### `++mit` - - ++ mit 60 - -The number of seconds in a minute. - - ~zod/try=> mit:yo - 60 - ------------------------------------------------------------------------- - -### `++moh` - - ++ moh `(list ,@ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~] - -The days in each month of the Gregorian common year. A list of unsigned -decimal atoms (Either 28, 30, or 31) denoting the number of days in the -month at the year at that index. - - ~zod/try=> moh:yo - ~[31 28 31 30 31 30 31 31 30 31 30 31] - ~zod/try=> (snag 4 moh:yo) - 31 - ------------------------------------------------------------------------- - -### `++moy` - - ++ moy `(list ,@ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~] - -The days in each month of the Gregorian leap-year. A list of unsigned -decimal atoms (Either 29,30, or 31) denoting the number of days in the -month at the leap-year at that index. - - ~zod/try=> moy:yo - ~[31 29 31 30 31 30 31 31 30 31 30 31] - ~zod/try=> (snag 1 moy:yo) - 29 - ------------------------------------------------------------------------- - -### `++qad` - - ++ qad 126.144.001 :: (add 1 (mul 4 yer)) - -The number of seconds in four years. Derived by adding one second to the -number of seconds in four years. - - ~zod/try=> qad:yo - 126.144.001 - ------------------------------------------------------------------------- - -### `++yer` - - ++ yer 31.536.000 :: (mul 365 day) - -The number of seconds in a year. Derived by multiplying the number of -seconds in a day by 365. - - ~zod/try=> yer:yo - 31.536.000 - ------------------------------------------------------------------------- - -section 2cI, almost macros --------------------------- - -### `++cury` - - ++ cury - |* [a=_|=(^ _*) b=*] - |* c=_+<+.a - (a b c) - -Curry a gate, binding the head of its sample - -`a` is a [gate](). - -`b` is a noun. - - ~zod/try=> =mol (cury add 2) - ~zod/try=> (mol 4) - 6 - ~zod/try=> (mol 7) - 9 - ------------------------------------------------------------------------- - -### `++curr` - - ++ curr - |* [a=_|=(^ _*) c=*] - |* b=_+<+.a - (a b c) - -Right curry a gate, binding the tail of its sample - -`a` is a gate. - -`c` is a noun. - - ~zod/try=> =tep (curr scan sym) - ~zod/try=> `@t`(tep "asd") - 'asd' - ~zod/try=> `@t`(tep "lek-om") - 'lek-om' - ------------------------------------------------------------------------- - -### `++cork` - - ++ cork |*([a=_,* b=gate] (corl b a)) :: compose forward - -Build `f` such that `(f x) .= (b (a x))`. - -`a` is a noun. - -`b` is a gate. - - ~zod/try=> (:(cork dec dec dec) 20) - 17 - ~zod/try=> =mal (mo (limo a/15 b/23 ~)) - ~zod/try=> ((cork ~(got by mal) dec) %a) - 14 - ~zod/try=> ((cork ~(got by mal) dec) %b) - 22 - ------------------------------------------------------------------------- - -### `++corl` - - ++ corl :: compose backwards - |* [a=gate b=_,*] - |= c=_+<.b - (a (b c)) - -Gate compose - -XX Revisit - -`a` is a gate. - -`b` is a noun. - - ~zod/try=> ((corl (lift bex) (slat %ud)) '2') - [~ 4] - ------------------------------------------------------------------------- - -### `++hard` - - ++ hard - |* han=$+(* *) - |= fud=* ^- han - ~| %hard - =+ gol=(han fud) - ?>(=(gol fud) gol) - -Demands that a specific type be produced, crashing the program is it is -not. - - ~zod/try=> ((hard (list)) (limo [1 2 3 ~])) - ~[1 2 3] - ~zod/try=> ((hard ,@) (add 2 2)) - 4 - ~zod/try=> ((hard ,@t) (crip "Tape to cord, bro!")) - 'Tape to cord, bro' - ~zod/try=> ((hard tape) (crip "...Tape to cord, bro?...")) - ! hard - ! exit - ------------------------------------------------------------------------- - -### `++soft` - - ++ soft - |* han=$+(* *) - |= fud=* ^- (unit han) - =+ gol=(han fud) - ?.(=(gol fud) ~ [~ gol]) - -Politely requests a specific type to be produced, producing null if it -is not. - - ~zod/try=> ((soft ,%4) (add 2 2)) - [~ %4] - ~zod/try=> ((soft ,@) (add 2 2)) - [~ 4] - ~zod/try=> ((soft ,%5) (add 2 2)) - ~ - ~zod/try=> ((soft ,@t) (crip "Tape to cord, Woohoo!")) - [~ 'Tape to cord, Woohoo!'] - ~zod/try=> ((soft ,@t) (trip 'Cmon man... Tape to cord? Please?!')) - ~ - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2da.md b/web/docs/dev/hoon/library/2da.md deleted file mode 100644 index a29d0fcc4..000000000 --- a/web/docs/dev/hoon/library/2da.md +++ /dev/null @@ -1,437 +0,0 @@ -section 2dA, sets -================= - -### `++apt` - -Set verification - - ++ apt :: set invariant - |= a=(tree) - ?~ a - & - ?& ?~(l.a & ?&((vor n.a n.l.a) (hor n.l.a n.a))) - ?~(r.a & ?&((vor n.a n.r.a) (hor n.a n.r.a))) - == - :: - -Produces a loobean indicating whether `a` is a set or not. - -`a` is a [tree](). - - ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) - ~zod/try=> (apt b) - %.y - ~zod/try=> =m (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ['c' 4] ['d' 5] ~]) - ~zod/try=> m - {[p='d' q=5] [p='a' q=1] [p='c' q=4] [p='b' q=[2 3]]} - ~zod/try=> (apt m) - %.y - ------------------------------------------------------------------------- - -### `++in` - -Set operations - - ++ in :: set engine - ~/ %in - |/ a=(set) - -Input arm. - - ~zod/try=> ~(. in (sa "asd")) - <13.evb [nlr(^$1{@tD $1}) <414.fvk 101.jzo 1.ypj %164>]> - -`a` is a [set]() - -### `+-all:in` - -Logical AND - - +- all :: logical AND - ~/ %all - |* b=$+(* ?) - |- ^- ? - ?~ a - & - ?&((b n.a) $(a l.a) $(a r.a)) - :: - -Computes the logical AND on every element in `a` slammed with `b`, -producing a loobean. - -`a` is a [set](). - -`b` is a [wet gate]() that accepts a noun and produces a loobean. - - ~zod/try=> =b (sa `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(all in b) |=(a=* ?@(+.a & |))) - %.n - ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) - ~zod/try=> (~(all in b) |=(a=@t (gte a 100))) - %.y - ------------------------------------------------------------------------- - -### `+-any:in` - -Logical OR - - +- any :: logical OR - ~/ %any - |* b=$+(* ?) - |- ^- ? - ?~ a - | - ?|((b n.a) $(a l.a) $(a r.a)) - :: - -Computes the logical OR on every element of `a` slammed with `b`. - -`a` is a [set](). - -`b` is a [gate]() that accepts a noun and produces a loobean. - - ~zod/try=> =b (sa `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(any in b) |=(a=* ?@(+.a & |))) - %.y - ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) - ~zod/try=> (~(any in b) |=(a=@t (lte a 100))) - %.n - ------------------------------------------------------------------------- - -### `+-del:in` - -Remove noun - - +- del :: b without any a - ~/ %del - |* b=* - |- ^+ a - ?~ a - ~ - ?. =(b n.a) - ?: (hor b n.a) - [n.a $(a l.a) r.a] - [n.a l.a $(a r.a)] - |- ^- ?(~ _a) - ?~ l.a r.a - ?~ r.a l.a - ?: (vor n.l.a n.r.a) - [n.l.a l.l.a $(l.a r.l.a)] - [n.r.a $(r.a l.r.a) r.r.a] - :: - -Removes `b` from the set `a`. - -`a` is a [set](). - -`b` is a [noun](). - - ~zod/try=> =b (sa `(list ,@t)`['a' 'b' 'c' ~]) - ~zod/try=> (~(del in b) 'a') - {'c' 'b'} - ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) - ~zod/try=> (~(del in b) 'john') - {'bonita' 'madeleine' 'daniel'} - ~zod/try=> (~(del in b) 'susan') - {'bonita' 'madeleine' 'daniel' 'john'} - ------------------------------------------------------------------------- - -### `+-dig:in` - -Axis a in b - - +- dig :: axis of a in b - |= b=* - =+ c=1 - |- ^- (unit ,@) - ?~ a ~ - ?: =(b n.a) [~ u=(peg c 2)] - ?: (gor b n.a) - $(a l.a, c (peg c 6)) - $(a r.a, c (peg c 7)) - :: - -Produce the axis of `b` within `a`. - -`a` is a [set](). - -`b` is a [noun](). - - ~zod/try=> =a (sa `(list ,@)`[1 2 3 4 5 6 7 ~]) - ~zod/try=> a - {5 4 7 6 1 3 2} - ~zod/try=> -.a - n=6 - ~zod/try=> (~(dig in a) 7) - [~ 12] - ~zod/try=> (~(dig in a) 2) - [~ 14] - ~zod/try=> (~(dig in a) 6) - [~ 2] - ------------------------------------------------------------------------- - -### `+-gas:in` - -Concatenate - - +- gas :: concatenate - ~/ %gas - |= b=(list ,_?>(?=(^ a) n.a)) - |- ^+ a - ?~ b - a - $(b t.b, a (put(+< a) i.b)) - :: - -Insert the elements of a list `b` into a set `a`. - -`a` is a [set](). - -`b` is a [list](). - - ~zod/try=> b - {'bonita' 'madeleine' 'rudolf' 'john'} - ~zod/try=> (~(gas in b) `(list ,@t)`['14' 'things' 'number' '1.337' ~]) - {'1.337' '14' 'number' 'things' 'bonita' 'madeleine' 'rudolf' 'john'} - ~zod/try=> (~(gas in s) `(list ,@t)`['1' '2' '3' ~]) - {'1' '3' '2' 'e' 'd' 'a' 'c' 'b'} - ------------------------------------------------------------------------- - -### `+-has:in` - -b in a? - - +- has :: b exists in a check - ~/ %has - |* b=* - |- ^- ? - ?~ a - | - ?: =(b n.a) - & - ?: (hor b n.a) - $(a l.a) - $(a r.a) - :: - -Checks if `b` is an element of `a`, producing a loobean. - -`a` is a [set](). - -`b` is a [noun](). - - ~zod/try=> =a (~(gas in `(set ,@t)`~) `(list ,@t)`[`a` `b` `c` ~]) - ~zod/try=> (~(has in a) `a`) - %.y - ~zod/try=> (~(has in a) 'z') - %.n - ------------------------------------------------------------------------- - -### `+-int:in` - -Intersection - - +- int :: intersection - ~/ %int - |* b=_a - |- ^+ a - ?~ b - ~ - ?~ a - ~ - ?. (vor n.a n.b) - $(a b, b a) - ?: =(n.b n.a) - [n.a $(a l.a, b l.b) $(a r.a, b r.b)] - ?: (hor n.b n.a) - %- uni(+< $(a l.a, b [n.b l.b ~])) $(b r.b) - %- uni(+< $(a r.a, b [n.b ~ r.b])) $(b l.b) - -Produces a set of the intersection between two sets of the same type, -`a` and `b`. - -`a` is a [set](). - -`b` is a [set](). - - ~zod/try=> (~(int in (sa "ac")) (sa "ha")) - {~~a} - ~zod/try=> (~(int in (sa "acmo")) ~) - {} - ~zod/try=> (~(int in (sa "acmo")) (sa "ham")) - {~~a ~~m} - ~zod/try=> (~(int in (sa "acmo")) (sa "lep")) - {} - ------------------------------------------------------------------------- - -### `+-put:in` - -Put b in a - - +- put :: puts b in a - ~/ %put - |* b=* - |- ^+ a - ?~ a - [b ~ ~] - ?: =(b n.a) - a - ?: (hor b n.a) - =+ c=$(a l.a) - ?> ?=(^ c) - ?: (vor n.a n.c) - [n.a c r.a] - [n.c l.c [n.a r.c r.a]] - =+ c=$(a r.a) - ?> ?=(^ c) - ?: (vor n.a n.c) - [n.a l.a c] - [n.c [n.a l.a l.c] r.c] - :: - -Add an element `b` to the set `a`. - -`a` is a [set](). - -`b` is a [noun](). - - ~zod/try=> =a (~(gas in `(set ,@t)`~) `(list ,@t)`[`a` `b` `c` ~]) - ~zod/try=> =b (~(put in a) `d`) - ~zod/try=> b - {`d` `a` `c` `b`} - ~zod/try=> -.l.+.b - n=`d` - ------------------------------------------------------------------------- - -### `+-rep:in` - -Accumulate - - +- rep :: replace by tile - |* [b=* c=_,*] - |- - ?~ a b - $(a r.a, b $(a l.a, b (c n.a b))) - :: - -Accumulate the elements of `a` using a gate `c` and an accumulator `b`. - -`a` is a [set](). - -`b` is a [noun]() that accepts a noun and produces a loobean. - -`c` is a [gate](). - - ~zod/try=> =a (~(gas in *(set ,@)) [1 2 3 ~]) - ~zod/try=> a - {1 3 2} - ~zod/try=> (~(rep in a) 0 |=([a=@ b=@] (add a b))) - 6 - ------------------------------------------------------------------------- - -### `+-tap:in` - -Set to list - - +- tap :: list tiles a set - ~/ %tap - |= b=(list ,_?>(?=(^ a) n.a)) - ^+ b - ?~ a - b - $(a r.a, b [n.a $(a l.a)]) - :: - -Flatten the set `a` into a list. - -`a` is an [set](). - -`a` is a [set](). - -`b` is a [list](). - - ~zod/try=> =s (sa `(list ,@t)`['a' 'b' 'c' 'd' 'e' ~]) - ~zod/try=> s - {'e' 'd' 'a' 'c' 'b'} - ~zod/try=> (~(tap in s) `(list ,@t)`['1' '2' '3' ~]) - ~['b' 'c' 'a' 'd' 'e' '1' '2' '3'] - ~zod/try=> b - {'bonita' 'madeleine' 'daniel' 'john'} - ~zod/try=> (~(tap in b) `(list ,@t)`['david' 'people' ~]) - ~['john' 'daniel' 'madeleine' 'bonita' 'david' 'people'] - ------------------------------------------------------------------------- - -### `+-uni:in` - -Union - - +- uni :: union - ~/ %uni - |* b=_a - |- ^+ a - ?~ b - a - ?~ a - b - ?: (vor n.a n.b) - ?: =(n.b n.a) - [n.b $(a l.a, b l.b) $(a r.a, b r.b)] - ?: (hor n.b n.a) - $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) - $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) - ?: =(n.a n.b) - [n.b $(b l.b, a l.a) $(b r.b, a r.a)] - ?: (hor n.a n.b) - $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) - $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) - -Produces a set of the union between two sets of the same type, `a` and -`b`. - -`a` is a [set](). - -`b` is a [set](). - - ~zod/try=> (~(uni in (sa "ac")) (sa "ha")) - {~~a ~~c ~~h} - ~zod/try=> (~(uni in (sa "acmo")) ~) - {~~a ~~c ~~m ~~o} - ~zod/try=> (~(uni in (sa "acmo")) (sa "ham")) - {~~a ~~c ~~m ~~o ~~h} - ~zod/try=> (~(uni in (sa "acmo")) (sa "lep")) - {~~e ~~a ~~c ~~m ~~l ~~o ~~p} - ------------------------------------------------------------------------- - -### `+-wyt:in` - -Set size - - +- wyt :: size of set - |- ^- @ - ?~(a 0 +((add $(a l.a) $(a r.a)))) - -Produce the number of elements in set `a` as an atom. - -`a` is an [set](). - - ~zod/try=> =a (~(put in (~(put in (sa)) 'a')) 'b') - ~zod/try=> ~(wyt in a) - 2 - ~zod/try=> b - {'bonita' 'madeleine' 'daniel' 'john'} - ~zod/try=> ~(wyt in b) - 4 - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2db.md b/web/docs/dev/hoon/library/2db.md deleted file mode 100644 index 0bf30fe9c..000000000 --- a/web/docs/dev/hoon/library/2db.md +++ /dev/null @@ -1,813 +0,0 @@ -section 2dB, maps -================= - -### `++ept` - -Map invariant. - - ++ ept :: map invariant - |= a=(tree ,[p=* q=*]) - ?~ a - & - ?& ?~(l.a & ?&((vor p.n.a p.n.l.a) (hor p.n.l.a p.n.a))) - ?~(r.a & ?&((vor p.n.a p.n.r.a) (hor p.n.a p.n.r.a))) - == - -Computes whether `a` is a [map](), producing a loobean. - -`a` is a [tree](). - - ~zod/try=> m - {[p='d' q=5] [p='a' q=1] [p='c' q=4] [p='b' q=[2 3]]} - ~zod/try=> (ept m) - %.y - ~zod/try=> b - {'bonita' 'madeleine' 'daniel' 'john'} - ~zod/try=> (ept b) - ! type-fail - ! exit - ------------------------------------------------------------------------- - -### `++ja` - -Jar engine - - ++ ja :: jar engine - |/ a=(jar) - -A container arm for `++jar` operation arms. A `++jar` is a `++map` of -`++list`s. The contained arms inherit the [sample]() jar. - -`a` is a [jar](). - - ~zod/try=> ~(. ja (mo (limo a/"ho" b/"he" ~))) - <2.dgz [nlr([p={%a %b} q=""]) <414.fvk 101.jzo 1.ypj %164>]> - ------------------------------------------------------------------------- - -### `+-get:ja` - -Grab value by key - - +- get :: grab value by key - |* b=* - =+ c=(~(get by a) b) - ?~(c ~ u.c) - -Produces a list retrieved from jar `a` using the key `b`. - -`a` is a [`++jar`](/doc/hoon/library/1#++jar). - -`b` is a key of the same type as the keys in `a`. - - ~zod/try=> =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~]) - ~zod/try=> l - {[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]} - ~zod/try=> (~(get ja l) 'a') - ~[1 2 3] - ~zod/try=> (~(get ja l) 'b') - ~[4 5 6] - ~zod/try=> (~(get ja l) 'c') - ~ - ------------------------------------------------------------------------- - -### `+-add:ja` - -Prepend to list - - +- add :: adds key-list pair - |* [b=* c=*] - =+ d=(get(+< a) b) - (~(put by a) b [c d]) - -Produces jar `a` with value `c` prepended to the list located at key -`b`. - -`a` is a [jar](). - -`b` is a key of the same type as the keys in `a`. - -`c` is a value of the same type as the values in `a`. - - ~zod/try=> =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~]) - ~zod/try=> l - {[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]} - ~zod/try=> (~(add ja l) 'b' 7) - {[p='a' q=~[1 2 3]] [p='b' q=~[7 4 5 6]]} - ~zod/try=> (~(add ja l) 'a' 100) - {[p='a' q=~[100 1 2 3]] [p='b' q=~[4 5 6]]} - ~zod/try=> (~(add ja l) 'c' 7) - {[p='a' q=~[1 2 3]] [p='c' q=~[7]] [p='b' q=~[4 5 6]]} - ~zod/try=> (~(add ja l) 'c' `(list ,@)`[7 8 9 ~]) - ! type-fail - ! exit - ------------------------------------------------------------------------- - -### `++ju` - -Jug operations - - ++ ju :: jug engine - |/ a=(jug) - -Container arm for jug operation arms. A `++jug` is a `++map` of -`++sets`. The contained arms inherit its [sample]() jug, `a`. - -`a` is a [jug](). - - ~zod/try=> ~(. ju (mo (limo a/(sa "ho") b/(sa "he") ~))) - <2.dgz [nlr([p={%a %b} q={nlr(^$1{@tD $1}) nlr(^$3{@tD $3})}]) <414.fvk 101.jzo 1.ypj %164>]> - -### `+-del:ju` - -Remove - - +- del :: delete at key b - |* [b=* c=*] - ^+ a - =+ d=(get(+< a) b) - =+ e=(~(del in d) c) - ?~ e - (~(del by a) b) - (~(put by a) b e) - -Produces jug `a` with value `c` removed from set located at key `b`. - -`a` is a [jug](). - -`b` is a key of the same type as the keys in `a`. - -`c` is the value of the same type of the keys in `a` that is to be -removed. - - ~zod/try=> s - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(del ju s) 'a' 1) - {[p='a' q={3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(del ju s) 'c' 7) - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ------------------------------------------------------------------------- - -### `+-get:ju` - -Retrieve set - - +- get :: gets set by key - |* b=* - =+ c=(~(get by a) b) - ?~(c ~ u.c) - -Produces a set retrieved from jar `a` using key `b`. - -`a` is a [jar](). - -`b` is a key of the same type as the keys in `a`. - - ~zod/try=> s - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(get ju s) 'a') - {1 3 2} - ~zod/try=> (~(get ju s) 'b') - {5 4 6} - ~zod/try=> (~(get ju s) 'c') - ~ - ------------------------------------------------------------------------- - -### `+-has:ju` - -Check contents - - +- has :: existence check - |* [b=* c=*] - ^- ? - (~(has in (get(+< a) b)) c) - -Computes whether a value `c` exists within the set located at key `b` -with jar `a`. Produces a loobean. - -`a` is a [set](). - -`b` is a key as a [noun](). - -`c` is a value as a [noun](). - - ~zod/try=> s - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(has ju s) 'a' 3) - %.y - ~zod/try=> (~(has ju s) 'b' 6) - %.y - ~zod/try=> (~(has ju s) 'a' 7) - %.n - ~zod/try=> (~(has jus s) 'c' 7) - ! -find-limb.jus - ! find-none - ! exit - ~zod/try=> (~(has ju s) 'c' 7) - %.n - ------------------------------------------------------------------------- - -### `+-put:ju` - -Add key-set pair - - +- put :: adds key-element pair - |* [b=* c=*] - ^+ a - =+ d=(get(+< a) b) - (~(put by a) b (~(put in d) c)) - -Produces jar `a` with `c` added to the set value located at key `b`. - -`a` is a [set](). - -`b` is a key as a [noun](). - -`c` is a [value](). - - ~zod/try=> s - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(put ju s) 'a' 7) - {[p='a' q={7 1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(put ju s) 'a' 1) - {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} - ~zod/try=> (~(put ju s) 'c' 7) - {[p='a' q={1 3 2}] [p='c' q={7}] [p='b' q={5 4 6}]} - ------------------------------------------------------------------------- - -### `++by` - -Map operations - - ++ by :: map engine - ~/ %by - |/ a=(map) - -Container arm for map operation arms. A map is a set of key, value -pairs. The contained arms inherit it's [sample]() [map](), `a`. - -`a` is a [map](). - - ~zod/try=> ~(. by (mo (limo [%a 1] [%b 2] ~))) - <19.irb [nlr([p={%a %b} q=@ud]) <414.rvm 101.jzo 1.ypj %164>]> - ------------------------------------------------------------------------- - -### `+-all:by` - -Logical AND - - +- all :: logical AND - ~/ %all - |* b=$+(* ?) - |- ^- ? - ?~ a - & - ?&((b q.n.a) $(a l.a) $(a r.a)) - -Computes the logical AND on the results of slamming every element in map -`a` with gate `b`. Produces a loobean. - -`a` is a [map](). - -`b` is a [wet gate](). - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(all by b) |=(a=* ?@(a & |))) - %.n - ~zod/try=> =a (mo `(list ,[@t @u])`[['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~]) - ~zod/try=> (~(all by a) |=(a=@ (lte a 6))) - %.y - ~zod/try=> (~(all by a) |=(a=@ (lte a 4))) - %.n - ------------------------------------------------------------------------- - -### `+-any:by` - -Logical OR - - +- any :: logical OR - ~/ %any - |* b=$+(* ?) - |- ^- ? - ?~ a - | - ?|((b q.n.a) $(a l.a) $(a r.a)) - -Computes the logical OR on the results of slamming every element with -gate `b`. Produces a loobean. - -`a` is a [map](). - -`b` is a [wet gate](). - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(all by b) |=(a=* ?@(a & |))) - %.y - ~zod/try=> =a (mo `(list ,[@t @u])`[['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~]) - ~zod/try=> (~(any by a) |=(a=@ (lte a 4))) - %.y - ------------------------------------------------------------------------- - -### `+-del:by` - -Delete - - +- del :: delete at key b - ~/ %del - |* b=* - |- ^+ a - ?~ a - ~ - ?. =(b p.n.a) - ?: (gor b p.n.a) - [n.a $(a l.a) r.a] - [n.a l.a $(a r.a)] - |- ^- ?(~ _a) - ?~ l.a r.a - ?~ r.a l.a - ?: (vor p.n.l.a p.n.r.a) - [n.l.a l.l.a $(l.a r.l.a)] - [n.r.a $(r.a l.r.a) r.r.a] - -Produces map `a` with the element located at key `b` removed. - -`a` is a [map](). - -`b` is a key as a [noun](). - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(del by b) `a`) - {[p=`b` q=[2 3]]} - ------------------------------------------------------------------------- - -### `+-dig:by` - -Axis of key - - +- dig :: axis of key - |= b=* - =+ c=1 - |- ^- (unit ,@) - ?~ a ~ - ?: =(b p.n.a) [~ u=(peg c 2)] - ?: (gor b p.n.a) - $(a l.a, c (peg c 6)) - $(a r.a, c (peg c 7)) - -Produce the axis of key `b` within map `a`. - -`a` is a [map](). - -`b` is a key as a [noun](). - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(dig by b) `b`) - [~ 2] - ------------------------------------------------------------------------- - -### `+-gas:by` - -Concatenate - - +- gas :: concatenate - ~/ %gas - |* b=(list ,[p=* q=*]) - => .(b `(list ,_?>(?=(^ a) n.a))`b) - |- ^+ a - ?~ b - a - $(b t.b, a (put(+< a) p.i.b q.i.b)) - -Insert a list of key-value pairs `b` into map `a`. - -`a` is a [map](). - -`b` is a [list]() of [cells]() of key-value nouns `p` and `q`. - - ~zod/try=> =a (mo `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) - ~zod/try=> =b `(list ,[@t *])`[[`c` 3] [`d` 4] ~] - ~zod/try=> (~(gas by a) b) - {[p=`d` q=4] [p=`a` q=1] [p=`c` q=3] [p=`b` q=2]} - ------------------------------------------------------------------------- - -### `+-get:by` - -Grab unit value - - +- get :: unit value by key - ~/ %get - |* b=* - |- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)]) - ?~ a - ~ - ?: =(b p.n.a) - [~ u=q.n.a] - ?: (gor b p.n.a) - $(a l.a) - $(a r.a) - -Produce the unit value of the value located at key `b` within map `a`. - -`a` is a [map]() - -`b` is a [key]() as a [noun]() - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(get by b) `b`) - [~ [2 3]] - ------------------------------------------------------------------------- - -### `+-got:by` - -Assert - - +- got - |* b=* - %- need - %- get(+< a) b - -Produce the value located at key `b` within map `a`. Crash if key `b` -does not exist. - -`a` is a [map](). - -`b` is a [key](). - - ~zod/try=> =m (mo `(list ,[@t *])`[['a' 1] ['b' 2] ~]) - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(get by m) 'a') - [~ 1] - ~zod/try=> (~(got by m) 'a') - 1 - ~zod/try=> (~(got by m) 'c') - ! exit - ------------------------------------------------------------------------- - -### `+-has:by` - -Key existence check - - +- has :: key existence check - ~/ %has - |* b=* - !=(~ (get(+< a) b)) - -Checks whether map `a` contains an element with key `b`, producing a -loobean. - -`a` is a [map](). - -`b` is a key as a [noun](). - - ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) - ~zod/try=> (~(has by b) `b`) - %.y - ~zod/try=> (~(has by b) `c`) - %.n - ------------------------------------------------------------------------- - -### `+-int:by` - -Intersection - - +- int :: intersection - ~/ %int - |* b=_a - |- ^+ a - ?~ b - ~ - ?~ a - ~ - ?: (vor p.n.a p.n.b) - ?: =(p.n.b p.n.a) - [n.b $(a l.a, b l.b) $(a r.a, b r.b)] - ?: (hor p.n.b p.n.a) - %- uni(+< $(a l.a, b [n.b l.b ~])) $(b r.b) - %- uni(+< $(a r.a, b [n.b ~ r.b])) $(b l.b) - ?: =(p.n.a p.n.b) - [n.b $(b l.b, a l.a) $(b r.b, a r.a)] - ?: (hor p.n.a p.n.b) - %- uni(+< $(b l.b, a [n.a l.a ~])) $(a r.a) - %- uni(+< $(b r.b, a [n.a ~ r.a])) $(a l.a) - -Produces a map of the (key) intersection between two maps of the same -type, `a` and `b`. If both maps have an identical key that point to -different values, the element from map `b` is used. - -`a` is a [map](). - -`b` is a [map](). - - ~zod/try=> =n (mo `(list ,[@t *])`[['a' 1] ['c' 3] ~]) - ~zod/try=> n - {[p='a' q=1] [p='c' q=3]} - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(int by m) n) - {[p='a' q=1]} - ~ravpel-holber/try=> =p (mo `(list ,[@t *])`[['a' 2] ['b' 2] ~]) - ~zod/try=> p - {[p='a' q=2] [p='b' q=2]} - ~zod/try=> (~(int by p) n) - {[p='a' q=2]} - ~zod/try=> =q (mo `(list ,[@t *])`[['a' 2] ['c' 2] ~]) - ~zod/try=> q - {[p='a' q=2] [p='b' q=2]} - ~zod/try=> (~(int by p) q) - {[p='a' q=2] [p='b' q=2]} - ~zod/try=> =o (mo `(list ,[@t *])`[['c' 3] ['d' 4] ~]) - ~zod/try=> (~(int by m) o) - {} - - ------------------------------------------------------------------------- - -### `+-mar:by` - -Assert and Add - - +- mar :: add with validation - |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))] - ?~ c - (del b) - (put b u.c) - -Produces map `a` with the addition of a key-value pair, where the value -is a nonempty unit. - -Accept a noun and a unit of a noun of the type of the map's keys and -values, respectively. Validate that the value is not null and put the -pair in the map. If the value is null, delete the key. - -XX This arm is broken, asana task 15186618346453 - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(mar by m) 'c' (some 3)) - ! -find-limb.n - ! find-none - ! exit - ~zod/try=> (~(mar by m) 'c' ~) - ! -find-limb.n - ! find-none - ! exit - ~zod/try=> (~(mar by m) 'b' ~) - ! -find-limb.n - ! find-none - ! exit - ------------------------------------------------------------------------- - -### `+-put:by` - -Add key-value pair - - +- put :: adds key-value pair - ~/ %put - |* [b=* c=*] - |- ^+ a - ?~ a - [[b c] ~ ~] - ?: =(b p.n.a) - ?: =(c q.n.a) - a - [[b c] l.a r.a] - ?: (gor b p.n.a) - =+ d=$(a l.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a d r.a] - [n.d l.d [n.a r.d r.a]] - =+ d=$(a r.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a l.a d] - [n.d [n.a l.a l.d] r.d] - -Produces `a` with the addition of the key-value pair of `b` and `c`. - -`a` is a [map](). - -`b` is a key of the same type as the keys in `a`. - -`c` is a value of the same type of the values in `a`. - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(put by m) 'c' 3) - {[p='a' q=1] [p='c' q=3] [p='b' q=2]} - ~zod/try=> (~(put by m) "zod" 26) - ! type-fail - ! exit - ~zod/try=> (~(put by m) 'a' 2) - {[p='a' q=2] [p='b' q=2]} - ------------------------------------------------------------------------- - -### `+-rep:by` - - +- rep :: replace by product - |* [b=* c=_,*] - |- - ?~ a b - $(a r.a, b $(a l.a, b (c q.n.a b))) - -Accumulate using gate from values in map - -XX interface changing. - ------------------------------------------------------------------------- - -### `+-rib:by` - - +- rib :: transform + product - |* [b=* c=_,*] - |- ^+ [b a] - ?~ a [b ~] - =+ d=(c n.a b) - =. n.a +.d - =+ e=$(a l.a, b -.d) - =+ f=$(a r.a, b -.e) - [-.f [n.a +.e +.f]] - -Replace values with accumulator - -XX interface changing, possibly disappearing - ------------------------------------------------------------------------- - -### `+-run:by` - -Transform values - - +- run :: turns to tuples - |* b=_,* - |- - ?~ a a - a(n (b q.n.a), l $(a l.a), r $(a r.a)) - -Iterates over every value in set `a` using gate `b`. Produces a map. - -`a` is a [map](). - -`b` is a [wet gate](). - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> ^+(m (~(run by m) dec)) - {[p='a' q=0] [p='b' q=1]} - ~zod/try=> `(map ,@tas ,@t)`(~(run by m) (cury scot %ux)) - {[p=%a q='0x1'] [p=%b q='0x2']} - ------------------------------------------------------------------------- - -### `+-tap:by` - -Listify pairs - - +- tap :: listify pairs - ~/ %tap - |= b=(list ,_?>(?=(^ a) n.a)) - ^+ b - ?~ a - b - $(a r.a, b [n.a $(a l.a)]) - -Produces the list of all elements in map `a` that is prepended to list -`b`, which is empty by default. - -`a` is a [map](). - -`b` is a [list](). - - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> `*`m - [[98 2] [[97 1] 0 0] 0] - ~zod/try=> (~(tap by m)) - ~[[p='b' q=2] [p='a' q=1]] - ~zod/try=> `*`(~(tap by m)) - [[98 2] [97 1] 0] - ------------------------------------------------------------------------- - -### `+-uni:by` - -Union - - +- uni :: union, merge - ~/ %uni - |* b=_a - |- ^+ a - ?~ b - a - ?~ a - b - ?: (vor p.n.a p.n.b) - ?: =(p.n.b p.n.a) - [n.b $(a l.a, b l.b) $(a r.a, b r.b)] - ?: (hor p.n.b p.n.a) - $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) - $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) - ?: =(p.n.a p.n.b) - [n.b $(b l.b, a l.a) $(b r.b, a r.a)] - ?: (hor p.n.a p.n.b) - $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) - $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) - -Produces a map of the union between the keys of `a` and `b`. If `b` -shares a key with `a`, the tuple from `a` is preserved. - -`a` is a [map](). - -`b` is a [map](). - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> o - {[p='d' q=4] [p='c' q=3]} - ~zod/try=> (~(uni by m) o) - {[p='d' q=4] [p='a' q=1] [p='c' q=3] [p='b' q=2]} - ~zod/try=> (~(uni by m) ~) - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> n - {[p='a' q=1] [p='c' q=9]} - ~zod/try=> (~(uni by o) n) - {[p='d' q=4] [p='a' q=1] [p='c' q=3]} - ~zod/try=> =n (mo `(list ,[@t *])`[['a' 1] ['c' 9] ~]) - ~zod/try=> n - {[p='a' q=1] [p='c' q=9]} - ~zod/try=> (~(uni by o) n) - {[p='d' q=4] [p='a' q=1] [p='c' q=9]} - ------------------------------------------------------------------------- - -### `+-urn:by` - -Turn (with key) - - +- urn :: turn - |* b=$+([* *] *) - |- - ?~ a ~ - [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)] - -Iterates over every value in map `a` using gate `b`, which accepts both -the key and the value of each element as its sample. - -`a` is a [map](). - -`b` is a [wet gate]() that accepts two nouns (a key and a value) and -produces a noun (the new value). - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(urn by m) |=(a=[p=* q=*] q.a)) - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> (~(urn by m) |=(a=[p=* q=*] 7)) - {[p='a' q=7] [p='b' q=7]} - ~zod/try=> (~(urn by m) |=(a=[p=* q=*] p.a)) - {[p='a' q=97] [p='b' q=98]} - ------------------------------------------------------------------------- - -### `+-wyt:by` - -Depth - - +- wyt :: depth of map - |- ^- @ - ?~(a 0 +((add $(a l.a) $(a r.a)))) - -Produce the depth of the tree map `a`. - -`a` is a [map](). - - ~zod/try=> m - {[p='a' q=1] [p='b' q=2]} - ~zod/try=> o - {[p='d' q=4] [p='c' q=3]} - ~zod/try=> ~(wyt by m) - 2 - ~zod/try=> ~(wyt by o) - 2 - ~zod/try=> ~(wyt by (~(uni by m) o)) - 4 - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2dc.md b/web/docs/dev/hoon/library/2dc.md deleted file mode 100644 index 5f3935d38..000000000 --- a/web/docs/dev/hoon/library/2dc.md +++ /dev/null @@ -1,221 +0,0 @@ -section 2dC, queues -=================== - -### `++to` - -Queue engine - - ++ to :: queue engine - |/ a=(qeu) - -Container arm for queue operation arms. The contained arms inherit its -[sample]() `++qeu` `a`. - -`a` is a queue, [++qeu](). - -### `+-bal:to` - -Balance - - +- bal - |- ^+ a - ?~ a ~ - ?. |(?=(~ l.a) (vor n.a n.l.a)) - $(a [n.l.a l.l.a $(a [n.a r.l.a r.a])]) - ?. |(?=(~ r.a) (vor n.a n.r.a)) - $(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a]) - a - :: - -Vertically rebalances queue `a`. - -`a` is a [queue](). - - ~zod/try=> `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~] - {"a" "b" "c" "d" "e" "f" "g"} - ~zod/try=> `*`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~] - [[97 0] 0 [98 0] 0 [99 0] 0 [100 0] 0 [101 0] 0 [102 0] 0 [103 0] 0 0] - ~zod/try=> ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) - {"a" "b" "c" "d" "e" "f" "g"} - ~zod/try=> `*`~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) - [[100 0] [[99 0] [[98 0] [[97 0] 0 0] 0] 0] [101 0] 0 [102 0] 0 [103 0] 0 0] - ------------------------------------------------------------------------- - -### `+-dep:to` - -Maximum Depth - - +- dep :: max depth of queue - |- ^- @ - ?~ a 0 - +((max $(a l.a) $(a r.a))) - :: - -Produces the maximum depth of leaves (r.a and l.a) in queue `a`. - -`a` is a [queue](). - - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 7 ~]) - ~zod/try=> ~(dep to a) - 4 - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 ~]) - ~zod/try=> ~(dep to a) - 3 - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 ~]) - ~zod/try=> ~(dep to a) - 2 - ~zod/try=> ~(dep to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) - 7 - ~zod/try=> ~(dep to ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~])) - 4 - ------------------------------------------------------------------------- - -### `+-gas` - -Push list - - +- gas :: insert list to queue - |= b=(list ,_?>(?=(^ a) n.a)) - |- ^+ a - ?~(b a $(b t.b, a (put(+< a) i.b))) - :: - -Push all elements of list `b` into the queue. - -`a` is a [queue](). - -`b` is a list. - - ~zod/try=> (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 ~]) - {3 2 1} - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 ~]) - ~zod/try=> =b `(list ,@)`[4 5 6 ~] - ~zod/try=> (~(gas to a) b) - {6 5 4 3 2 1} - ------------------------------------------------------------------------- - -### `+-get:to` - -Pop - - +- get :: head-tail pair - |- ^+ [p=?>(?=(^ a) n.a) q=a] - ?~ a - !! - ?~ r.a - [n.a l.a] - =+ b=$(a r.a) - :- p.b - ?: |(?=(~ q.b) (vor n.a n.q.b)) - [n.a l.a q.b] - [n.q.b [n.a l.a l.q.b] r.q.b] - :: - -Produces the head and tail queue of `a`. - -`a` is a [queue](). - - ~zod/try=> =s (~(gas to *(qeu ,@)) `(list ,@)`~[1 2 3]) - ~zod/try=> ~(get to s) - [p=1 q={3 2}] - ~zod/try=> ~(get to ~) - ! exit - ------------------------------------------------------------------------- - -### `+-nap:to` - -Remove last in - - +- nap :: removes head - ?> ?=(^ a) - ?: =(~ l.a) r.a - =+ b=get(+< l.a) - bal(+< ^+(a [p.b q.b r.a])) - :: - -Removes the head of queue `a`, producing the resulting queue. - -`a` is a [queue](). - - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 ~]) - ~zod/try=> -.a - n=6 - ~zod/try=> =b ~(nap to a) - ~zod/try=> -.b - n=2 - ~zod/try=> b - {5 4 3 2 1} - ~zod/try=> a - {6 5 4 3 2 1} - ------------------------------------------------------------------------- - -### `+-put:to` - -Insert - - +- put :: insert new tail - |* b=* - |- ^+ a - ?~ a - [b ~ ~] - bal(+< a(l $(a l.a))) - :: - -Accept any noun `b` and adds to queue `a` as the head, producing the -resulting queue. - -`a` is a [queue](). - -`b` is any noun. - - ~zod/try=> (~(gas to `(qeu ,@)`~) `(list ,@)`[3 1 2 4 5 6 ~]) - ~zod/try=> (~(put to a) 7) - {7 6 5 4 2 1 3} - ------------------------------------------------------------------------- - -### `+-tap:to` - -Queue to list - - +- tap :: queue to list - |= b=(list ,_?>(?=(^ a) n.a)) - ^+ b - ?~ a - b - $(a r.a, b [n.a $(a l.a)]) - :: - -Produces queue `a` as a list from front to back. - -`a` is a [queue](). - - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[3 1 2 4 5 6 ~]) - ~zod/try=> `*`a - [6 0 2 [4 [5 0 0] 0] 1 0 3 0 0] - ~zod/try=> (~(tap to a) `(list ,@)`[99 100 101 ~]) - ~[3 1 2 4 5 6 99 100 101] - ------------------------------------------------------------------------- - -### `+-top:to` - - +- top :: produces head - |- ^- (unit ,_?>(?=(^ a) n.a)) - ?~ a ~ - ?~(r.a [~ n.a] $(a r.a)) - -Produces the head of queue `a` as a unit (an empty queue has no head). - -`a` is a [queue](). - - ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 ~]) - ~zod/try=> ~(top to a) - [~ 1] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2dd.md b/web/docs/dev/hoon/library/2dd.md deleted file mode 100644 index e4087edba..000000000 --- a/web/docs/dev/hoon/library/2dd.md +++ /dev/null @@ -1,69 +0,0 @@ -section 2dD, casual containers -============================== - -### `++mo` - -Map from list - - ++ mo :: map from list - |* a=(list) - => .(a `_(homo a)`a) - => .(a `(list ,[p=_-<.a q=_->.a])`a) - =+ b=*(map ,_?>(?=(^ a) p.i.a) ,_?>(?=(^ a) q.i.a)) - (~(gas by b) a) - :: - -Produces a map of key-value pairs from the left-right cell pairs of list -`a`. - -`a` is a [list](). - - ~zod/try=> (mo `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) - {[p=`a` q=1] [p=`b` q=2]} - ------------------------------------------------------------------------- - -### `++sa` - -Set from list - - ++ sa :: set from list - |* a=(list) - => .(a `_(homo a)`a) - =+ b=*(set ,_?>(?=(^ a) i.a)) - (~(gas in b) a) - :: - -Produces a set of the elements in list `a`. - -`a` is a [list](). - - ~zod/try=> (sa `(list ,@)`[1 2 3 4 5 ~]) - {5 4 1 3 2} - ~zod/try=> (sa `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) - {[`a` 1] [`b` 2]} - ------------------------------------------------------------------------- - -### `++qu` - -Queue from list - - ++ qu :: queue from list - |* a=(list) - => .(a `_(homo a)`a) - =+ b=*(qeu ,_?>(?=(^ a) i.a)) - (~(gas to b) a) - -Produces a queue from list `a`. - -`a` is a [list](). - - ~zod/try=> (qu `(list ,@ud)`~[1 2 3 5]) - {5 3 2 1} - ~zod/try=> (qu "sada") - {'a' 'd' 'a' 's'} - ~zod/try=> ~(top to (qu "sada")) - [~ 's'] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ea.md b/web/docs/dev/hoon/library/2ea.md deleted file mode 100644 index b341c82d0..000000000 --- a/web/docs/dev/hoon/library/2ea.md +++ /dev/null @@ -1,162 +0,0 @@ -section 2eA, packing -==================== - -### `++cue` - -Unpack atom to noun - - ++ cue :: unpack atom to noun - ~/ %cue - |= a=@ - ^- * - =+ b=0 - =+ m=`(map ,@ ,*)`~ - =< q - |- ^- [p=@ q=* r=_m] - ?: =(0 (cut 0 [b 1] a)) - =+ c=(rub +(b) a) - [+(p.c) q.c (~(put by m) b q.c)] - =+ c=(add 2 b) - ?: =(0 (cut 0 [+(b) 1] a)) - =+ u=$(b c) - =+ v=$(b (add p.u c), m r.u) - =+ w=[q.u q.v] - [(add 2 (add p.u p.v)) w (~(put by r.v) b w)] - =+ d=(rub c a) - [(add 2 p.d) (need (~(get by m) q.d)) m] - :: - -Produces a noun unpacked from atom `a`. The inverse of jam. - -`a` is an [atom](). - - ~zod/try=> (cue 12) - 1 - ~zod/try=> (cue 817) - [1 1] - ~zod/try=> (cue 4.657) - [1 2] - ~zod/try=> (cue 39.689) - [0 19] - ------------------------------------------------------------------------- - -### `++jam` - - ++ jam :: pack - ~/ %jam - |= a=* - ^- @ - =+ b=0 - =+ m=`(map ,* ,@)`~ - =< q - |- ^- [p=@ q=@ r=_m] - =+ c=(~(get by m) a) - ?~ c - => .(m (~(put by m) a b)) - ?: ?=(@ a) - =+ d=(mat a) - [(add 1 p.d) (lsh 0 1 q.d) m] - => .(b (add 2 b)) - =+ d=$(a -.a) - =+ e=$(a +.a, b (add b p.d), m r.d) - [(add 2 (add p.d p.e)) (mix 1 (lsh 0 2 (cat 0 q.d q.e))) r.e] - ?: ?&(?=(@ a) (lte (met 0 a) (met 0 u.c))) - =+ d=(mat a) - [(add 1 p.d) (lsh 0 1 q.d) m] - =+ d=(mat u.c) - [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m] - :: - -Produces an atom unpacked from noun `a`. The inverse of cue. - -`a` is a [noun](). - - ~zod/try=> (jam 1) - 12 - ~zod/try=> (jam [1 1]) - 817 - ~zod/try=> (jam [1 2]) - 4.657 - ~zod/try=> (jam [~ u=19]) - 39.689 - ------------------------------------------------------------------------- - -### `++mat` - -Length-encode - - ++ mat :: length-encode - ~/ %mat - |= a=@ - ^- [p=@ q=@] - ?: =(0 a) - [1 1] - =+ b=(met 0 a) - =+ c=(met 0 b) - :- (add (add c c) b) - (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a))) - -Produces a cell whose tail `q` is atom `a` with a bit representation of -its length prepended to it (as the least significant bits). The head `p` -is the length of `q` in bits. - -`a` is an atom. - - ~zod/try=> (mat 0xaaa) - [p=20 q=699.024] - ~zod/try=> (met 0 q:(mat 0xaaa)) - 20 - ~zod/try=> `@ub`q:(mat 0xaaa) - 0b1010.1010.1010.1001.0000 - ~zod/try=> =a =-(~&(- -) `@ub`0xaaa) - 0b1010.1010.1010 - ~zod/try=> =b =-(~&(- -) `@ub`(xeb a)) - 0b1100 - ~zod/try=> =b =-(~&(- -) `@ub`(met 0 a)) - 0b1100 - ~zod/try=> =c =-(~&(- -) (xeb b)) - 4 - ~zod/try=> [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)] - [0b1010.1010.1010 0b100 0b1.0000] - ------------------------------------------------------------------------- - -### `++rub` - -Length-decode - - ++ rub :: length-decode - ~/ %rub - |= [a=@ b=@] - ^- [p=@ q=@] - =+ ^= c - =+ [c=0 m=(met 0 b)] - |- ?< (gth c m) - ?. =(0 (cut 0 [(add a c) 1] b)) - c - $(c +(c)) - ?: =(0 c) - [1 0] - =+ d=(add a +(c)) - =+ e=(add (bex (dec c)) (cut 0 [d (dec c)] b)) - [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)] - -The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b` -and produces the cell whose tail `q` is the decoded atom at index `a` -and whose head is the length of the encoded atom `q`, by which the -offset `a` is advanced. Only used internally as a helper cue. - -`a` is an atom. - -`b` is a bitstring as an atom. - - ~zod/try=> `@ub`(jam 0xaaa) - 0b1.0101.0101.0101.0010.0000 - ~zod/try=> (rub 1 0b1.0101.0101.0101.0010.0000) - [p=20 q=2.730] - ~zod/try=> `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000) - 0xaaa - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2eb.md b/web/docs/dev/hoon/library/2eb.md deleted file mode 100644 index 7dfd5560d..000000000 --- a/web/docs/dev/hoon/library/2eb.md +++ /dev/null @@ -1,63 +0,0 @@ -section 2eB, parsing (tracing) -============================== - -### `++last` - -Farther trace - - ++ last |= [zyc=hair naz=hair] :: farther trace - ^- hair - ?: =(p.zyc p.naz) - ?:((gth q.zyc q.naz) zyc naz) - ?:((gth p.zyc p.naz) zyc naz) - :: - -Compares two line-column pairs, `zyc` and `naz`, and produces whichever -[hair]() is farther along. - -`zyc` is a [hair](). - -`naz` is a [hair](). - - ~zod/try=> (last [1 1] [1 2]) - [p=1 q=2] - ~zod/try=> (last [2 1] [1 2]) - [p=2 q=1] - ~zod/try=> (last [0 0] [99 0]) - [p=99 q=0] - ~zod/try=> (last [7 7] [7 7]) - [p=7 q=7] - ------------------------------------------------------------------------- - -### `++lust` - -Detect newline - - ++ lust |= [weq=char naz=hair] :: detect newline - ^- hair - ?:(=(10 weq) [+(p.naz) 1] [p.naz +(q.naz)]) - -Advances the hair `naz` by a row if the char `weq` is a newline, or by a -column if `weq` is any other character. - -`weq` is a [char](). - -`naz` is a [hair](). - - ~zod/try=> (lust `a` [1 1]) - [p=1 q=2] - ~zod/try=> (lust `@t`10 [1 1]) - [p=2 q=1] - ~zod/try=> (lust '9' [10 10]) - [p=10 q=11] - /~zod/try=> (roll "maze" [.(+<+ [1 1])]:lust) - [1 5] - /~zod/try=> %- roll :_ [.(+<+ [1 1])]:lust - """ - Sam - lokes - """ - [2 6] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ec.md b/web/docs/dev/hoon/library/2ec.md deleted file mode 100644 index 33b30c493..000000000 --- a/web/docs/dev/hoon/library/2ec.md +++ /dev/null @@ -1,652 +0,0 @@ -section 2eC, parsing (custom rules) -=================================== - -### `++cold` - -Replace with constant - - ++ cold :: replace w/ constant - ~/ %cold - |* [cus=* sef=_rule] - ~/ %fun - |= tub=nail - =+ vex=(sef tub) - ?~ q.vex - vex - [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]] - :: - -Parser modifier. Accepts a rule `sef` and produces a parser that -produces a constant `cus`, if `sef` is successful. - -`cus` is a constant [noun](). - -`sef` is a [`++rule`](). - - ~zod/try=> ((cold %foo (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((cold %foo (just 'a')) [[1 1] "bc"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++cook` - -Apply gate - - ++ cook :: apply gate - ~/ %cook - |* [poq=_,* sef=_rule] - ~/ %fun - |= tub=nail - =+ vex=(sef tub) - ?~ q.vex - vex - [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]] - :: - -Parser modifier. Produces a parser that takes a (successful) result of a -rule `sef` and slams it through `poq`. - -`poq` is a [gate](). - -`sef` is a [`++rule`](). - - ~zod/try=> ((cook ,@ud (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((cook ,@tas (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=%a q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((cook |=(a=@ +(a)) (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=98 q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((cook |=(a=@ `@t`+(a)) (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p='b' q=[p=[p=1 q=2] q="bc"]]]] - ------------------------------------------------------------------------- - -### `++easy` - -Always parse - - ++ easy :: always parse - ~/ %easy - |* huf=* - ~/ %fun - |= tub=nail - ^- (like ,_huf) - [p=p.tub q=[~ u=[p=huf q=tub]]] - :: - -Parser generator. Produces a parser that succeeds with given noun `huf` -without consuming any text. - - ~zod/try=> ((easy %foo) [[1 1] "abc"]) - [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="abc"]]]] - ~zod/try=> ((easy %foo) [[1 1] "bc"]) - [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="bc"]]]] - ~zod/try=> ((easy 'a') [[1 1] "bc"]) - [p=[p=1 q=1] q=[~ [p='a' q=[p=[p=1 q=1] q="bc"]]]] - ------------------------------------------------------------------------- - -### `++fail` - -Never parse - - ++ fail |=(tub=nail [p=p.tub q=~]) :: never parse - -Produces an [edge]() at the same text position ([hair]()) with a failing -result (`q=~`). - -`tub` is a [`++nail`](). - - ~zod/try=> (fail [[1 1] "abc"]) - [p=[p=1 q=1] q=~] - ~zod/try=> (fail [[p=1.337 q=70] "Parse me, please?"]) - [p=[p=1.337 q=70] q=~] - ------------------------------------------------------------------------- - -### `++full` - -Parse to end - - ++ full :: parse to end - |* sef=_rule - |= tub=nail - =+ vex=(sef tub) - ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~])) - :: - -Accepts a [`++nail`](), `tub`, and produces a parser that succeeds only -when a `tub` success consumes the remainder of the [tape](). - -`sef` is a [`++rule`](). - - ~zod/try=> ((full (just 'a')) [[1 1] "ab"]) - [p=[p=1 q=2] q=~] - ~zod/try=> ((full (jest 'ab')) [[1 1] "ab"]) - [p=[p=1 q=3] q=[~ u=[p='ab' q=[p=[p=1 q=3] q=""]]]] - ~zod/try=> ((full ;~(plug (just 'a') (just 'b'))) [[1 1] "ab"]) - [p=[p=1 q=3] q=[~ u=[p=[~~a ~~b] q=[p=[p=1 q=3] q=""]]]] - ------------------------------------------------------------------------- - -### `++funk` - -Add to tape - - ++ funk :: add to tape first - |* [pre=tape sef=_rule] - |= tub=nail - (sef p.tub (weld pre q.tub)) - :: - -Parser modifier: prepend text to tape before applying parser. - -`pre` is a [`++tape`]() - -`sef` is a [`++rule`]() - - ~zod/try=> ((funk "abc prefix-" (jest 'abc')) [[1 1] "to be parsed"]) - [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=" prefix-to be parsed"]]]] - ~zod/try=> ((funk "parse" (just 'a')) [[1 4] " me"]) - [p=[p=1 q=4] q=~] - ------------------------------------------------------------------------- - -### `++here` - -Place-based apply - - ++ here :: place-based apply - ~/ %here - |* [hez=_|=([a=pint b=*] [a b]) sef=_rule] - ~/ %fun - |= tub=nail - =+ vex=(sef tub) - ?~ q.vex - vex - [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]] - :: - -Parser modifier. Similar to [`++cook`](), produces a parser that takes a -(successful) result of `sef` and slams it through `hez`. `hez` accepts a -[`++pint`]() `a` and a noun `b`, which is what the parser parsed. - -`hez` is a [gate](). - -`sef` is a [`++rule`]() - - ~zod/try=> (scan "abc" (star alf)) - "abc" - ~zod/try=> (scan "abc" (here |*(^ +<) (star alf))) - [[[p=1 q=1] p=1 q=4] "abc"] - ~zod/try=> (scan "abc" (star (here |*(^ +<) alf))) - ~[[[[p=1 q=1] p=1 q=2] ~~a] [[[p=1 q=2] p=1 q=3] ~~b] [[[p=1 q=3] p=1 q=4] ~~c]] - ------------------------------------------------------------------------- - -### `++inde` - -Indentation block - - ++ inde |* sef=_rule :: indentation block - |= nail ^+ (sef) - =+ [har tap]=[p q]:+< - =+ lev=(fil 3 (dec q.har) ' ') - =+ eol=(just `@t`10) - =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap) - ;~(simu ;~(plug eol eol) eol) - ?~ q.roq roq - =+ vex=(sef har(q 1) p.u.q.roq) - =+ fur=p.vex(q (add (dec q.har) q.p.vex)) - ?~ q.vex vex(p fur) - =- vex(p fur, u.q -) - :+ &3.vex - &4.vex(q.p (add (dec q.har) q.p.&4.vex)) - =+ res=|4.vex - |- ?~ res |4.roq - ?. =(10 -.res) [-.res $(res +.res)] - (welp [`@t`10 (trip lev)] $(res +.res)) - :: - -Apply rule to indented block starting at current column number, omitting -the leading whitespace. - -`sef` is a [`++rule`]() - - ~zod/try=> (scan "abc" (inde (star ;~(pose prn (just `@`10))))) - "abc" - ~zod/try=> (scan "abc" (star ;~(pose prn (just `@`10)))) - "abc" - ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10))))) - "abc - de" - ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (inde (star ;~(pose prn (just `@`10)))))) - ! {1 6} - ! exit - ~zod/try=> (scan " abc\0a de" ;~(pfix ace ace (inde (star ;~(pose prn (just `@`10)))))) - "abc - de" - ------------------------------------------------------------------------- - -### `++jest` - -Match a cord - - ++ jest :: match a cord - |= daf=@t - |= tub=nail - =+ fad=daf - |- ^- (like ,@t) - ?: =(0 daf) - [p=p.tub q=[~ u=[p=fad q=tub]]] - ?: |(?=(~ q.tub) !=((end 3 1 daf) i.q.tub)) - (fail tub) - $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf)) - :: - -Match and consume a cord. - -`daf` is a `@t` - - ~zod/try=> ((jest 'abc') [[1 1] "abc"]) - [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=""]]]] - ~zod/try=> (scan "abc" (jest 'abc')) - 'abc' - ~zod/try=> (scan "abc" (jest 'acb')) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> ((jest 'john doe') [[1 1] "john smith"]) - [p=[p=1 q=6] q=~] - ~zod/try=> ((jest 'john doe') [[1 1] "john doe"]) - [p=[p=1 q=9] q=[~ [p='john doe' q=[p=[p=1 q=9] q=""]]]] - ------------------------------------------------------------------------- - -### `++just` - -Match a char - - ++ just :: XX redundant, jest - ~/ %just :: match a char - |= daf=char - ~/ %fun - |= tub=nail - ^- (like char) - ?~ q.tub - (fail tub) - ?. =(daf i.q.tub) - (fail tub) - (next tub) - :: - -Match and consume a single character. - -`daf` is a [`++char`]() - - ~zod/try=> ((just 'a') [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> (scan "abc" (just 'a')) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> (scan "a" (just 'a')) - ~~a - ~zod/try=> (scan "%" (just '%')) - ~~~25. - ------------------------------------------------------------------------- - -### `++knee` - -Recursive parsers - - ++ knee :: callbacks - |* [gar=* sef=_|.(rule)] - |= tub=nail - ^- (like ,_gar) - ((sef) tub) - :: - -Used for recursive parsers, which would otherwise be infinite when -compiled. - -`gar` is a noun. - -`sef` is a [gate]() that accepts a [`++rule`]() - - ~zod/try=> |-(;~(plug prn ;~(pose $ (easy ~)))) - ! rest-loop - ! exit - ~zod/try=> |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~)))) - < 1.obo - [ c=c=tub=[p=[p=@ud q=@ud] q=""] - b - < 1.bes - [ c=tub=[p=[p=@ud q=@ud] q=""] - b=<1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]> - a=<1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]> - v=<414.fvk 101.jzo 1.ypj %164> - ] - > - a - ... 450 lines omitted ... - ] - > - ~zod/try=> (scan "abcd" |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~))))) - [~~a "bcd"] - ------------------------------------------------------------------------- - -### `++mask` - -Match char - - ++ mask :: match char in set - ~/ %mask - |= bud=(list char) - ~/ %fun - |= tub=nail - ^- (like char) - ?~ q.tub - (fail tub) - ?. (lien bud |=(a=char =(i.q.tub a))) - (fail tub) - (next tub) - :: - -Parser generator. Matches the next character if it is in a list of -characters. - -`bud` is a list of [`++char`]() - - ~zod/try=> (scan "a" (mask "cba")) - ~~a - ~zod/try=> ((mask "abc") [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((mask "abc") [[1 1] "bbc"]) - [p=[p=1 q=2] q=[~ [p=~~b q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((mask "abc") [[1 1] "dbc"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++next` - -Consume char - - ++ next :: consume a char - |= tub=nail - ^- (like char) - ?~ q.tub - (fail tub) - =+ zac=(lust i.q.tub p.tub) - [zac [~ i.q.tub [zac t.q.tub]]] - :: - -Consume any character, producing it as a result. - -`tub` is a [`++nail`]() - - ~zod/try=> (next [[1 1] "ebc"]) - [p=[p=1 q=2] q=[~ [p=~~e q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> (next [[1 1] "john jumps jones"]) - [p=[p=1 q=2] q=[~ [p=~~j q=[p=[p=1 q=2] q="ohn jumps jones"]]]] - ------------------------------------------------------------------------- - -### `++sear` - -Conditional `++cook` - - ++ sear :: conditional cook - |* [pyq=_|=(* *(unit)) sef=_rule] - |= tub=nail - =+ vex=(sef tub) - ?~ q.vex - vex - =+ gey=(pyq p.u.q.vex) - ?~ gey - [p=p.vex q=~] - [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]] - :: - -Conditional [`++cook`](). Slams the result through a gate that produces -a unit; if that unit is empty, fail. - -`tub` is a [`++nail`](/doc/hoon/library/1#++nail) - - ~zod/try=> ((sear |=(a=* ?@(a (some a) ~)) (just `a`)) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((sear |=(* ~) (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=~] - ------------------------------------------------------------------------- - -### `++shim` - -Char in range - - ++ shim :: match char in range - ~/ %shim - |= [les=@ mos=@] - ~/ %fun - |= tub=nail - ^- (like char) - ?~ q.tub - (fail tub) - ?. ?&((gte i.q.tub les) (lte i.q.tub mos)) - (fail tub) - (next tub) - :: - -Match characters within a range. - -`les` and `mos` are atoms, `@`. - - ~zod/try=> ((shim 'a' 'z') [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((shim 'a' 'Z') [[1 1] "abc"]) - [p=[p=1 q=1] q=~] - ~zod/try=> ((shim 'a' 'Z') [[1 1] "Abc"]) - [p=[p=1 q=2] q=[~ [p=~~~41. q=[p=[p=1 q=2] q="bc"]]]] - ------------------------------------------------------------------------- - -### `++stag` - -Add label - - ++ stag :: add a label - ~/ %stag - |* [gob=* sef=_rule] - ~/ %fun - |= tub=nail - =+ vex=(sef tub) - ?~ q.vex - vex - [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]] - :: - -Add a label to an edge parsed by a rule. - -`gob` is a noun. - -`sef` is a rule. - - ~zod/try=> ((stag %foo (just 'a')) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=[%foo ~~a] q=[p=[p=1 q=2] q="bc"]]]] - ~zod/try=> ((stag "xyz" (jest 'abc')) [[1 1] "abc"]) - [p=[p=1 q=4] q=[~ u=[p=["xyz" 'abc'] q=[p=[p=1 q=4] q=""]]]] - ~zod/try=> ((stag 10.000 (shim 0 100)) [[1 1] "abc"]) - [p=[p=1 q=2] q=[~ u=[p=[10.000 ~~a] q=[p=[p=1 q=2] q="bc"]]]] - ------------------------------------------------------------------------- - -### `++stet` - -Add faces - - ++ stet - |* leh=(list ,[?(@ [@ @]) _rule]) - |- - ?~ leh - ~ - [i=[p=-.i.leh q=+.i.leh] t=$(leh t.leh)] - :: - -Add `[p q]` faces to range-parser pairs in a list. - -`leh` is a list of range-parsers. - - ~zod/try=> (stet (limo [[5 (just 'a')] [1 (jest 'abc')] [[1 1] (shim 0 200)] - [[1 10] (cold %foo (just 'a'))]~])) - ~[ - [p=5 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - [p=1 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - [p=[1 10] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - ] - ~zod/try=> [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~] - [ [[1 1] <1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>] - [[2 1] <1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>] - ~ - ] - ~zod/try=> (stet (limo [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~])) - ~[ - [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - [p=[2 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] - ] - ------------------------------------------------------------------------- - -### `++stew` - -Switch by first - - ++ stew :: switch by first char - ~/ %stew - |* leh=(list ,[p=?(@ [@ @]) q=_rule]) :: char/range keys - =+ ^= wor :: range complete lth - |= [ort=?(@ [@ @]) wan=?(@ [@ @])] - ?@ ort - ?@(wan (lth ort wan) (lth ort -.wan)) - ?@(wan (lth +.ort wan) (lth +.ort -.wan)) - =+ ^= hel :: build parser map - =+ hel=`(tree $_(?>(?=(^ leh) i.leh)))`~ - |- ^+ hel - ?~ leh - ~ - =+ yal=$(leh t.leh) - |- ^+ hel - ?~ yal - [i.leh ~ ~] - ?: (wor p.i.leh p.n.yal) - =+ nuc=$(yal l.yal) - ?> ?=(^ nuc) - ?: (vor p.n.yal p.n.nuc) - [n.yal nuc r.yal] - [n.nuc l.nuc [n.yal r.nuc r.yal]] - =+ nuc=$(yal r.yal) - ?> ?=(^ nuc) - ?: (vor p.n.yal p.n.nuc) - [n.yal l.yal nuc] - [n.nuc [n.yal l.yal l.nuc] r.nuc] - ~% %fun ..^$ ~ - |= tub=nail - ?~ q.tub - (fail tub) - |- - ?~ hel - (fail tub) - ?: ?@ p.n.hel - =(p.n.hel i.q.tub) - ?&((gte i.q.tub -.p.n.hel) (lte i.q.tub +.p.n.hel)) - :: (q.n.hel [(lust i.q.tub p.tub) t.q.tub]) - (q.n.hel tub) - ?: (wor i.q.tub p.n.hel) - $(hel l.hel) - $(hel r.hel) - :: - -Parser generator. From an associative list of characters or character -ranges to rules, construct a map, and parse tapes only with rules -associated with a range the tape's first character falls in. - ------------------------------------------------------------------------- - -### `++stir` - -Parse repeatedly - - ++ stir :: parse repeatedly - ~/ %stir - |* [rud=* raq=_|*([a=* b=*] [a b]) fel=_rule] - ~/ %fun - |= tub=nail - ^- (like ,_rud) - =+ vex=(fel tub) - ?~ q.vex - [p.vex [~ rud tub]] - =+ wag=$(tub q.u.q.vex) - ?> ?=(^ q.wag) - [(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]] - :: - -Parse with rule as many times as possible, and fold over results with a -binary gate. - -`rud` is a noun. - -`raq` is a gate that takes two nouns and produces a cell. - -`fel` is a rule. - - ~zod/try=> (scan "abc" (stir *@ add prn)) - 294 - ~zod/try=> (roll "abc" add) - b=294 - ------------------------------------------------------------------------- - -### `++stun` - -Parse several times - - ++ stun :: parse several times - |* [[les=@ mos=@] fel=_rule] - |= tub=nail - ^- (like (list ,_(wonk (fel)))) - ?: =(0 mos) - [p.tub [~ ~ tub]] - =+ vex=(fel tub) - ?~ q.vex - ?: =(0 les) - [p.vex [~ ~ tub]] - vex - =+ ^= wag %= $ - les ?:(=(0 les) 0 (dec les)) - mos ?:(=(0 mos) 0 (dec mos)) - tub q.u.q.vex - == - ?~ q.wag - wag - [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]] - -Parse bounded number of times. - -`[les=@ mos=@]` is a cell of atoms indicating the bounds. - -`fel` is a rule. - - ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbrownfoxran") - [p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]] - ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbro") - [p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]] - ~zod/try=> ((stun [5 10] prn) [1 1] "aqui") - [p=[p=1 q=5] q=~] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ed.md b/web/docs/dev/hoon/library/2ed.md deleted file mode 100644 index 159d64062..000000000 --- a/web/docs/dev/hoon/library/2ed.md +++ /dev/null @@ -1,289 +0,0 @@ -section 2eD -=========== - -### `++bend` - -Conditional composer - - ++ bend :: conditional comp - ~/ %bend - |* raq=_|*([a=* b=*] [~ u=[a b]]) - ~/ %fun - |* [vex=edge sab=_rule] - ?~ q.vex - vex - =+ yit=(sab q.u.q.vex) - =+ yur=(last p.vex p.yit) - ?~ q.yit - [p=yur q=q.vex] - =+ vux=(raq p.u.q.vex p.u.q.yit) - ?~ vux - [p=yur q=q.vex] - [p=yur q=[~ u=[p=u.vux q=q.u.q.yit]]] - :: - -Parsing composer: connects the edge `vex` with the subsequent rule `sab` -as an optional suffix, using the gate `raq` to compose or reject its -result. If there is no suffix, or if the suffix fails to be composed -with the current result, the current result is produced. Used to map a -group of rules to a specified output. - -`raq` is a [gate](). - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qs") - [p=[p=1 q=3] q=[~ u=[p=~~q q=[p=[p=1 q=2] q="s"]]]] - ~zod/try=> (;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qqq") - [p=[p=1 q=3] q=[~ u=[p=~~r q=[p=[p=1 q=3] q="q"]]]] - ~zod/try=> (scan "aa" ;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn)) - ~~b - ~zod/try=> (scan "ba" ;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn)) - ! {1 3} - ! exit - ~zod/try=> `(unit ,@tas)`(scan "" ;~((bend) (easy ~) sym)) - ~ - ~zod/try=> `(unit ,@tas)`(scan "sep" ;~((bend) (easy ~) sym)) - [~ %sep] - ------------------------------------------------------------------------- - -### `++comp` - -Arbitrary compose - - ++ comp - ~/ %comp - |* raq=_|*([a=* b=*] [a b]) :: arbitrary compose - ~/ %fun - |* [vex=edge sab=_rule] - ?~ q.vex - vex - =+ yit=(sab q.u.q.vex) - =+ yur=(last p.vex p.yit) - ?~ q.yit - [p=yur q=q.yit] - [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]] - :: - -Parsing composer: connects the edge `vex` with a following rule `sab`, -combining the contents of `vex` with the result of `sab` using a binary -gate `raq`. Used to fold over the results of several rules. - -`raq` is a [gate]() that accepts a cell of two nouns, `a` and `b`, and -produces a cell of two nouns. - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (scan "123" ;~((comp |=([a=@u b=@u] (add a b))) dit dit dit)) - 6 - ~zod/try=> (scan "12" ;~((comp |=([a=@u b=@u] (add a b))) dit dit dit)) - ! {1 3} - ! exit - ------------------------------------------------------------------------- - -### `++glue` - -Skip delimiter - - ++ glue :: add rule - ~/ %glue - |* bus=_rule - ~/ %fun - |* [vex=edge sab=_rule] - (plug vex ;~(pfix bus sab)) - :: - -Parsing composer: connects an edge `vex` with a following rule `sab` by -parsing the rule `bus` (the delimiting symbol) and throwing out the -result. - -`bus` is a [rule](). - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (scan "200|mal|bon" ;~((glue bar) dem sym sym)) - [q=200 7.102.829 7.237.474] - ~zod/try=> `[@u @tas @tas]`(scan "200|mal|bon" ;~((glue bar) dem sym sym)) - [200 %mal %bon] - ~zod/try=> (scan "200|;|bon" ;~((glue bar) dem sem sym)) - [q=200 ~~~3b. 7.237.474] - ~zod/try=> (scan "200.;.bon" ;~((glue dot) dem sem sym)) - [q=200 ~~~3b. 7.237.474] - ------------------------------------------------------------------------- - -### `++less` - -Parse unless - - ++ less :: no first and second - |* [vex=edge sab=_rule] - ?~ q.vex - =+ roq=(sab) - [p=(last p.vex p.roq) q=q.roq] - vex(q ~) - :: - -Parsing composer: if an edge `vex` reflects a success, fail. Otherwise, -connect `vex` with the following rule. - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (scan "sas-/lo" (star ;~(less lus bar prn))) - "sas-/lo" - ~zod/try=> (scan "sas-/l+o" (star ;~(less lus bar prn))) - ! {1 8} - ! exit - ~zod/try=> (scan "sas|-/lo" (star ;~(less lus bar prn))) - ! {1 5} - ! exit - ------------------------------------------------------------------------- - -### `++pfix` - -Discard first rule - - ++ pfix :: discard first rule - ~/ %pfix - (comp |*([a=* b=*] b)) - :: - -Parsing composer: connects an [edge]() `vex` with two subsequent rules, -ignoring the result of the first and producing the result of the second. - -`vex` is an [edge](). - - ~zod/try=> `@t`(scan "%him" ;~(pfix cen sym)) - 'him' - ~zod/try=> (scan "+++10" ;~(pfix (star lus) dem)) - q=10 - ------------------------------------------------------------------------- - -### `++plug` - -Parse to tuple - - ++ plug :: first then second - ~/ %plug - |* [vex=edge sab=_rule] - ?~ q.vex - vex - =+ yit=(sab q.u.q.vex) - =+ yur=(last p.vex p.yit) - ?~ q.yit - [p=yur q=q.yit] - [p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]] - :: - -Parsing composer: connects `vex` with a following rule `sab`, producing -a cell of both the results. See also: the monad applicator [;\~]() for a -more detailed explanation. - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (scan "1..20" ;~(plug dem dot dot dem)) - [q=1 ~~~. ~~~. q=20] - ~zod/try=> (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so)) - [1.701.539.693 ~~~2f. [% p=[p=~.da q=170.141.184.500.766.106.671.844.917.172.921.958.400]]] - ~zod/try=> ;;(,[@tas @t ~ %da @da] (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so))) - [%moke '/' ~ %da ~2014.1.1] - ------------------------------------------------------------------------- - -### `++pose` - -Parse options - - ++ pose :: first or second - ~/ %pose - |* [vex=edge sab=_rule] - ?~ q.vex - =+ roq=(sab) - [p=(last p.vex p.roq) q=q.roq] - vex - -Parsing composer: if `vex` reflects a failure, connect it with the -following rule `sab`. See also: the monad applicator [;\~]() - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> `@t`(scan "+" ;~(pose lus tar cen)) - '+' - ~zod/try=> `@t`(scan "*" ;~(pose lus tar cen)) - '*' - ~zod/try=> `@t`(scan "%" ;~(pose lus tar cen)) - '%' - ~zod/try=> `@t`(scan "-" ;~(pose lus tar cen)) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++simu` - -First and second - - ++ simu :: first and second - |* [vex=edge sab=_rule] - ?~ q.vex - vex - =+ roq=(sab) - roq - :: - -Parsing composer: if an edge `vex` reflects a failure, fail. Otherwise, -connect `vex` with the following rule. - -`sab` is a [rule](). - -`vex` is an [edge](). - - ~zod/try=> (scan "~zod" scat:vast) - [%dtzy p=%p q=0] - ~zod/try=> (scan "%zod" scat:vast) - [%dtzz p=%tas q=6.582.138] - ~zod/try=> (scan "%zod" ;~(simu cen scat:vast)) - [%dtzz p=%tas q=6.582.138] - ~zod/try=> (scan "~zod" ;~(simu cen scat:vast)) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sfix` - -Discard second rule - - ++ sfix :: discard second rule - ~/ %sfix - (comp |*([a=* b=*] a)) - -Parsing composer: connects `vex` with two subsequent rules returning the -result of the first and discarding the result of the second. - -`a` is the result of parsing the first [rule](). - -`b` is the result of of parsing the second [rule](). - - ~zod/try=> `@t`(scan "him%" ;~(sfix sym cen)) - 'him' - ~zod/try=> (scan "10+++" ;~(sfix dem (star lus))) - q=10 - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ee.md b/web/docs/dev/hoon/library/2ee.md deleted file mode 100644 index ba748aa48..000000000 --- a/web/docs/dev/hoon/library/2ee.md +++ /dev/null @@ -1,195 +0,0 @@ -section 2eE, parsing (composers) -================================ - -### `++bass` - - ++ bass - |* [wuc=@ tyd=_rule] - %+ cook - |= waq=(list ,@) - %+ roll - waq - =|([p=@ q=@] |.((add p (mul wuc q)))) - tyd - :: - -Parser modifier: -[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) ordered list -as atom of a base. - -`wuc` is an [atom](). - -`tyd` is a [rule](). - - ~zod/try=> (scan "123" (bass 10 (star dit))) - q=123 - ~zod/try=> (scan "123" (bass 8 (star dit))) - q=83 - ~zod/try=> `@ub`(scan "123" (bass 8 (star dit))) - 0b101.0011 - ------------------------------------------------------------------------- - -### `++boss` - - ++ boss - |* [wuc=@ tyd=_rule] - %+ cook - |= waq=(list ,@) - %+ reel - waq - =|([p=@ q=@] |.((add p (mul wuc q)))) - tyd - :: - -Parser modifier: -[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) ordered list -as atom of a base. - -`wuc` is an [atom](). - -`tyd` is a [rule](). - - ~zod/try=> (scan "123" (boss 10 (star dit))) - q=321 - ~zod/try=> `@t`(scan "bam" (boss 256 (star alp))) - 'bam' - ~zod/try=> `@ux`(scan "bam" (boss 256 (star alp))) - 0x6d.6162 - ------------------------------------------------------------------------- - -### `++ifix` - - ++ ifix - |* [fel=[p=_rule q=_rule] hof=_rule] - ;~(pfix p.fel ;~(sfix hof q.fel)) - :: - -Parser modifier: surround with pair of rules, output of which is -discarded. - -`fel` is a pair of [rule]()s. - -`hof` is a [rule](). - - ~zod/try=> (scan "-40-" (ifix [hep hep] dem)) - q=40 - ~zod/try=> (scan "4my4" (ifix [dit dit] (star alf))) - "my" - ------------------------------------------------------------------------- - -### `++more` - - ++ more - |* [bus=_rule fel=_rule] - ;~(pose (most bus fel) (easy ~)) - :: - -Parser modifier: using a delimiter rule, parse a list of matches. - -`bus` is a [rule](). - -`fel` is a [rule](). - - ~zod/try=> (scan "" (more ace dem)) - ~ - ~zod/try=> (scan "40 20" (more ace dem)) - [q=40 ~[q=20]] - ~zod/try=> (scan "40 20 60 1 5" (more ace dem)) - [q=40 ~[q=20 q=60 q=1 q=5]] - ------------------------------------------------------------------------- - -### `++most` - - ++ most - |* [bus=_rule fel=_rule] - ;~(plug fel (star ;~(pfix bus fel))) - :: - -Parser modifier: using a delimiter rule, parse a list of at least one -match. - -`bus` is a [rule](). - -`fel` is a [rule](). - - ~zod/try=> (scan "40 20" (most ace dem)) - [q=40 ~[q=20]] - ~zod/try=> (scan "40 20 60 1 5" (most ace dem)) - [q=40 ~[q=20 q=60 q=1 q=5]] - ~zod/try=> (scan "" (most ace dem)) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++plus` - - ++ plus |*(fel=_rule ;~(plug fel (star fel))) - -Parser modifier: parse list of at least one match - -`fel` is a [rule](). - - ~zod/try=> (scan ">>>>" (cook lent (plus gar))) - 4 - ~zod/try=> (scan "- - " (plus ;~(pose ace hep))) - [~~- " - "] - ~zod/try=> `tape`(scan "- - " (plus ;~(pose ace hep))) - "- - " - ~zod/try=> `(pole ,@t)`(scan "- - " (plus ;~(pose ace hep))) - ['-' [' ' [' ' ['-' [' ' ~]]]]] - ------------------------------------------------------------------------- - -### `++slug` - - ++ slug - |* raq=_|*([a=* b=*] [a b]) - |* [bus=_rule fel=_rule] - ;~((comp raq) fel (stir rud raq ;~(pfix bus fel))) - :: - -Parser modifier: By composing with a gate, parse a delimited list of -matches. - -`bus` is a [rule](). - -`fel` is a [rule](). - - ~zod/try=> (scan "20+5+110" ((slug add) lus dem)) - 135 - ~zod/try=> `@t`(scan "a b c" ((slug |=(a=[@ @t] (cat 3 a))) ace alp)) - 'abc' - ------------------------------------------------------------------------- - -### `++star` - - ++ star :: 0 or more times - |* fel=_rule - (stir `(list ,_(wonk *fel))`~ |*([a=* b=*] [a b]) fel) - -Parser modifier: parse list of matches. - -`fel` is a [rule](). - - ~zod/try=> (scan "aaaaa" (just 'a')) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> (scan "aaaaa" (star (just 'a'))) - "aaaaa" - ~zod/try=> (scan "abcdef" (star (just 'a'))) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> (scan "abcabc" (star (jest 'abc'))) - <|abc abc|> - ~zod/try=> (scan "john smith" (star (shim 0 200))) - "john smith" - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ef.md b/web/docs/dev/hoon/library/2ef.md deleted file mode 100644 index f7c7d070f..000000000 --- a/web/docs/dev/hoon/library/2ef.md +++ /dev/null @@ -1,648 +0,0 @@ -section 2eF, parsing (ascii) -============================ - -### `++ace` - -Parse space - - ++ ace (just ' ') - -Parses ASCII character 32, space. - - ~zod/try=> (scan " " ace) - ~~. - ~zod/try=> `cord`(scan " " ace) - ' ' - ~zod/try=> (ace [[1 1] " "]) - [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (ace [[1 1] " abc "]) - [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="abc "]]]] - ------------------------------------------------------------------------- - -### `++bar` - -Parse vertical bar - - ++ bar (just '|') - -Parses ASCII character 124, the vertical bar. - - ~zod/try=> (scan "|" bar) - ~~~7c. - ~zod/try=> `cord`(scan "|" bar) - '|' - ~zod/try=> (bar [[1 1] "|"]) - [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (bar [[1 1] "|="]) - [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q="="]]]] - ------------------------------------------------------------------------- - -### `++bas` - -Parse backslash - - ++ bas (just '\\') - -Parses ASCII character 92, the backslash. Note the extra `\` in the slam -of `bas` with [`++just`](/doc/hoon/library/2ec#++just) is to escape the escape character, `\`. - - ~zod/try=> (scan "\\" bas) - ~~~5c. - ~zod/try=> `cord`(scan "\\" bas) - '\' - ~zod/try=> (bas [[1 1] "\"]) - ~ - ~zod/try=> (bas [[1 1] "\\"]) - [p=[p=1 q=2] q=[~ [p=~~~5c. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (bas [[1 1] "\""]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++buc` - -Parse dollar sign - - ++ buc (just '$') - -Parses ASCII character 36, the dollar sign. - - ~zod/try=> (scan "$" buc) - ~~~24. - ~zod/try=> `cord`(scan "$" buc) - '$' - ~zod/try=> (buc [[1 1] "$"]) - [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (buc [[1 1] "$%"]) - [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q="%"]]]] - ------------------------------------------------------------------------- - -### `++cab` - -Parse underscore - - ++ cab (just '_') - -Parses ASCII character 95, the underscore. - - ~zod/try=> (scan "_" cab) - ~~~5f. - ~zod/try=> `cord`(scan "_" cab) - '_' - ~zod/try=> (cab [[1 1] "_"]) - [p=[p=1 q=2] q=[~ [p=~~~5f. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (cab [[1 1] "|_"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++cen` - -Parses percent sign - - ++ cen (just '%') - -Parses ASCII character 37, the percent sign. - - ~zod/try=> (scan "%" cen) - ~~~25. - ~zod/try=> `cord`(scan "%" cen) - '%' - ~zod/try=> (cen [[1 1] "%"]) - [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (cen [[1 1] "%^"]) - [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q="^"]]]] - ------------------------------------------------------------------------- - -### `++col` - -Parse colon - - ++ col (just ':') - -Parses ASCII character 58, the colon - - ~zod/try=> (scan ":" col) - ~~~3a. - ~zod/try=> `cord`(scan ":" col) - ':' - ~zod/try=> (col [[1 1] ":"]) - [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (col [[1 1] ":-"]) - [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q="-"]]]] - ------------------------------------------------------------------------- - -### `++com` - -Parse comma - - ++ com (just ',') - -Parses ASCII character 44, the comma. - - ~zod/try=> (scan "," com) - ~~~2c. - ~zod/try=> `cord`(scan "," com) - ',' - ~zod/try=> (com [[1 1] ","]) - [p=[p=1 q=2] q=[~ [p=~~~2c. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (com [[1 1] "not com"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++doq` - -Parse double quote - - ++ doq (just '"') - -Parses ASCII character 34, the double quote. - - ~tadbyl-hilbel/try=> (scan "\"" doq) - ~~~22. - ~tadbyl-hilbel/try=> `cord`(scan "\"" doq) - '"' - ~tadbyl-hilbel/try=> (doq [[1 1] "\""]) - [p=[p=1 q=2] q=[~ [p=~~~22. q=[p=[p=1 q=2] q=""]]]] - ~tadbyl-hilbel/try=> (doq [[1 1] "not successfully parsed"]) - [p=[p=1 q=1] q=~] - ~tadbyl-hilbel/try=> (scan "see?" doq) - ! {1 1} - ! 'syntax-error' - ! exit - ------------------------------------------------------------------------- - -### `++dot` - -Parse period - - ++ dot (just '.') - -Parses ASCII character 46, the period. - - ~zod/try=> (scan "." dot) - ~~~. - ~zod/try=> `cord`(scan "." dot) - '.' - ~zod/try=> (dot [[1 1] "."]) - [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (dot [[1 1] ".^"]) - [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q="^"]]]] - ------------------------------------------------------------------------- - -### `++fas` - -Parse forward slash - - ++ fas (just '/') - -Parses ASCII character 47, the forward slash. - - ~zod/try=> (scan "/" fas) - ~~~2f. - ~zod/try=> `cord`(scan "/" fas) - '/' - ~zod/try=> (fas [[1 1] "/"]) - [p=[p=1 q=2] q=[~ [p=~~~2f. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (fas [[1 1] "|/"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++gal` - -Parse less-than sign - - ++ gal (just '<') - -Parses ASCII character 60, the less-than sign. - - ~zod/try=> (scan "<" gal) - ~~~3c. - ~zod/try=> `cord`(scan "<" gal) - '<' - ~zod/try=> (gal [[1 1] "<"]) - [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (gal [[1 1] "<+"]) - [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q="+"]]]] - ~zod/try=> (gal [[1 1] "+<"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++gar` - -Parse greater-than sign - - ++ gar (just '>') - -Parses ASCII character 62, the greater-than sign. - - ~zod/try=> (scan ">" gar) - ~~~3e. - ~zod/try=> `cord`(scan ">" gar) - '>' - ~zod/try=> (gar [[1 1] ">"]) - [p=[p=1 q=2] q=[~ [p=~~~3e. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (gar [[1 1] "=>"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++hax` - -Parse number sign - - ++ hax (just '#') - -Parses ASCII character 35, the number sign. - - ~zod/try=> (scan "#" hax) - ~~~23. - ~zod/try=> `cord`(scan "#" hax) - '#' - ~zod/try=> (hax [[1 1] "#"]) - [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (hax [[1 1] "#!"]) - [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q="!"]]]] - ------------------------------------------------------------------------- - -### `++kel` - -Parse left curley bracket - - ++ kel (just '{') - -Parses ASCII character 123, the left curly bracket. Note that `{` -(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string -interpolation. To parse either of them, they must be escaped. - - ~zod/try=> (scan "\{" kel) - ~~~7b. - ~zod/try=> `cord`(scan "\{" kel) - '{' - ~zod/try=> (kel [[1 1] "\{"]) - [p=[p=1 q=2] q=[~ [p=~~~7b. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (kel [[1 1] " \{"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++ker` - -Parse right curley bracket - - ++ ker (just '}') - -Parses ASCII character 125, the right curly bracket. Note that `{` -(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string -interpolation. To parse either of them, they must be escaped. - - ~zod/try=> (scan "}" ker) - ~~~7d. - ~zod/try=> `cord`(scan "}" ker) - '}' - ~zod/try=> (ker [[1 1] "}"]) - [p=[p=1 q=2] q=[~ [p=~~~7d. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (ker [[1 1] "\{}"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++ket` - -Parse caret - - ++ ket (just '^') - -Parses ASCII character 94, the caret. - - ~zod/try=> (scan "^" ket) - ~~~5e. - ~zod/try=> `cord`(scan "^" ket) - '^' - ~zod/try=> (ket [[1 1] "^"]) - [p=[p=1 q=2] q=[~ [p=~~~5e. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (ket [[1 1] ".^"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++lus` - -Parse plus sign - - ++ lus (just '+') - -Parses ASCII character 43, the plus sign. - - ~zod/try=> (scan "+" lus) - ~~~2b. - ~zod/try=> `cord`(scan "+" lus) - '+' - ~zod/try=> (lus [[1 1] "+"]) - [p=[p=1 q=2] q=[~ [p=~~~2b. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (lus [[1 1] ".+"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++hep` - -Parse hyphen - - ++ hep (just '-') - -Parses ASCII character 45, the hyphen. - - ~zod/try=> (scan "-" hep) - ~~- - ~zod/try=> `cord`(scan "-" hep) - '-' - ~zod/try=> (hep [[1 1] "-"]) - [p=[p=1 q=2] q=[~ [p=~~- q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (hep [[1 1] ":-"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++pel` - -Parse left parenthesis - - ++ pel (just '(') - -Parses ASCII character 40, the left parenthesis. - - ~zod/try=> (scan "(" pel) - ~~~28. - ~zod/try=> `cord`(scan "(" pel) - '(' - ~zod/try=> (pel [[1 1] "("]) - [p=[p=1 q=2] q=[~ [p=~~~28. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (pel [[1 1] ";("]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++pam` - -Parse ampersand - - ++ pam (just '&') - -Parses ASCII character 38, the ampersand. - - ~zod/try=> (scan "&" pam) - ~~~26. - ~zod/try=> `cord`(scan "&" pam) - '&' - ~zod/try=> (pam [[1 1] "&"]) - [p=[p=1 q=2] q=[~ [p=~~~26. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (pam [[1 1] "?&"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++per` - -Parse right parenthesis - - ++ per (just ')') - -Parses ASCII character 41, the right parenthesis. - - ~zod/try=> (scan ")" per) - ~~~29. - ~zod/try=> `cord`(scan ")" per) - ')' - ~zod/try=> (per [[1 1] ")"]) - [p=[p=1 q=2] q=[~ [p=~~~29. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (per [[1 1] " )"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++pat` - -Parse "at" sign - - ++ pat (just '@') - -Parses ASCII character 64, the "at" sign. - - ~zod/try=> (scan "@" pat) - ~~~4. - ~zod/try=> `cord`(scan "@" pat) - '@' - ~zod/try=> (pat [[1 1] "@"]) - [p=[p=1 q=2] q=[~ [p=~~~4. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (pat [[1 1] "?@"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++sel` - -Parse left square bracket - -Left square bracket - - ++ sel (just '[') - -Parses ASCII character 91, the left square bracket. - - ~zod/try=> (scan "[" sel) - ~~~5b. - ~zod/try=> `cord`(scan "[" sel) - '[' - ~zod/try=> (sel [[1 1] "["]) - [p=[p=1 q=2] q=[~ [p=~~~5b. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (sel [[1 1] "-["]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++sem` - -Parse semicolon - - ++ sem (just ';') - -Parses ASCII character 59, the semicolon. - -### `Examples` - - ~zod/try=> (scan ";" sem) - ~~~3b. - ~zod/try=> `cord`(scan ";" sem) - ';' - ~zod/try=> (sem [[1 1] ";"]) - [p=[p=1 q=2] q=[~ [p=~~~3b. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (sem [[1 1] " ;"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++ser` - -Parse right square bracket - - ++ ser (just ']') - -Parses ASCII character 93, the right square bracket. - - ~zod/try=> (scan "]" ser) - ~~~5d. - ~zod/try=> `cord`(scan "]" ser) - ']' - ~zod/try=> (ser [[1 1] "]"]) - [p=[p=1 q=2] q=[~ [p=~~~5d. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (ser [[1 1] "[ ]"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++sig` - -Parse tilde - - ++ sig (just '~') - -Parses ASCII character 126, the tilde. - - ~zod/try=> (scan "~" sig) - ~~~~ - ~zod/try=> `cord`(scan "~" sig) - '~' - ~zod/try=> (sig [[1 1] "~"]) - [p=[p=1 q=2] q=[~ [p=~~~~ q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (sig [[1 1] "?~"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++soq` - -Parse single quote - - ++ soq (just '\'') - -Parses ASCII character 39, soq. Note the extra '' is to escape the first -`soq` because soq delimits a cord. - - ~zod/try=> (scan "'" soq) - ~~~27. - ~zod/try=> `cord`(scan "'" soq) - ''' - ~zod/try=> (soq [[1 1] "'"]) - [p=[p=1 q=2] q=[~ [p=~~~27. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (soq [[1 1] ">'"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++tar` - -Parse asterisk - - ++ tar (just '*') - -Parses ASCII character 42, the asterisk. - - ~zod/try=> (scan "*" tar) - ~~~2a. - ~zod/try=> `cord`(scan "*" tar) - '*' - ~zod/try=> (tar [[1 1] "*"]) - [p=[p=1 q=2] q=[~ [p=~~~2a. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (tar [[1 1] ".*"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++tec` - -Parse backtick - - ++ tec (just '`') :: backTiCk - -Parses ASCII character 96, the backtick (also known as the "grave -accent". - - ~zod/try=> (scan "`" tec) - ~~~6. - ~zod/try=> `cord`(scan "`" tec) - '`' - ~zod/try=> (tec [[1 1] "`"]) - [p=[p=1 q=2] q=[~ [p=~~~6. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (tec [[1 1] " `"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++tis` - -Parse equals sign - - ++ tis (just '=') - -Parses ASCII character 61, the equals sign. - - ~zod/try=> (scan "=" tis) - ~~~3d. - ~zod/try=> `cord`(scan "=" tis) - '=' - ~zod/try=> (tis [[1 1] "="]) - [p=[p=1 q=2] q=[~ [p=~~~3d. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (tis [[1 1] "|="]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++wut` - -Parses question mark - - ++ wut (just '?') - -Parses ASCII character 63, wut. - - ~zod/try=> (scan "?" wut) - ~~~3f. - ~zod/try=> `cord`(scan "?" wut) - '?' - ~zod/try=> (wut [[1 1] "?"]) - [p=[p=1 q=2] q=[~ [p=~~~3f. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (wut [[1 1] ".?"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- - -### `++zap` - -Exclamation point - - ++ zap (just '!') - -Parses ASCII character 33, the exclamation point zap. - - ~zod/try=> (scan "!" zap) - ~~~21. - ~zod/try=> `cord`(scan "!" zap) - '!' - ~zod/try=> (zap [[1 1] "!"]) - [p=[p=1 q=2] q=[~ [p=~~~21. q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (zap [[1 1] "?!"]) - [p=[p=1 q=1] q=~] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2eg.md b/web/docs/dev/hoon/library/2eg.md deleted file mode 100644 index 22cfe88f4..000000000 --- a/web/docs/dev/hoon/library/2eg.md +++ /dev/null @@ -1,160 +0,0 @@ -section 2eG, parsing (whitespace) -================================= - -### `++dog` - -`.` optional gap - - ++ dog ;~(plug dot gay) :: - -Dot followed by an optional gap, used in numbers. - - /~zod/try=> 1.234. - 703 - 1.234.703 - ~zod/try=> (scan "a. " ;~(pfix alf dog)) - [~~~. ~] - ------------------------------------------------------------------------- - -### `++doh` - -`@p` separator - - ++ doh ;~(plug ;~(plug hep hep) gay) :: - -Phonetic base phrase separator - - /~zod/try=> ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd - ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd - /~zod/try=> ~nopfel-botduc-nilnev-dolfyn-- - haspub-natlun-lodmur-holtyd - ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd - ~zod/try=> (scan "--" doh) - [[~~- ~~-] ~] - ~zod/try=> (scan "-- " doh) - [[~~- ~~-] ~] - ------------------------------------------------------------------------- - -### `++dun` - -`--` to `~` - - ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~ - -Parse phep, `--`, to null, `~`. - - ~zod/try=> (scan "--" dun) - ~ - ~zod/try=> (dun [[1 1] "--"]) - [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=""]]]] - ------------------------------------------------------------------------- - -### `++duz` - -`==` to `~` - - ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~ - -Parse stet, `==`, to null `~`. - - ~zod/try=> (scan "==" duz) - ~ - ~zod/try=> (duz [[1 1] "== |=..."]) - [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=" |=..."]]]] - ------------------------------------------------------------------------- - -### `++gah` - -Newline or ' ' - - ++ gah (mask [`@`10 ' ' ~]) :: newline or ace - -Whitespace component, either newline or space. - - /~zod/try=> ^- * :: show spaces - """ - - - - - - - """ - [32 32 32 45 10 32 45 10 32 32 45 0] - /~zod/try=> ^- * - """ - - """ - [32 32 32 10 32 10 32 32 0] - /~zod/try=> ^- (list ,@) - %- scan :_ (star gah) - """ - - """ - ~[32 32 32 10 32 10 32 32] - ------------------------------------------------------------------------- - -### `++gap` - -Plural whitespace - - ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) :: plural whitespace - -Separates tall runes - ------------------------------------------------------------------------- - -### `++gaq` - -End of line - - ++ gaq ;~ pose :: end of line - (just `@`10) - ;~(plug gah ;~(pose gah vul)) - vul - == - -Two spaces, a newline, or comment. - ------------------------------------------------------------------------- - -### `++gaw` - -Classic whitespace - - ++ gaw (cold ~ (star ;~(pose vul gah))) :: classic white - -Terran whitespace - ------------------------------------------------------------------------- - -### `++gay` - -Optional gap. - - ++ gay ;~(pose gap (easy ~)) :: - -Optional gap. - ------------------------------------------------------------------------- - -### `++vul` - - ++ vul %- cold :- ~ :: comments - ;~ plug col col - (star prn) - (just `@`10) - == - -Parse comments and produce a null. Note that a comment must be ended -with a newline character. - - ~zod/try=> (scan "::this is a comment \0a" vul) - ~ - ~zod/try=> (scan "::this is a comment " vul) - ! {1 21} - ! exit - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2eh.md b/web/docs/dev/hoon/library/2eh.md deleted file mode 100644 index da4b79489..000000000 --- a/web/docs/dev/hoon/library/2eh.md +++ /dev/null @@ -1,531 +0,0 @@ -section 2eH, parsing (idioms) -============================= - -### `++alf` - -Alphabetic characters - - ++ alf ;~(pose low hig) :: alphabetic - -Parse alphabetic characters, both upper and lowercase. - - ~zod/try=> (scan "a" alf) - ~~a - ~zod/try=> (scan "A" alf) - ~~~41. - ~zod/try=> (scan "AaBbCc" (star alf)) - "AaBbCc" - ------------------------------------------------------------------------- - -### `++aln` - -Alphanumeric characters - - ++ aln ;~(pose low hig nud) :: alphanumeric - -Parse alphanumeric characters - both alphabetic characters and numbers. - - ~zod/try=> (scan "0" aln) - ~~0 - ~zod/try=> (scan "alf42" (star aln)) - "alf42" - ~zod/try=> (scan "0123456789abcdef" (star aln)) - "0123456789abcdef" - ------------------------------------------------------------------------- - -### `++alp` - -Alphanumeric and `-` - - ++ alp ;~(pose low hig nud hep) :: alphanumeric and - - -Parse alphanumeric strings and hep, "-". - - ~zod/try=> (scan "7" alp) - ~~7 - ~zod/try=> (scan "s" alp) - ~~s - ~zod/try=> (scan "123abc-" (star alp)) - "123abc-" - ------------------------------------------------------------------------- - -### `++bet` - -Axis syntax `-`, `+` - - ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - + - -Parse the hep and lus axis syntax. - - ~zod/try=> (scan "-" bet) - 2 - ~zod/try=> (scan "+" bet) - 3 - ------------------------------------------------------------------------- - -### `++bin` - -Binary to atom - - ++ bin (bass 2 (most gon but)) :: binary to atom - -Parse a tape of binary (0s and 1s) and produce its atomic -representation. - - ~zod/try=> (scan "0000" bin) - 0 - ~zod/try=> (scan "0001" bin) - 1 - ~zod/try=> (scan "0010" bin) - 2 - ~zod/try=> (scan "100000001111" bin) - 2.063 - ------------------------------------------------------------------------- - -### `++but` - -Binary digit - - ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit - -Parse a single binary digit. - - ~zod/try=> (scan "0" but) - 0 - ~zod/try=> (scan "1" but) - 1 - ~zod/try=> (scan "01" but) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> (scan "01" (star but)) - ~[0 1] - ------------------------------------------------------------------------- - -### `++cit` - -Octal digit - - ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit - -Parse a single octal digit. - - ~zod/try=> (scan "1" cit) - 1 - ~zod/try=> (scan "7" cit) - 7 - ~zod/try=> (scan "8" cit) - ! {1 1} - ! 'syntax-error' - ! exit - ~zod/try=> (scan "60" (star cit)) - ~[6 0] - ------------------------------------------------------------------------- - -### `++dem` - -Decimal to atom - - ++ dem (bass 10 (most gon dit)) :: decimal to atom - -Parse a decimal number to an atom. - - ~zod/try=> (scan "7" dem) - 7 - ~zod/try=> (scan "42" dem) - 42 - ~zod/try=> (scan "150000000" dem) - 150.000.000 - ~zod/try=> (scan "12456" dem) - 12.456 - ------------------------------------------------------------------------- - -### `++dit` - -Decimal digit - - ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit - -Parse a single decimal digit. - - ~zod/try=> (scan "7" dit) - 7 - ~zod/try=> (scan "42" (star dit)) - ~[4 2] - ~zod/try=> (scan "26000" (star dit)) - ~[2 6 0 0 0] - ------------------------------------------------------------------------- - -### `++gul` - -Axis syntax `<` or `>` - - ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < > - -Parse the axis gal and gar axis syntax. - - ~zod/try=> (scan "<" gul) - 2 - ~zod/try=> (scan ">" gul) - 3 - ------------------------------------------------------------------------- - -### `++gon` - -Long numbers - - ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ / - -Parse long numbers - Numbers which wrap around the shell with the line -break characters bas and fas. - - ~zod/try=> (scan "\\/" gon) - [~~~5c. ~ ~~~2f.] - ~zod/try=> (gon [[1 1] "\\/"]) - [p=[p=1 q=3] q=[~ u=[p=[~~~5c. ~ ~~~2f.] q=[p=[p=1 q=3] q=""]]]] - ------------------------------------------------------------------------- - -### `++hex` - -Hex to atom - - ++ hex (bass 16 (most gon hit)) :: hex to atom - -Parse any hexadecimal number to an atom. - - ~zod/try=> (scan "a" hex) - 10 - ~zod/try=> (scan "A" hex) - 10 - ~zod/try=> (scan "2A" hex) - 42 - ~zod/try=> (scan "1ee7" hex) - 7.911 - ~zod/try=> (scan "1EE7" hex) - 7.911 - ~zod/try=> (scan "1EE7F7" hex) - 2.025.463 - ~zod/try=> `@ux`(scan "1EE7F7" hex) - 0x1e.e7f7 - ------------------------------------------------------------------------- - -### `++hig` - -Uppercase - - ++ hig (shim 'A' 'Z') :: uppercase - -Parse a single uppercase letter. - - ~zod/try=> (scan "G" hig) - ~~~47. - ~zod/try=> `cord`(scan "G" hig) - 'G' - ~zod/try=> (scan "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (star hig)) - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ~zod/try=> (hig [[1 1] "G"]) - [p=[p=1 q=2] q=[~ [p=~~~47. q=[p=[p=1 q=2] q=""]]]] - ------------------------------------------------------------------------- - -### `++hit` - -Hex digits - - ++ hit ;~ pose :: hex digits - dit - (cook |=(a=char (sub a 87)) (shim 'a' 'f')) - (cook |=(a=char (sub a 55)) (shim 'A' 'F')) - == - -Parse a single hexadecimal digit. - - ~zod/try=> (scan "a" hit) - 10 - ~zod/try=> (scan "A" hit) - 10 - ~zod/try=> (hit [[1 1] "a"]) - [p=[p=1 q=2] q=[~ [p=10 q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (scan "2A" (star hit)) - ~[2 10] - ------------------------------------------------------------------------- - -### `++low` - -Lowercase - - ++ low (shim 'a' 'z') :: lowercase - -Parse a single lowercase letter. - - ~zod/try=> (scan "g" low) - ~~g - ~zod/try=> `cord`(scan "g" low) - 'g' - ~zod/try=> (scan "abcdefghijklmnopqrstuvwxyz" (star low)) - "abcdefghijklmnopqrstuvwxyz" - ~zod/try=> (low [[1 1] "g"]) - [p=[p=1 q=2] q=[~ [p=~~g q=[p=[p=1 q=2] q=""]]]] - ------------------------------------------------------------------------- - -### `++mes` - -Hexbyte - - ++ mes %+ cook :: hexbyte - |=([a=@ b=@] (add (mul 16 a) b)) - ;~(plug hit hit) - -Parse a hexbyte. - - ~zod/try=> (scan "2A" mes) - 42 - ~zod/try=> (mes [[1 1] "2A"]) - [p=[p=1 q=3] q=[~ u=[p=42 q=[p=[p=1 q=3] q=""]]]] - ~zod/try=> (scan "42" mes) - 66 - ------------------------------------------------------------------------- - -### `++nix` - -Letters, `-`, and `_` - - ++ nix (boss 256 (star ;~(pose aln cab))) :: - -Letters, `-`, and `_` - - ~zod/try=> (scan "as_me" nix) - q=435.626.668.897 - ~zod/try=> `@t`(scan "as_me" nix) - 'as_me' - ------------------------------------------------------------------------- - -### `++nud` - -Numeric - - ++ nud (shim '0' '9') :: numeric - -Parse a numeric character - A number. - - ~zod/try=> (scan "0" nud) - ~~0 - ~zod/try=> (scan "7" nud) - ~~7 - ~zod/try=> (nud [[1 1] "1"]) - [p=[p=1 q=2] q=[~ [p=~~1 q=[p=[p=1 q=2] q=""]]]] - ~zod/try=> (scan "0123456789" (star nud)) - "0123456789" - ------------------------------------------------------------------------- - -### `++prn` - -Printable character - - ++ prn ;~(less (just `@`127) (shim 32 256)) - -Parse any printable character - - ~zod/try=> (scan "h" prn) - ~~h - ~zod/try=> (scan "!" prn) - ~~~21. - ~zod/try=> (scan "\01" prn) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++qat` - -Chars in blockcord - - ++ qat ;~ pose :: chars in blockcord - prn - ;~(less ;~(plug (just `@`10) soqs) (just `@`10)) - == - -Parse character in cord block. - - ~zod/try=> (scan "h" qat) - ~~h - ~zod/try=> (scan "!" qat) - ~~~21. - ~zod/try=> (scan "\0a" qat) - ~~~a. - ~zod/try=> (scan "\00" qat) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++qit` - -Chars in cord - - ++ qit ;~ pose :: chars in a cord - ;~(less bas soq prn) - ;~(pfix bas ;~(pose bas soq mes)) :: escape chars - == - -Parse an individual character to its cord atom representation. - - ~zod/try=> (scan "%" qit) - 37 - ~zod/try=> `@t`(scan "%" qit) - '%' - ~zod/try=> (scan "0" qit) - 48 - ~zod/try=> (scan "E" qit) - 69 - ~zod/try=> (scan "a" qit) - 97 - ~zod/try=> (scan "\\0a" qit) - 10 - ~zod/try=> `@ux`(scan "\\0a" qit) - 0xa - ~zod/try=> (scan "cord" (star qit)) - ~[99 111 114 100] - ------------------------------------------------------------------------- - -### `++qut` - -Cord - - ++ qut ;~ pose :: cord - ;~ less soqs - (ifix [soq soq] (boss 256 (more gon qit))) - == - %- inde %+ ifix - :- ;~ plug soqs - ;~(pose ;~(plug (plus ace) vul) (just '\0a')) - == - ;~(plug (just '\0a') soqs) - (boss 256 (star qat)) - == - :: - -Parse single-soq cord with `\{gap}/` anywhere in the middle, or -triple-soq cord which must be in an indented block. - - ~zod/try=> (scan "'cord'" qut) - q=1.685.221.219 - ~zod/try=> 'cord' - 'cord' - ~zod/try=> `@ud`'cord' - 1.685.221.219 - /~zod/try=> ''' - Heredoc isn't prohibited from containing quotes - ''' - 'Heredoc isn't prohibited from containing quotes' - ------------------------------------------------------------------------- - -### `++soqs` - -Delimiting `'''` - - ++ soqs ;~(plug soq soq soq) :: delimiting ''' - -Triple single quote - - ~zod/try=> (scan "'''" soqs) - [~~~27. ~~~27. ~~~27.] - ~zod/try=> (rash '"""' soqs) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sym` - -Term - - ++ sym - %+ cook - |=(a=tape (rap 3 ^-((list ,@) a))) - ;~(plug low (star ;~(pose nud low hep))) - :: - -A term: a letter(lowercase), followed by letters, numbers, or `-`. - - ~zod/try=> (scan "sam-2" sym) - 215.510.507.891 - ~zod/try=> `@t`(scan "sam-2" sym) - 'sam-2' - ~zod/try=> (scan "sym" sym) - 7.174.515 - ------------------------------------------------------------------------- - -### `++ven` - -`+>-` axis syntax - - ++ ven ;~ (comp |=([a=@ b=@] (peg a b))) :: +>- axis syntax - bet - =+ hom=`?`| - |= tub=nail - ^- (like axis) - =+ vex=?:(hom (bet tub) (gul tub)) - ?~ q.vex - [p.tub [~ 1 tub]] - =+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex) - ?> ?=(^ q.wag) - [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]] - == - -Axis syntax parser - - ~zod/arvo=/hoon/hoon> (scan "->+" ven) - 11 - ~zod/arvo=/hoon/hoon> `@ub`(scan "->+" ven) - 0b1011 - ~zod/arvo=/hoon/hoon> (peg (scan "->" ven) (scan "+" ven)) - 11 - ~zod/arvo=/hoon/hoon> ->+:[[1 2 [3 4]] 5] - [3 4] - ------------------------------------------------------------------------- - -### `++vit` - -Base64 digit - - ++ vit :: base64 digit - ;~ pose - (cook |=(a=@ (sub a 65)) (shim 'A' 'Z')) - (cook |=(a=@ (sub a 71)) (shim 'a' 'z')) - (cook |=(a=@ (add a 4)) (shim '0' '9')) - (cold 62 (just '-')) - (cold 63 (just '+')) - == - -Terran base64 - - ~zod/arvo=/hoon/hoon> (scan "C" vit) - 2 - ~zod/arvo=/hoon/hoon> (scan "c" vit) - 28 - ~zod/arvo=/hoon/hoon> (scan "2" vit) - 54 - ~zod/arvo=/hoon/hoon> (scan "-" vit) - 62 diff --git a/web/docs/dev/hoon/library/2ei.md b/web/docs/dev/hoon/library/2ei.md deleted file mode 100644 index 90f8b1660..000000000 --- a/web/docs/dev/hoon/library/2ei.md +++ /dev/null @@ -1,107 +0,0 @@ -section 2eI, parsing (external) -=============================== - -### `++rash` - -Parse or crash - - ++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) :: - -Parse a cord with a given rule and crash if the cord isn't entirely -parsed. - -`naf` is an [atom](). - -`sab` is a [rule](). - - ~zod/try=> (rash 'I was the world in which I walked, and what I saw' (star (shim 0 200))) - "I was the world in which I walked, and what I saw" - ~zod/try=> (rash 'abc' (just 'a')) - ! {1 2} - ! 'syntax-error' - ! exit - ~zod/try=> (rash 'abc' (jest 'abc')) - 'abc' - `~zod/try=> (rash 'abc' (jest 'ab')) - ! {1 3} - ! 'syntax-error' - ! exit - ------------------------------------------------------------------------- - -### `++rush` - -Parse or null - - ++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab)) - -Parse a given with a given rule and produce null if the cord isn't -entirely parsed. - -`naf` is an [atom](). - -`sab` is a [rule](). - - ~zod/try=> (rush 'I was the world in which I walked, and what I saw' (star (shim 0 200))) - [~ "I was the world in which I walked, and what I saw"] - ~zod/try=> (rush 'abc' (just 'a')) - ~ - ~zod/try=> (rush 'abc' (jest 'abc')) - [~ 'abc'] - ~zod/try=> (rush 'abc' (jest 'ac')) - ~ - ~zod/try=> (rush 'abc' (jest 'ab')) - ~ - ------------------------------------------------------------------------- - -### `++rust` - -Parse tape or null - - ++ rust |* [los=tape sab=_rule] - =+ vex=((full sab) [[1 1] los]) - ?~(q.vex ~ [~ u=p.u.q.vex]) - -Parse a tape with a given rule and produce null if the tape isn't -entirely parsed. - -`los` is a [tape](). - -`sab` is a [rule](). - - ~zod/try=> (rust "I was the world in which I walked, and what I saw" (star (shim 0 200))) - [~ "I was the world in which I walked, and what I saw"] - ~zod/try=> (rust "Or heard or felt came not but from myself;" (star (shim 0 200))) - [~ "Or heard or felt came not but from myself;"] - ~zod/try=> (rust "And there I found myself more truly and more strange." (jest 'And there I')) - ~ - ------------------------------------------------------------------------- - -### `++scan` - -Parse tape or crash - - ++ scan |* [los=tape sab=_rule] - =+ vex=((full sab) [[1 1] los]) - ?~ q.vex - ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~) - ~|('syntax-error' !!) - p.u.q.vex - -Parse a tape with a given rule and crash if the tape isn't entirely -parsed. - -`los` is a [tape](). - -`sab` is a [rule](). - - ~zod/try=> (scan "I was the world in which I walked, and what I saw" (star (shim 0 200))) - "I was the world in which I walked, and what I saw" - ~zod/try=> (scan "Or heard or felt came not but from myself;" (star (shim 0 200))) - "Or heard or felt came not but from myself;" - ~zod/try=> (scan "And there I found myself more truly and more strange." (jest 'And there I')) - ! {1 12} - ! 'syntax-error' - ! exit diff --git a/web/docs/dev/hoon/library/2ej.md b/web/docs/dev/hoon/library/2ej.md deleted file mode 100644 index 77382925d..000000000 --- a/web/docs/dev/hoon/library/2ej.md +++ /dev/null @@ -1,561 +0,0 @@ -section 2eJ, formatting (basic text) -==================================== - -### `++cass` - -To lowercase - - ++ cass :: lowercase - |= vib=tape - %+ rap 3 - (turn vib |=(a=@ ?.(&((gte a 'A') (lte a 'Z')) a (add 32 a)))) - :: - -Produce the case insensitive (all lowercase) cord of a tape. - -`vib` is a [tape](). - - ~zod/try=> (cass "john doe") - 7.309.170.810.699.673.450 - ~zod/try=> `cord`(cass "john doe") - 'john doe' - ~zod/try=> (cass "abc, 123, !@#") - 2.792.832.775.110.938.439.066.079.945.313 - ~zod/try=> `cord`(cass "abc, 123, !@#") - 'abc, 123, !@#' - ------------------------------------------------------------------------- - -### `++cuss` - -To uppercase - - ++ cuss :: uppercase - |= vib=tape - ^- @t - %+ rap 3 - (turn vib |=(a=@ ?.(&((gte a 'a') (lte a 'z')) a (sub a 32)))) - :: - -Turn all occurances of lowercase letters in any tape into uppercase -letters, as a cord. - -`vib` is a [tape](). - - ~zod/try=> (cuss "john doe") - 'JOHN DOE' - ~zod/try=> (cuss "abc ABC 123 !@#") - 'ABC ABC 123 !@#' - ~zod/try=> `@ud`(cuss "abc") - 4.407.873 - ~zod/try=> (cuss "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsQqRrVvWwXxYyZz") - 'AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSQQRRVVWWXXYYZZ' - ------------------------------------------------------------------------- - -### `++crip` - -Tape to cord - - ++ crip |=(a=tape `@t`(rap 3 a)) :: tape to cord - -Produce cord from a tape. - -`a` is a [tape](). - - ~zod/try=> (crip "john doe") - 'john doe' - ~zod/try=> (crip "abc 123 !@#") - 'abc 123 !@#' - ~zod/try=> `@ud`(crip "abc") - 6.513.249 - ------------------------------------------------------------------------- - -### `++mesc` - -Escape special chars - - ++ mesc :: ctrl code escape - |= vib=tape - ^- tape - ?~ vib - ~ - ?: =('\\' i.vib) - ['\\' '\\' $(vib t.vib)] - ?: ?|((gth i.vib 126) (lth i.vib 32) =(39 i.vib)) - ['\\' (welp ~(rux at i.vib) '/' $(vib t.vib))] - [i.vib $(vib t.vib)] - :: - -Escape special characters, used in [`++show`](/doc/hoon/library/2ez#++show) - -`vib` is a [tape](). - - /~zod/try=> (mesc "ham lus") - "ham lus" - /~zod/try=> (mesc "bas\\hur") - "bas\\\\hur" - /~zod/try=> (mesc "as'saß") - "as\0x27/sa\0xc3/\0x9f/" - ------------------------------------------------------------------------- - -### `++runt` - -Prepend `n` times - - ++ runt :: prepend repeatedly - |= [[a=@ b=@] c=tape] - ^- tape - ?: =(0 a) - c - [b $(a (dec a))] - :: - -Add `a` repetitions of character `b` to the head of `c` - -`a` and `b` are [atom]()s. - -`c` is a [tape](). - - /~zod/try=> (runt [2 '/'] "ham") - "//ham" - /~zod/try=> (runt [10 'a'] "") - "aaaaaaaaaa" - ------------------------------------------------------------------------- - -### `++sand` - -Soft-cast by odor - - ++ sand :: atom sanity - |= a=@ta - |= b=@ ^- (unit ,@) - ?.(((sane a) b) ~ [~ b]) - :: - -Soft-cast validity by odor. - -`a` is a [`@ta`](). - -`b` is an [atom](). - - /~zod/try=> `(unit ,@ta)`((sand %ta) 'sym-som') - [~ ~.sym-som] - /~zod/try=> `(unit ,@ta)`((sand %ta) 'err!') - ~ - ------------------------------------------------------------------------- - -### `++sane` - -Check odor validity - - ++ sane :: atom sanity - |= a=@ta - |= b=@ ^- ? - ?. =(%t (end 3 1 a)) - ~|(%sane-stub !!) - =+ [inx=0 len=(met 3 b)] - ?: =(%tas a) - |- ^- ? - ?: =(inx len) & - =+ cur=(cut 3 [inx 1] b) - ?& ?| &((gte cur 'a') (lte cur 'z')) - &(=('-' cur) !=(0 inx) !=(len inx)) - &(&((gte cur '0') (lte cur '9')) !=(0 inx)) - == - $(inx +(inx)) - == - ?: =(%ta a) - |- ^- ? - ?: =(inx len) & - =+ cur=(cut 3 [inx 1] b) - ?& ?| &((gte cur 'a') (lte cur 'z')) - &((gte cur '0') (lte cur '9')) - |(=('-' cur) =('~' cur) =('_' cur) =('.' cur)) - == - $(inx +(inx)) - == - |- ^- ? - ?: =(0 b) & - =+ cur=(end 3 1 b) - ?: &((lth cur 32) !=(10 cur)) | - =+ len=(teff cur) - ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i))))))) - $(b (rsh 3 len b)) - == - :: - -Check validity by odor. Produces a gate. - -`a` is a [`@ta`](). - -`b` is an [atom](). - - /~zod/try=> ((sane %tas) %mol) - %.y - /~zod/try=> ((sane %tas) 'lam') - %.y - /~zod/try=> ((sane %tas) 'more ace') - %.n - ------------------------------------------------------------------------- - -### `++trim` - -Tape split - - ++ trim :: tape split - |= [a=@ b=tape] - ^- [p=tape q=tape] - ?~ b - [~ ~] - ?: =(0 a) - [~ b] - =+ c=$(a (dec a), b t.b) - [[i.b p.c] q.c] - :: - -Split first `a` characters off tape. - -`a` is an [atom](). - -`b` is a [tape](). - - /~zod/try=> (trim 5 "lasok termun") - [p="lasok" q=" termun"] - /~zod/try=> (trim 5 "zam") - [p="zam" q=""] - ------------------------------------------------------------------------- - -### `++trip` - -Cord to tape - - ++ trip :: cord to tape - ~/ %trip - |= a=@ ^- tape - ?: =(0 (met 3 a)) - ~ - [^-(@ta (end 3 1 a)) $(a (rsh 3 1 a))] - :: - -Produce tape from cord. - -`a` is an [atom](). - - /~zod/try=> (trip 'john doe') - "john doe" - /~zod/try=> (trip 'abc 123 !@#') - "abc 123 !@#" - /~zod/try=> (trip 'abc') - "abc" - ------------------------------------------------------------------------- - -### `++teff` - -UTF8 Length - - ++ teff :: length utf8 - |= a=@t ^- @ - =+ b=(end 3 1 a) - ?: =(0 b) - ?>(=(0 a) 0) - ?> |((gte b 32) =(10 b)) - ?:((lte b 127) 1 ?:((lte b 223) 2 ?:((lte b 239) 3 4))) - :: - -Number of utf8 bytes. - -`a` is a [`@t`](). - - /~zod/try=> (teff 'a') - 1 - /~zod/try=> (teff 'ß') - 2 - ------------------------------------------------------------------------- - -### `++turf` - -UTF8 to UTF32 cord - - ++ turf :: utf8 to utf32 - |= a=@t - ^- @c - %+ rap 5 - |- ^- (list ,@c) - =+ b=(teff a) - ?: =(0 b) ~ - :- %+ can 0 - %+ turn - ^- (list ,[p=@ q=@]) - ?+ b !! - 1 [[0 7] ~] - 2 [[8 6] [0 5] ~] - 3 [[16 6] [8 6] [0 4] ~] - 4 [[24 6] [16 6] [8 6] [0 3] ~] - == - |=([p=@ q=@] [q (cut 0 [p q] a)]) - $(a (rsh 3 b a)) - :: - -Convert utf8 ([cord]()) to utf32 codepoints. - -`a` is a [`@t`](). - - /~zod/try=> (turf 'my ßam') - ~-my.~df.am - /~zod/try=> 'я тут' - 'я тут' - /~zod/try=> (turf 'я тут') - ~-~44f..~442.~443.~442. - /~zod/try=> `@ux`'я тут' - 0x82.d183.d182.d120.8fd1 - /~zod/try=> `@ux`(turf 'я тут') - 0x442.0000.0443.0000.0442.0000.0020.0000.044f - ------------------------------------------------------------------------- - -### `++tuba` - -UTF8 to UTF32 tape - - ++ tuba :: utf8 to utf32 tape - |= a=tape - ^- (list ,@c) - (rip 5 (turf (rap 3 a))) :: XX horrible - :: - -Convert tape to list of codepoints. - -`a` is a [tape]() - - /~zod/try=> (tuba "я тут") - ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.] - /~zod/try=> (tuba "chars") - ~[~-c ~-h ~-a ~-r ~-s] - ------------------------------------------------------------------------- - -### `++tufa` - -UTF32 to UTF8 tape - - ++ tufa :: utf32 to utf8 tape - |= a=(list ,@c) - ^- tape - ?~ a "" - (weld (rip 3 (tuft i.a)) $(a t.a)) - :: - -Wrap list of utf32 codepoints to utf8 [tape](). - -`a` is a [list]() of [`@c`](). - - /~zod/try=> (tufa ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.]) - "я тут" - /~zod/try=> (tufa ((list ,@c) ~[%a %b 0xb1 %c])) - "ab±c" - ------------------------------------------------------------------------- - -### `++tuft` - -UTF32 to UTF8 text - - ++ tuft :: utf32 to utf8 text - |= a=@c - ^- @t - %+ rap 3 - |- ^- (list ,@) - ?: =(0 a) - ~ - =+ b=(end 5 1 a) - =+ c=$(a (rsh 5 1 a)) - ?: (lth b 0x7f) - [b c] - ?: (lth b 0x7ff) - :* (mix 0b1100.0000 (cut 0 [6 5] b)) - (mix 0b1000.0000 (end 0 6 b)) - c - == - ?: (lth b 0xffff) - :* (mix 0b1110.0000 (cut 0 [12 4] b)) - (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (end 0 6 b)) - c - == - :* (mix 0b1111.0000 (cut 0 [18 3] b)) - (mix 0b1000.0000 (cut 0 [12 6] b)) - (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (end 0 6 b)) - c - == - :: - -Convert utf32 glyph to -[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) utf8 cord. - -`a` is a [`@c`](). - - /~zod/try=> (tuft `@c`%a) - 'a' - /~zod/try=> (tuft `@c`0xb6) - '¶' - ------------------------------------------------------------------------- - -### `++wack` - -Coin format encode - - ++ wack :: coin format - |= a=@ta - ^- @ta - =+ b=(rip 3 a) - %+ rap 3 - |- ^- tape - ?~ b - ~ - ?: =('~' i.b) ['~' '~' $(b t.b)] - ?: =('_' i.b) ['~' '-' $(b t.b)] - [i.b $(b t.b)] - :: - -Escape span `~` as `~~` and `_` as `~-`. Used for printing. - -`a` is a [`@ta`](). - - /~zod/try=> (wack '~20_sam~') - ~.~~20~-sam~~ - /~zod/try=> `@t`(wack '~20_sam~') - '~~20~-sam~~' - ~zod/try=> ~(rend co %many ~[`ud/5 `ta/'~20_sam']) - "._5_~~.~~20~-sam__" - ~zod/try=> ._5_~~.~~20~-sam__ - [5 ~.~20_sam] - ------------------------------------------------------------------------- - -### `++wick` - -Coin format decode - - ++ wick :: coin format - |= a=@ - ^- @ta - =+ b=(rip 3 a) - %+ rap 3 - |- ^- tape - ?~ b - ~ - ?: =('~' i.b) - ?~ t.b !! - [?:(=('~' i.t.b) '~' ?>(=('-' i.t.b) '_')) $(b t.t.b)] - [i.b $(b t.b)] - :: - -Unescape span `~~` as `~` and `~-` as `_`. - -`a` is a an [atom](). - - /~zod/try=> `@t`(wick '~-ams~~lop') - '_ams~lop' - /~zod/try=> `@t`(wick (wack '~20_sam~')) - '~20_sam~' - ------------------------------------------------------------------------- - -### `++woad` - -Unescape cord - - ++ woad :: cord format - |= a=@ta - ^- @t - %+ rap 3 - |- ^- (list ,@) - ?: =(0 a) - ~ - =+ b=(end 3 1 a) - =+ c=(rsh 3 1 a) - ?: =('.' b) - [' ' $(a c)] - ?. =('~' b) - [b $(a c)] - => .(b (end 3 1 c), c (rsh 3 1 c)) - ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) - ^= d - =+ d=0 - |- ^- [p=@ q=@] - ?: =('.' b) - [d c] - ?< =(0 c) - %= $ - b (end 3 1 c) - c (rsh 3 1 c) - d %+ add (mul 16 d) - %+ sub b - ?: &((gte b '0') (lte b '9')) 48 - ?>(&((gte b 'a') (lte b 'z')) 87) - == - %'.' ['.' $(a c)] - %'~' ['~' $(a c)] - == - :: - -Unescape cord codepoints. - -`a` is a [`@ta`](). - - /~zod/try=> (woad ~.~b6.20.as) - '¶20 as' - ------------------------------------------------------------------------- - -### `++wood` - -Escape cord - - ++ wood :: cord format - |= a=@t - ^- @ta - %+ rap 3 - |- ^- (list ,@) - ?: =(0 a) - ~ - =+ b=(teff a) - =+ c=(turf (end 3 b a)) - =+ d=$(a (rsh 3 b a)) - ?: ?| &((gte c 'a') (lte c 'z')) - &((gte c '0') (lte c '9')) - =('-' c) - == - [c d] - ?+ c - :- '~' - =+ e=(met 2 c) - |- ^- tape - ?: =(0 c) - ['.' d] - =. e (dec e) - =+ f=(rsh 2 e c) - [(add ?:((lte f 9) 48 87) f) $(c (end 2 e c))] - :: - %' ' ['.' d] - %'.' ['~' '.' d] - %'~' ['~' '~' d] - == - -Escape cord codepoints. - -`a` is a [`@ta`](). - - /~zod/try=> (wood 'my ßam') - ~.my.~df.am diff --git a/web/docs/dev/hoon/library/2ek.md b/web/docs/dev/hoon/library/2ek.md deleted file mode 100644 index c89ebe425..000000000 --- a/web/docs/dev/hoon/library/2ek.md +++ /dev/null @@ -1,162 +0,0 @@ -section 2eK, formatting (layout) -================================ - -### `++re` - -Pretty-printing engine - - ++ re - |_ tac=tank - -Pretty-printing engine. - -`tac` is a [`++tank`](/doc/hoon/library/1#++tank). - - /~zod/try=> ~(. re leaf/"ham") - <2.ghl [[%leaf ""] <414.gly 100.xkc 1.ypj %164>]> - -### `++ram` - -Flatten to tape - - ++ ram - ^- tape - ?- -.tac - %leaf p.tac - %palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac]) - %rose - %+ weld - q.p.tac - |- ^- tape - ?~ q.tac - r.p.tac - =+ voz=$(q.tac t.q.tac) - (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz))) - == - :: - -Flatten tank out into a tape. - - /~zod/try=> ~(ram re leaf/"foo") - "foo" - /~zod/try=> ~(ram re rose/["." "(" ")"]^~[leaf/"bar" leaf/"baz" leaf/"bam"]) - "(bar.baz.bam)" - -### `++win` - -Render at indent - - ++ win - |= [tab=@ edg=@] - =+ lug=`wall`~ - |^ |- ^- wall - ?- -.tac - %leaf (rig p.tac) - %palm - ?: fit - (rig ram) - ?~ q.tac - (rig q.p.tac) - ?~ t.q.tac - (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac) - => .(q.tac `(list tank)`q.tac) - =+ lyn=(mul 2 (lent q.tac)) - =+ ^= qyr - |- ^- wall - ?~ q.tac - lug - %= ^$ - tac i.q.tac - tab (add tab (sub lyn 2)) - lug $(q.tac t.q.tac, lyn (sub lyn 2)) - == - (wig(lug qyr) q.p.tac) - :: - %rose - ?: fit - (rig ram) - =+ ^= gyl - |- ^- wall - ?~ q.tac - ?:(=(%$ r.p.tac) lug (rig r.p.tac)) - ^$(tac i.q.tac, lug $(q.tac t.q.tac), tab din) - ?: =(%$ q.p.tac) - gyl - (wig(lug gyl) q.p.tac) - == - :: - -Render at indent level `tab` and width `edg`. - -`tab` and `edg` are [atom]()s. - - /~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 20) - <<"samoltekon-lapdok">> - /~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 10) - <<"\/samolt\/" " ekon-l" " apdok" "\/ \/">> - /~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 20) - <<"[1423--2316]">> - /~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 10) - <<"[ 1423" " 2316" "]">> - -### `++din` - - ++ din (mod (add 2 tab) (mul 2 (div edg 3))) - -XX document - -### `++fit` - -Fit on one line test - - ++ fit (lte (lent ram) (sub edg tab)) - -Determine whether `tac` fits on one line. Internal to `++win` - -### `++rig` - -Wrap in `\/` - - ++ rig - |= hom=tape - ^- wall - ?: (lte (lent hom) (sub edg tab)) - [(runt [tab ' '] hom) lug] - => .(tab (add tab 2), edg (sub edg 2)) - =+ mut=(trim (sub edg tab) hom) - :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])]) - => .(hom q.mut) - |- - ?~ hom - :- %+ runt - [(sub tab 2) ' '] - ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])] - lug - => .(mut (trim (sub edg tab) hom)) - [(runt [tab ' '] p.mut) $(hom q.mut)] - :: - -Wrap tape in `\/` if it doesn't fit at current indentation. Internal to -`++win` - -### `++wig` - -`++win` render tape - - ++ wig - |= hom=tape - ^- wall - ?~ lug - (rig hom) - =+ lin=(lent hom) - =+ wug=:(add 1 tab lin) - ?. =+ mir=i.lug - |- ?~ mir - | - ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug)))) - (rig hom) :: ^ XX regular form? - [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug] - -- - -- - -Render tape. Internal to `++win`. diff --git a/web/docs/dev/hoon/library/2el.md b/web/docs/dev/hoon/library/2el.md deleted file mode 100644 index 4a001e2b8..000000000 --- a/web/docs/dev/hoon/library/2el.md +++ /dev/null @@ -1,1871 +0,0 @@ -section 2eL, formatting (path) -============================== - -### `++ab` - -Primitive parser engine - - ++ ab - |% - -A core containing numeric parser primitives. - - ~zod/try=> ab - <36.ecc 414.gly 100.xkc 1.ypj %164> - ------------------------------------------------------------------------- - -### `++bix` - -Parse hex pair - - ++ bix (bass 16 (stun [2 2] six)) - -Parsing rule. Parses a pair of base-16 digits. Used in escapes. - - ~zod/try=> (scan "07" bix:ab) - q=7 - ~zod/try=> (scan "51" bix:ab) - q=81 - ~zod/try=> (scan "a3" bix:ab) - q=163 - ------------------------------------------------------------------------- - -### `++hif` - -Parse phonetic pair - - ++ hif (boss 256 ;~(plug tip tiq (easy ~))) - -Parsing rule. Parses an atom of odor [`@pE`](), a phrase of two bytes -encoded phonetically. - - ~zod/try=> (scan "doznec" hif:ab) - q=256 - ~zod/try=> (scan "pittyp" hif:ab) - q=48.626 - ------------------------------------------------------------------------- - -### `++huf` - -Parse two phonetic pairs - - ++ huf %+ cook - |=([a=@ b=@] (wred:un ~(zug mu ~(zag mu [a b])))) - ;~(plug hif ;~(pfix hep hif)) - -Parsing rule. Parses and unscrambles an atom of odor [@pF](), a phrase -of two two-byte pairs that are encoded (and scrambled) phonetically. - - ~zod/try=> (scan "pittyp-pittyp" huf:ab) - 328.203.557 - ~zod/try=> (scan "tasfyn-partyv" huf:ab) - 65.792 - ~zod/try=> `@ux`(scan "tasfyn-partyv" huf:ab) - 0x1.0100 - ------------------------------------------------------------------------- - -### `++hyf` - -Parse 8 phonetic bytes - - ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~))) - -Parsing rule. Parses an atom of odor [@pG](), a phrase of eight of -phonetic bytes. - - ~zod/try=> (scan "sondel-forsut-tillyn-nillyt" hyf:ab) - q=365.637.097.828.335.095 - ~zod/try=> `@u`~sondel-forsut-tillyn-nillyt - 365.637.097.828.335.095 - ------------------------------------------------------------------------- - -### `++pev` - -Parse \<= 5 base-32 - - ++ pev (bass 32 ;~(plug sev (stun [0 4] siv))) - -Parsing rule. Parses up to five base-32 digits without a leading zero. - - ~zod/try=> (scan "a" pev:ab) - q=10 - ~zod/try=> (scan "290j" pev:ab) - q=74.771 - ~zod/try=> (scan "123456" pev:ab) - ! {1 6} - ! exit - ~zod/try=> (scan "090j" pev:ab) - ~ - ------------------------------------------------------------------------- - -### `++pew` - -Parse \<= 5 base-64 - - ++ pew (bass 64 ;~(plug sew (stun [0 4] siw))) - -Parsing rule. Parses up to five base-64 digits without a leading zero. - - ~zod/try=> (scan "Q" pew:ab) - q=52 - ~zod/try=> (scan "aQ~9" pew:ab) - q=2.838.473 - ~zod/try=> `@`0waQ~9 - 2.838.473 - ~zod/try=> (scan "123456" pew:ab) - ! {1 6} - ! exit - ~zod/try=> (scan "012345" pew:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++piv` - -Parse 5 base-32 - - ++ piv (bass 32 (stun [5 5] siv)) - -Parsing rule. Parses exactly five base-32 digits. - - ~zod/try=> (scan "10b3l" piv:ab) - q=1.059.957 - ~zod/try=> (scan "1" piv:ab) - ! {1 2} - ! exit - ------------------------------------------------------------------------- - -### `++piw` - -Parse 5 base-64 - - ++ piw (bass 64 (stun [5 5] siw)) - -Parsing rule. Parses exactly five base-64 digits. - - ~zod/try=> (scan "2C-pZ" piw:ab) - q=43.771.517 - ~zod/try=> (scan "2" piv:ab) - ! {1 2} - ! exit - ------------------------------------------------------------------------- - -### `++qeb` - -Parse \<= 4 binary - - ++ qeb (bass 2 ;~(plug seb (stun [0 3] sib))) - -Parsing rule. Parses a binary number of up to 4 digits in length without -a leading zero. - - ~zod/try=> (scan "1" qeb:ab) - q=1 - ~zod/try=> (scan "101" qeb:ab) - q=5 - ~zod/try=> (scan "1111" qeb:ab) - q=15 - ~zod/try=> (scan "11111" qeb:ab) - ! {1 5} - ! exit - ~zod/try=> (scan "01" qeb:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++qex` - -Parse \<= 4 hex - - ++ qex (bass 16 ;~(plug sex (stun [0 3] hit))) - -Parsing rule. Parses a hexadecimal number of up to 4 digits in length -without a leading zero. - - ~zod/try=> (scan "ca" qex:ab) - q=202 - ~zod/try=> (scan "18ac" qex:ab) - q=6.316 - ~zod/try=> (scan "18acc" qex:ab) - ! {1 5} - ! exit - ~zod/try=> (scan "08ac" qex:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++qib` - -Parse 4 binary - - ++ qib (bass 2 (stun [4 4] sib)) - -Parsing rule. Parses exactly four binary digits. - - ~zod/try=> (scan "0001" qib:ab) - q=1 - ~zod/try=> (scan "0100" qib:ab) - q=4 - ~zod/try=> (scan "110" qib:ab) - ! {1 4} - ! exit - ------------------------------------------------------------------------- - -### `++qix` - -Parse 4 hex - - ++ qix (bass 16 (stun [4 4] six)) - -Parsing rule. Parses exactly four hexadecimal digits. - - ~zod/try=> (scan "0100" qix:ab) - q=256 - ~zod/try=> (scan "10ff" qix:ab) - q=4.351 - ~zod/try=> (scan "0" qix:ab) - ! {1 2} - ! exit - ------------------------------------------------------------------------- - -### `++seb` - -Parse 1 - - ++ seb (cold 1 (just '1')) - -Parsing rule. Parses the number 1. - - ~zod/try=> (scan "1" seb:ab) - 1 - ~zod/try=> (scan "0" seb:ab) - ! ~zod/try/~2014.10.23..22.34.21..bfdd/:<[1 1].[1 18]> - ! {1 1} - ~zod/try=> (scan "2" seb:ab) - ! ~zod/try/~2014.10.23..22.34.29..d399/:<[1 1].[1 18]> - ! {1 1} - ------------------------------------------------------------------------- - -### `++sed` - -Parse decimal - - ++ sed (cook |=(a=@ (sub a '0')) (shim '1' '9')) - -Parsing rule. Parses a nonzero decimal digit. - - ~zod/try=> (scan "5" sed:ab) - 5 - ~zod/try=> (scan "0" sed:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sev` - -Parse base-32 - - ++ sev ;~(pose sed sov) - -Parsing rule. Parses a nonzero base-32 digit - - ~zod/try=> (scan "c" sev:ab) - 12 - ~zod/socialnet=> (scan "0" sev:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sew` - -Parse base-64 - - ++ sew ;~(pose sed sow) - -Parsing rule. Parses a nonzero base-64 digit - - ~zod/try=> (scan "M" sew:ab) - 48 - ~zod/try=> (scan "0" sew:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sex` - -Parse hex - - ++ sex ;~(pose sed sox) - -Parsing rule. Parses a nonzero hexadecimal digit. - - ~zod/try=> (scan "e" sex:ab) - 14 - ~zod/try=> (scan "0" sex:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++sib` - -Parse binary - - ++ sib (cook |=(a=@ (sub a '0')) (shim '0' '1')) - -Parsing rule. Parses a binary digit. - - ~zod/try=> (scan "1" sib:ab) - 1 - ~zod/socialnet=> (scan "0" sib:ab) - 0 - ------------------------------------------------------------------------- - -### `++sid` - -Parse decimal - - ++ sid (cook |=(a=@ (sub a '0')) (shim '0' '9')) - -Parsing rule. Parses a decimal digit. - - ~zod/try=> (scan "5" sid:ab) - 5 - ------------------------------------------------------------------------- - -### `++siv` - -Parse base-32 - - ++ siv ;~(pose sid sov) - -Parsing rule. Parses a base-32 digit. - - ~zod/try=> (scan "c" siv:ab) - 12 - ------------------------------------------------------------------------- - -### `++siw` - -Parse base-64 - - ++ siw ;~(pose sid sow) - -Parsing rule. Parses a base-64 digit. - - ~zod/try=> (scan "M" siw:ab) - 48 - ------------------------------------------------------------------------- - -### `++six` - -Parse hex - - ++ six ;~(pose sid sox) - -Parsing rule. Parses a hexadecimal digit. - - ~zod/try=> (scan "e" six:ab) - 14 - ------------------------------------------------------------------------- - -### `++sov` - -Parse base-32 - - ++ sov (cook |=(a=@ (sub a 87)) (shim 'a' 'v')) - -Parsing rule. Parses a base-32 letter. - - ~zod/try=> (scan "c" sov:ab) - 12 - ------------------------------------------------------------------------- - -### `++sow` - -Parse base-64 - - ++ sow ;~ pose - (cook |=(a=@ (sub a 87)) (shim 'a' 'z')) - (cook |=(a=@ (sub a 29)) (shim 'A' 'Z')) - (cold 62 (just '-')) - (cold 63 (just '~')) - == - -Parsing rule. Parses a base-64 letter/symbol. - - ~zod/try=> (scan "M" sow:ab) - 48 - ------------------------------------------------------------------------- - -### `++sox` - -Parse hex letter - - ++ sox (cook |=(a=@ (sub a 87)) (shim 'a' 'f')) - -Parsing rule. Parses a hexadecimal letter. - - ~zod/try=> (scan "e" sox:ab) - 14 - ------------------------------------------------------------------------- - -### `++ted` - -Parse \<= 3 decimal - - ++ ted (bass 10 ;~(plug sed (stun [0 2] sid))) - -Parsing rule. Parses a decimal number of up to 3 digits without a -leading zero. - - ~zod/try=> (scan "21" ted:ab) - q=21 - ~zod/try=> (scan "214" ted:ab) - q=214 - ~zod/try=> (scan "2140" ted:ab) - {1 4} - ~zod/try=> (scan "0" ted:ab) - ! {1 1} - ! exit - ------------------------------------------------------------------------- - -### `++tip` - -Leading phonetic byte - - ++ tip (sear |=(a=@ (ins:po a)) til) - -Parsing rule. Parses the leading phonetic byte, which represents a -syllable. - - ~zod/try=> (scan "doz" tip:ab) - 0 - ~zod/try=> (scan "pit" tip:ab) - 242 - ------------------------------------------------------------------------- - -### `++tiq` - -Trailing phonetic syllable - - ++ tiq (sear |=(a=@ (ind:po a)) til) - -Parsing rule. Parses the trailing phonetic byte, which represents a -syllable. - - ~zod/try=> (scan "zod" tiq:ab) - 0 - ~zod/try=> (scan "nec" tiq:ab) - 1 - ------------------------------------------------------------------------- - -### `++tid` - -Parse 3 decimal digits - - ++ tid (bass 10 (stun [3 3] sid)) - -Parsing rule. Parses exactly three decimal digits. - - ~zod/try=> (scan "013" tid:ab) - q=13 - ~zod/try=> (scan "01" tid:ab) - ! {1 3} - ! exit - ------------------------------------------------------------------------- - -### `++til` - -Parse 3 lowercase - - ++ til (boss 256 (stun [3 3] low)) - -Parsing rule. Parses exactly three lowercase letters. - - ~zod/try=> (scan "mer" til:ab) - q=7.497.069 - ~zod/try=> `@t`(scan "mer" til:ab) - 'mer' - ~zod/try=> (scan "me" til:ab) - ! {1 3} - ! exit - ------------------------------------------------------------------------- - -### `++urs` - -Parse span characters - - ++ urs %+ cook - |=(a=tape (rap 3 ^-((list ,@) a))) - (star ;~(pose nud low hep dot sig cab)) - -Parsing rule. Parses characters from an atom of the span odor [`@ta`](). - - ~zod/try=> `@ta`(scan "asa-lom_tak" urs:ab) - ~.asa-lom_tak - ~zod/try=> `@t`(scan "asa-lom_tak" urs:ab) - 'asa-lom_tak' - ------------------------------------------------------------------------- - -### `++urt` - -Parse non-`_` span - - ++ urt %+ cook - |=(a=tape (rap 3 ^-((list ,@) a))) - (star ;~(pose nud low hep dot sig)) - -Parsing rule. Parses all characters of the span odor [`@ta`]() except -for cab, `_`. - - ~zod/try=> `@t`(scan "asa-lom.t0k" urt:ab) - 'asa-lom.t0k' - ------------------------------------------------------------------------- - -### `++voy` - -Parse bas, soq, or bix - - ++ voy ;~(pfix bas ;~(pose bas soq bix)) - -Parsing rule. Parses an escaped backslash, single quote, or hex pair -byte. - - ~zod/try=> (scan "\\0a" voy:ab) - q=10 - ~zod/try=> (scan "\\'" voy:ab) - q=39 - ------------------------------------------------------------------------- - -### `++ag` - -Top-level atom parser engine - - ++ ag - |% - -A core containing top-level atom parsers. - - ~zod/try=> ag - <14.vpu 414.mof 100.xkc 1.ypj %164> - ------------------------------------------------------------------------- - -### `++ape` - -Parse 0 or rule - - ++ ape |*(fel=_rule ;~(pose (cold 0 (just '0')) fel)) - -Parser modifier. Parses 0 or the sample rule `fel`. - -`fel` is a [`rule`](). - - ~zod/try=> (scan "202" (star (ape:ag (cold 2 (just '2'))))) - ~[2 0 2] - ------------------------------------------------------------------------- - -### `++bay` - -Parses binary number - - ++ bay (ape (bass 16 ;~(plug qeb:ab (star ;~(pfix dog qib:ab))))) - -Parsing rule. Parses a binary number without a leading zero. - - ~zod/try=> (scan "10.0110" bay:ag) - q=38 - ------------------------------------------------------------------------- - -### `++bip` - -Parse IPv6 - - ++ bip =+ tod=(ape qex:ab) - (bass 0x1.0000 ;~(plug tod (stun [7 7] ;~(pfix dog tod)))) - -Parsing rule. Parses a [`@is`](), an IPv6 address. - - ~zod/try=> (scan "0.0.ea.3e6c.0.0.0.0" bip:ag) - q=283.183.420.760.121.105.516.068.864 - ~zod/try=> `@is`(scan "0.0.ea.3e6c.0.0.0.0" bip:ag) - .0.0.ea.3e6c.0.0.0.0 - ------------------------------------------------------------------------- - -### `++dem` - -Parse decimal with dots - - ++ dem (ape (bass 1.000 ;~(plug ted:ab (star ;~(pfix dog tid:ab))))) - -Parsing rule. Parses a decimal number that includes dot separators. - - ~zod/try=> (scan "52" dem:ag) - q=52 - ~zod/try=> (scan "13.507" dem:ag) - q=13.507 - ------------------------------------------------------------------------- - -### `++dim` - -Parse decimal number - - ++ dim (ape (bass 10 ;~(plug sed:ab (star sid:ab)))) - -Parsing rule. Parses a decimal number without a leading zero. - - ~zod/try=> (scan "52" dim:ag) - q=52 - ~zod/try=> (scan "013507" dim:ag) - ! {1 2} - ! exit - ------------------------------------------------------------------------- - -### `++dum` - -Parse decimal with leading `0` - - ++ dum (bass 10 (plus sid:ab)) - -Parsing rule. Parses a decmial number with leading zeroes. - - ~zod/try=> (scan "52" dum:ag) - q=52 - ~zod/try=> (scan "0000052" dum:ag) - q=52 - ~zod/try=> (scan "13507" dim:ag) - q=13.507 - ------------------------------------------------------------------------- - -### `++fed` - -Parse phonetic base - - ++ fed ;~ pose - (bass 0x1.0000.0000.0000.0000 (most doh hyf:ab)) - huf:ab - hif:ab - tiq:ab - == - -Parsing rule. Parses an atom of odor [`@p`](), the phonetic base. - - ~zod/try=> (scan "zod" fed:ag) - 0 - ~zod/try=> (scan "nec" fed:ag) - 1 - ~zod/try=> (scan "sondel" fed:ag) - 9.636 - ~zod/try=> ~tillyn-nillyt - ~tillyn-nillyt - ~zod/try=> (scan "tillyn-nillyt" fed:ag) - 3.569.565.175 - ~zod/try=> (scan "tillyn-nillyt-tasfyn-partyv" fed:ag) - 15.331.165.687.565.582.592 - ~zod/try=> (scan "tillyn-nillyt-tasfyn-partyv--novweb-talrud-talmud-sonfyr" fed:ag) - 282.810.089.790.159.633.869.501.053.313.363.681.181 - ------------------------------------------------------------------------- - -### `++hex` - -Parse hex - - ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab))))) - -Parsing rule. Parses a hexadecimal number - - ~zod/try=> (scan "4" hex:ag) - q=4 - ~zod/try=> (scan "1a" hex:ag) - q=26 - ~zod/try=> (scan "3.ac8d" hex:ag) - q=240.781 - ~zod/try=> `@ux`(scan "3.ac8d" hex:ag) - 0x3.ac8d - ------------------------------------------------------------------------- - -### `++lip` - -Parse IPv4 address - - ++ lip =+ tod=(ape ted:ab) - (bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod)))) - -Parsing rule. Parses an IPv4 address. - - ~zod/try=> (scan "127.0.0.1" lip:ag) - q=2.130.706.433 - ~zod/try=> `@if`(scan "127.0.0.1" lip:ag) - .127.0.0.1 - ~zod/try=> `@if`(scan "8.8.8.8" lip:ag) - .8.8.8.8 - ------------------------------------------------------------------------- - -### `++viz` - -Parse Base-32 with dots - - ++ viz (ape (bass 0x200.0000 ;~(plug pev:ab (star ;~(pfix dog piv:ab))))) - -Parsing rule. Parses a Base-32 number with dot separators. - - ~zod/try=> (scan "e2.ol4pm" viz:ag) - q=15.125.353.270 - ------------------------------------------------------------------------- - -### `++vum` - -Parse base-32 string - - ++ vum (bass 32 (plus siv:ab)) - -Parsing rule. Parses a raw base-32 string. - - ~zod/try=> (scan "e2ol4pm" vum:ag) - q=15.125.353.270 - ------------------------------------------------------------------------- - -### `++wiz` - -Parse base-64 - - ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab))))) - -- - :: - -Parsing rule. Parses a base-64 number. - - ~zod/try=> (scan "e2O.l4Xpm" wiz:ag) - q=61.764.130.813.526 - ------------------------------------------------------------------------- - -### `++co` - -Literal rendering engine - - ++ co - =< |_ lot=coin - -A [door]() that contains arms that operate on the sample coin `lot`. - -`lot` is a [`++coin`](). - - ~zod/try=> ~(. co many/~[`ta/'mo' `ud/5]) - < 3.dhd - [ [ %many - [%~ %ta @t] - [%~ %ud @ud] - %~ - ] - <10.utz 3.zid [rex="" <414.hmb 100.xkc 1.ypj %164>]> - ] - > - ------------------------------------------------------------------------- - -### `++rear` - -Prepend & render as tape - - ++ rear |=(rom=tape =>(.(rex rom) rend)) - -Renders a coin `lot` as a [tape]() prepended to the sample tape `rom`. - -`rom` is a [`pe`]() - -`lot` is a [`++coin`](). - - ~zod/try=> (~(rear co %$ %ux 200) "--ha") - "0xc8--ha" - ------------------------------------------------------------------------- - -### `++rent` - -Render as span - - ++ rent `@ta`(rap 3 rend) - -Renders a coin `lot` as a span. - -`lot` is a [`++coin`](). - - ~zod/try=> ~(rent co %$ %ux 200) - ~.0xc8 - ~zod/try=> `@t`~(rent co %$ %ux 200) - '0xc8' - ------------------------------------------------------------------------- - -### `++rend` - -Render as tape - - ++ rend - ^- tape - ?: ?=(%blob -.lot) - ['~' '0' ((v-co 1) (jam p.lot))] - ?: ?=(%many -.lot) - :- '.' - |- ^- tape - ?~ p.lot - ['_' '_' rex] - ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))] - =+ [yed=(end 3 1 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] - |- ^- tape - ?+ yed (z-co q.p.lot) - %c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rex)] - %d - ?+ hay (z-co q.p.lot) - %a - =+ yod=(yore q.p.lot) - => ^+(. .(rex ?~(f.t.yod rex ['.' (s-co f.t.yod)]))) - => ^+ . - %= . - rex - ?: &(=(~ f.t.yod) =(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) - rex - => .(rex ['.' (y-co s.t.yod)]) - => .(rex ['.' (y-co m.t.yod)]) - ['.' '.' (y-co h.t.yod)] - == - => .(rex ['.' (a-co d.t.yod)]) - => .(rex ['.' (a-co m.yod)]) - => .(rex ?:(a.yod rex ['-' rex])) - ['~' (a-co y.yod)] - :: - %r - =+ yug=(yell q.p.lot) - => ^+(. .(rex ?~(f.yug rex ['.' (s-co f.yug)]))) - :- '~' - ?: &(=(0 d.yug) =(0 m.yug) =(0 h.yug) =(0 s.yug)) - ['.' 's' '0' rex] - => ^+(. ?:(=(0 s.yug) . .(rex ['.' 's' (a-co s.yug)]))) - => ^+(. ?:(=(0 m.yug) . .(rex ['.' 'm' (a-co m.yug)]))) - => ^+(. ?:(=(0 h.yug) . .(rex ['.' 'h' (a-co h.yug)]))) - => ^+(. ?:(=(0 d.yug) . .(rex ['.' 'd' (a-co d.yug)]))) - +.rex - == - :: - %f - ?: =(& q.p.lot) - ['.' 'y' rex] - ?:(=(| q.p.lot) ['.' 'n' rex] (z-co q.p.lot)) - :: - %n ['~' rex] - %i - ?+ hay (z-co q.p.lot) - %f ((ro-co [3 10 4] |=(a=@ ~(d ne a))) q.p.lot) - %s ((ro-co [4 16 8] |=(a=@ ~(x ne a))) q.p.lot) - == - :: - %p - =+ dyx=(met 3 q.p.lot) - :- '~' - ?: (lte dyx 1) - (weld (trip (tod:po q.p.lot)) rex) - ?: =(2 dyx) - ;: weld - (trip (tos:po (end 3 1 q.p.lot))) - (trip (tod:po (rsh 3 1 q.p.lot))) - rex - == - =+ [dyz=(met 5 q.p.lot) fin=|] - |- ^- tape - ?: =(0 dyz) - rex - %= $ - fin & - dyz (dec dyz) - q.p.lot (rsh 5 1 q.p.lot) - rex - =+ syb=(wren:un (end 5 1 q.p.lot)) - =+ cog=~(zig mu [(rsh 4 1 syb) (end 4 1 syb)]) - ;: weld - (trip (tos:po (end 3 1 p.cog))) - (trip (tod:po (rsh 3 1 p.cog))) - `tape`['-' ~] - (trip (tos:po (end 3 1 q.cog))) - (trip (tod:po (rsh 3 1 q.cog))) - `tape`?:(fin ['-' ?:(=(1 (end 0 1 dyz)) ~ ['-' ~])] ~) - rex - == - == - :: - %r - ?+ hay (z-co q.p.lot) - %d - =+ r=(rlyd q.p.lot) - ?~ e.r - ['.' '~' (r-co r)] - ['.' '~' u.e.r] - %h ['.' '~' '~' (r-co (rlyh q.p.lot))] - %q ['.' '~' '~' '~' (r-co (rlyq q.p.lot))] - %s ['.' (r-co (rlys q.p.lot))] - == - :: - %u - =- (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam)) - ^= gam ^- [p=tape q=tape] - ?+ hay [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)] - %b [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)] - %i [['0' 'i' ~] ((d-co 1) q.p.lot)] - %x [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)] - %v [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)] - %w [['0' 'w' ~] ((ox-co [64 5] |=(a=@ ~(w ne a))) q.p.lot)] - == - :: - %s - %+ weld - ?:((syn:si q.p.lot) "--" "-") - $(yed 'u', q.p.lot (abs:si q.p.lot)) - :: - %t - ?: =('a' hay) - ?: =('s' (cut 3 [2 1] p.p.lot)) - - (weld (rip 3 q.p.lot) rex) - ['~' '.' (weld (rip 3 q.p.lot) rex)] - ['~' '~' (weld (rip 3 (wood q.p.lot)) rex)] - == - -- - =+ rex=*tape - =< |% - ++ a-co |=(dat=@ ((d-co 1) dat)) - ++ d-co |=(min=@ (em-co [10 min] |=([? b=@ c=tape] [~(d ne b) c]))) - ++ r-co - |= [syn=? nub=@ der=@ ign=(unit tape) ne=?] - => .(rex ['.' (t-co ((d-co 1) der) ne)]) - => .(rex ((d-co 1) nub)) - ?:(syn rex ['-' rex]) - ++ t-co |= [a=tape n=?] ^- tape - ?: n a - ?~ a ~|(%empty-frac !!) t.a - :: - ++ s-co - |= esc=(list ,@) ^- tape - ~| [%so-co esc] - ?~ esc - rex - :- '.' - =>(.(rex $(esc t.esc)) ((x-co 4) i.esc)) - - :: - ++ v-co |=(min=@ (em-co [32 min] |=([? b=@ c=tape] [~(v ne b) c]))) - ++ w-co |=(min=@ (em-co [64 min] |=([? b=@ c=tape] [~(w ne b) c]))) - ++ x-co |=(min=@ (em-co [16 min] |=([? b=@ c=tape] [~(x ne b) c]))) - ++ y-co |=(dat=@ ((d-co 2) dat)) - ++ z-co |=(dat=@ `tape`['0' 'x' ((x-co 1) dat)]) - -- - ~% %co +> ~ - |% - ++ em-co - ~/ %emco - |= [[bas=@ min=@] [par=$+([? @ tape] tape)]] - |= hol=@ - ^- tape - ?: &(=(0 hol) =(0 min)) - rex - =+ [rad=(mod hol bas) dar=(div hol bas)] - %= $ - min ?:(=(0 min) 0 (dec min)) - hol dar - rex (par =(0 dar) rad rex) - == - :: - ++ ox-co - ~/ %oxco - |= [[bas=@ gop=@] dug=$+(@ @)] - %+ em-co - [|-(?:(=(0 gop) 1 (mul bas $(gop (dec gop))))) 0] - |= [top=? seg=@ res=tape] - %+ weld - ?:(top ~ `tape`['.' ~]) - %. seg - %+ em-co(rex res) - [bas ?:(top 0 gop)] - |=([? b=@ c=tape] [(dug b) c]) - :: - ++ ro-co - ~/ %roco - |= [[buz=@ bas=@ dop=@] dug=$+(@ @)] - |= hol=@ - ^- tape - ?: =(0 dop) - rex - => .(rex $(dop (dec dop))) - :- '.' - %- (em-co [bas 1] |=([? b=@ c=tape] [(dug b) c])) - [(cut buz [(dec dop) 1] hol)] - -- - :: - -Renders a coin `lot` as a tape. - -`lot` is a [`++coin`](). - - ~zod/try=> ~(rend co ~ %ux 200) - "0xc8" - ~zod/try=> ~(rend co %many ~[[%$ ux/200] [%$ p/40]]) - "._0xc8_~~tem__" - ~zod/try=> ~(rend co ~ %p 32.819) - "~pillyt" - ~zod/try=> ~(rend co ~ %ux 18) - "0x12" - ~zod/try=> ~(rend co [~ p=[p=%if q=0x7f00.0001]]) - ".127.0.0.1" - ~zod/try=> `@ux`.127.0.0.1 - 2.130.706.433 - ~zod/try=> ~(rend co %many ~[[~ %ud 20] [~ %uw 133] [~ %tas 'sam']]) - "._20_0w25_sam__" - ~zod/try=> ~(rend co %blob [1 1]) - "~0ph" - ~zod/try=> ~0ph - [1 1] - ~zod/try=> `@uv`(jam [1 1]) - 0vph - ------------------------------------------------------------------------- - -### `++ne` - -Digit rendering engine - - ++ ne - |_ tig=@ - -A [door]() containing arms that render digits at bases 10, 16, 32, and -64. - -`tig` is an [`atom`](). - - ~zod/try=> ~(. ne 20) - <4.gut [@ud <414.hhh 100.xkc 1.ypj %164>]> - ------------------------------------------------------------------------- - -### `++d` - -Render decimal - - ++ d (add tig '0') - -Renders a decimal digit as an atom of an ACII byte value. - -`tig` is an [`atom`](). - - ~zod/try=> `@t`~(d ne 7) - '7' - ------------------------------------------------------------------------- - -### `++x` - -Render hex - - ++ x ?:((gte tig 10) (add tig 87) d) - -Renders a hexadecimal digit as an atom of an ASCII byte value. - -`tig` is an [`atom`](). - - ~zod/try=> `@t`~(x ne 7) - '7' - ~zod/try=> `@t`~(x ne 14) - 'e' - ------------------------------------------------------------------------- - -### `++v` - -Render base-32 - - ++ v ?:((gte tig 10) (add tig 87) d) - -Renders a base-32 digit as an atom of an ASCII byte value. - - ~zod/try=> `@t`~(v ne 7) - '7' - ~zod/try=> `@t`~(v ne 14) - 'e' - ~zod/try=> `@t`~(v ne 25) - 'p' - ------------------------------------------------------------------------- - -### `++w` - -Render base-64 - - ++ w ?:(=(tig 63) '~' ?:(=(tig 62) '-' ?:((gte tig 36) (add tig 29) x))) - -- - :: - -Renders a base-64 digit as an atom of an ASCII byte value. - -`tig` is an [`atom`](). - - ~zod/try=> `@t`~(w ne 7) - '7' - ~zod/try=> `@t`~(w ne 14) - 'e' - ~zod/try=> `@t`~(w ne 25) - 'p' - ~zod/try=> `@t`~(w ne 52) - 'Q' - ~zod/try=> `@t`~(w ne 61) - 'Z' - ~zod/try=> `@t`~(w ne 63) - '~' - ~zod/try=> `@t`~(w ne 62) - '-' - ------------------------------------------------------------------------- - -### `++mu` - -Core used to scramble 16-bit atoms - - ++ mu - |_ [top=@ bot=@] - -A [door]() that contains arms that are used to scramble two atoms, `top` -and `bot`. Used especially in the phonetic base to disguise the -relationship between a destroyer and its cruiser. - -`bot` is an [atom](). - -`top` is an [atom](). - - ~zod/try=> ~(. mu 0x20e5 0x5901) - <3.sjm [[@ux @ux] <414.hhh 100.xkc 1.ypj %164>]> - ------------------------------------------------------------------------- - -### `++zag` - -Add bottom into top - - ++ zag [p=(end 4 1 (add top bot)) q=bot] - -Produces the cell of `top` and `bot` with `top` scrambled to the result -of adding `bot` to `top` modulo 16. Used to scramble the name of a -destroyer. - -`bot` is an [atom](). - -`top` is an [atom](). - - ~zod/try=> `[@ux @ux]`~(zag mu 0x20e0 0x201) - [0x22e1 0x201] - ------------------------------------------------------------------------- - -### `++zig` - -Subtract bottom from top - - ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] - -The inverse of [`++zag`](). Produces the cell of `top` and `bot` with -`top` unscrambled. The unscrambled `top` is the sum of the sample `top` -and the 16-bit complement of `bot`. Used to unscramble the name of the -destroyer. - -`bot` is an [atom](). - -`top` is an [atom](). - - ~zod/try=> `[@ux @ux]`~(zig mu 0x2f46 0x1042) - [0x1f04 0x1042] - ------------------------------------------------------------------------- - -### `++zug` - -Concatenate into atom - - ++ zug (mix (lsh 4 1 top) bot) - -Produces the concatenation of `top` and `bot`. Used to assemble a -destroyer name. - -`bot` is an [atom](). - -`top` is an [atom](). - - ~zod/try=> `@ux`~(zug mu 0x10e1 0xfa) - 0x10e1.00fa - ------------------------------------------------------------------------- - -### `++so` - -Coin parser engine - - ++ so - |% - -Core containing arms that parse [`++coin`]s. - - ~zod/try=> so - <10.mkn 414.hhh 100.xkc 1.ypj %164> - ------------------------------------------------------------------------- - -### `++bisk` - -Parse odor-atom pair - - ++ bisk - ;~ pose - ;~ pfix (just '0') - ;~ pose - (stag %ub ;~(pfix (just 'b') bay:ag)) - (stag %ui ;~(pfix (just 'i') dim:ag)) - (stag %ux ;~(pfix (just 'x') hex:ag)) - (stag %uv ;~(pfix (just 'v') viz:ag)) - (stag %uw ;~(pfix (just 'w') wiz:ag)) - == - == - (stag %ud dem:ag) - == - -Parsing rule. Parses an unsigned integer of any permitted base, -producing a [`++dime`](). - - ~zod/try=> (scan "25" bisk:so) - [%ud q=25] - ~zod/try=> (scan "0x12.6401" bisk:so) - [%ux q=1.205.249] - ------------------------------------------------------------------------- - -### `++crub` - -Parse `@da`, `@dr`, `@p`, `@t` - - ++ crub - ;~ pose - %+ cook - |=(det=date `dime`[%da (year det)]) - ;~ plug - %+ cook - |=([a=@ b=?] [b a]) - ;~(plug dim:ag ;~(pose (cold | hep) (easy &))) - ;~(pfix dot dim:ag) :: month - ;~(pfix dot dim:ag) :: day - ;~ pose - ;~ pfix - ;~(plug dot dot) - ;~ plug - dum:ag - ;~(pfix dot dum:ag) - ;~(pfix dot dum:ag) - ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~)) - == - == - (easy [0 0 0 ~]) - == - == - :: - %+ cook - |= [a=(list ,[p=?(%d %h %m %s) q=@]) b=(list ,@)] - =+ rop=`tarp`[0 0 0 0 b] - |- ^- dime - ?~ a - [%dr (yule rop)] - ?- p.i.a - %d $(a t.a, d.rop (add q.i.a d.rop)) - %h $(a t.a, h.rop (add q.i.a h.rop)) - %m $(a t.a, m.rop (add q.i.a m.rop)) - %s $(a t.a, s.rop (add q.i.a s.rop)) - == - ;~ plug - %+ most - dot - ;~ pose - ;~(pfix (just 'd') (stag %d dim:ag)) - ;~(pfix (just 'h') (stag %h dim:ag)) - ;~(pfix (just 'm') (stag %m dim:ag)) - ;~(pfix (just 's') (stag %s dim:ag)) - == - ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~)) - == - :: - (stag %p fed:ag) - ;~(pfix dot (stag %ta urs:ab)) - ;~(pfix sig (stag %t (cook woad urs:ab))) - ;~(pfix hep (stag %c (cook turf (cook woad urs:ab)))) - == - -Parsing rule. Parses any atom of any of the following odors after a -leading sig, `~` into a [`++dime`](): [`@da`](), [`@dr`](), [`@p`](), -and [`@t`](), producing a [`++dime`](). - - ~zod/try=> (scan "1926.5.12" crub:so) - [p=~.da q=170.141.184.449.747.016.871.285.095.307.149.312.000] - ~zod/try=> (,[%da @da] (scan "1926.5.12" crub:so)) - [%da ~1926.5.12] - ~zod/try=> (scan "s10" crub:so) - [p=~.dr q=184.467.440.737.095.516.160] - ~zod/try=> (,[%dr @dr] (scan "s10" crub:so)) - [%dr ~s10] - ~zod/try=> (scan "doznec" crub:so) - [%p 256] - ~zod/try=> (scan ".mas" crub:so) - [%ta 7.561.581] - ------------------------------------------------------------------------- - -### `++nuck` - -Top-level coin parser - - ++ nuck - %+ knee *coin |. ~+ - %- stew - ^. stet ^. limo - :~ :- ['a' 'z'] (cook |=(a=@ta [~ %tas a]) sym) - :- ['0' '9'] (stag ~ bisk) - :- '-' (stag ~ tash) - :- '.' ;~(pfix dot perd) - :- '~' ;~(pfix sig ;~(pose twid (easy [~ %n 0]))) - == - -Parsing rule. Switches on the first character and applies the -corresponding [`++coin`]() parser. - - ~zod/try=> (scan "~pillyt" nuck:so) - [% p=[p=~.p q=32.819]] - ~zod/try=> (scan "0x12" nuck:so) - [% p=[p=~.ux q=18]] - ~zod/try=> (scan ".127.0.0.1" nuck:so) - [% p=[p=~.if q=2.130.706.433]] - ~zod/try=> `@ud`.127.0.0.1 - 2.130.706.433 - ~zod/try=> (scan "._20_0w25_sam__" nuck:so) - [ %many - p - ~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]] - ] - ~zod/try=> `@`%sam - 7.168.371 - ~zod/try=> (scan "~0ph" nuck:so) - [%blob p=[1 1]] - ~zod/try=> ~0ph - [1 1] - ~zod/try=> `@uv`(jam [1 1]) - 0vph - ------------------------------------------------------------------------- - -### `++nusk` - -Parse coin literal with escapes - - ++ nusk - (sear |=(a=@ta (rush (wick a) nuck)) urt:ab) - -Parsing rule. Parses a coin literal with escapes. (See also: xx tuple -formatting). - - ~zod/try=> ~.asd_a - ~.asd_a - ~zod/try=> ._1_~~.asd~-a__ - [1 ~.asd_a] - ~zod/try=> (scan "~~.asd~-a" nusk:so) - [% p=[p=~.ta q=418.212.246.369]] - ~zod/try=> (,[~ %ta @ta] (scan "~~.asd~-a" nusk:so)) - [~ %ta ~.asd_a] - ------------------------------------------------------------------------- - -### `++perd` - -Parsing rule. - - ++ perd - ;~ pose - (stag ~ zust) - (stag %many (ifix [cab ;~(plug cab cab)] (more cab nusk))) - == - -Parsing rule. Parses a dime or tuple without their respective standard -prefixes. - - ~zod/try=> (scan "y" perd:so) - [~ [%f %.y]] - ~zod/try=> (scan "n" perd:so) - [~ [%f %.n]] - ~zod/try=> | - %.n - ~zod/try=> (scan "_20_x__" perd:so) - [%many [[% p=[p=~.ud q=20]] ~[[% p=[p=~.tas q=120]]]]] - ------------------------------------------------------------------------- - -### `++royl` - -Parse dime float - - ++ royl - =+ ^= zer - (cook lent (star (just '0'))) - =+ ^= voy - %+ cook royl-cell - ;~ plug - ;~(pose (cold | hep) (easy &)) - ;~(plug dim:ag ;~(pose ;~(pfix dot ;~(plug zer dim:ag)) (easy [0 0]))) - ;~ pose - ;~ pfix - (just 'e') - (cook some ;~(plug ;~(pose (cold | hep) (easy &)) dim:ag)) - == - (easy ~) - == - == - ;~ pose - (stag %rh (cook rylh ;~(pfix ;~(plug sig sig) voy))) - (stag %rq (cook rylq ;~(pfix ;~(plug sig sig sig) voy))) - (stag %rd (cook ryld ;~(pfix sig voy))) - (stag %rs (cook ryls voy) - == - -Parsing rule. Parses a number into a [`++dime`]() float. - - ~zod/try=> (scan "~3.14" royl:so) - [%rd .~3.13999999999999] - ~zod/try=> .~3.14 - .~3.13999999999999 - ------------------------------------------------------------------------- - -### `++royl-cell` - -XX still not fully functional - - ++ royl-cell - |= [a=? b=[c=@ d=@ e=@] f=(unit ,[h=? i=@])] - ^- [? @ @ @ (unit ,@s)] - ?~ f - [a c.b d.b e.b ~] - ?: h.u.f - [a c.b d.b e.b [~ (mul i.u.f 2)]] - [a c.b d.b e.b [~ (dec (mul i.u.f 2))]] - -Intermediate parsed float convereter - ------------------------------------------------------------------------- - -### `++tash` - -Parse signed dime - - ++ tash - =+ ^= neg - |= [syn=? mol=dime] ^- dime - ?> =('u' (end 3 1 p.mol)) - [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] - ;~ pfix hep - ;~ pose - (cook |=(a=dime (neg | a)) bisk) - ;~(pfix hep (cook |=(a=dime (neg & a)) bisk)) - == - == - -Parsing rule. Parses a signed number into a [`++dime`](). - - ~zod/try=> (scan "-20" tash:so) - [p=~.sd q=39] - ~zod/try=> (,[%sd @sd] (scan "-20" tash:so)) - [%sd -20] - ~zod/try=> (,[%sd @sd] (scan "--20" tash:so)) - [%sd --20] - ~zod/try=> (,[%sx @sx] (scan "--0x2e" tash:so)) - [%sx --0x2e] - ------------------------------------------------------------------------- - -### `++twid` - -Parse coins without `~` prefix - - ++ twid - ;~ pose - (cook |=(a=@ [%blob (cue a)]) ;~(pfix (just '0') vum:ag)) - (stag ~ crub) - == - :: - -Parsing rule. Parses coins after a leading sig, `~`. - - ~zod/try=> (scan "zod" twid:so) - [~ [%p 0]] - ~zod/try=> (scan ".sam" twid:so) - [~ [%ta 7.168.371]] - ~zod/try=> `@ud`~.sam - 7.168.371 - ~zod/try=> `@t`~.sam - 'sam' - ~zod/try=> (scan "0ph" twid:so) - [%blob [1 1]] - ------------------------------------------------------------------------- - -### `++zust` - -Parse prefixed dimes from `@if`, `@f`, `@rd` - - ++ zust - ;~ pose - (stag %is bip:ag) - (stag %if lip:ag) - (stag %f ;~(pose (cold & (just 'y')) (cold | (just 'n')))) - royl - == - -- - -Parsing rule. Parses an atom of either [`@if`]() (IP address), [`@f`]() -(loobean), or [`rf`]()(floating point) into a [`++dime`](). - - ~zod/try=> (scan "127.0.0.1" zust:so) - [%if q=2.130.706.433] - ~zod/try=> (scan "af.0.0.0.0.e7a5.30d2.7" zust:so) - [%is q=908.651.950.243.594.834.993.091.554.288.205.831] - ~zod/try=> (,[%is @is] (scan "af.0.0.0.0.e7a5.30d2.7" zust:so)) - [%is .af.0.0.0.0.e7a5.30d2.7] - ~zod/try=> (,[%is @ux] (scan "af.0.0.0.0.e7a5.30d2.7" zust:so)) - [%is 0xaf.0000.0000.0000.0000.e7a5.30d2.0007] - ~zod/try=> (scan "y" zust:so) - [%f %.y] - ~zod/try=> (scan "12.09" zust:so) - [%rd .~12.00999999999999] - ------------------------------------------------------------------------- - -### `++scot` - -Render dime as cord - - ++ scot |=(mol=dime ~(rent co %$ mol)) - -Renders a dime `mol` as a cord. - -`mol` is a [`++dime`](). - - ~zod/try=> (scot %p ~pillyt) - ~.~pillyt - ~zod/try=> `@t`(scot %p ~pillyt) - '~pillyt' - ~zod/try=> (scot %ux 0x12) - ~.0x12 - ~zod/try=> `@t`(scot %ux 0x12) - '0x12' - ~zod/try=> (scot %if .127.0.0.1) - ~..127.0.0.1 - ~zod/try=> `@t`(scot %if .127.0.0.1) - '.127.0.0.1' - ~zod/try=> (scot %ta ~.asd_a) - ~.~.asd_a - ~zod/try=> `@t`(scot %ta ~.asd_a) - '~.asd_a' - ------------------------------------------------------------------------- - -### `++scow` - -Render dime as tape - - ++ scow |=(mol=dime ~(rend co %$ mol)) - -Renders `mol` as a tape. - -`mol` is a [`++dime`](). - - ~zod/try=> (scow %p ~pillyt) - "~pillyt" - ~zod/try=> (scow %ux 0x12) - "0x12" - ~zod/try=> (scow %if .127.0.0.1) - ".127.0.0.1" - ~zod/try=> (scow %ta ~.asd_a) - "~.asd_a" - ------------------------------------------------------------------------- - -### `++slat` - -Curried slaw - - ++ slat |=(mod=@tas |=(txt=@ta (slaw mod txt))) - -Produces a [`gate`]() that parses a [`term`]() `txt` to an atom of the -odor specified by `mod`. - -`mod` is a term, an atom of odor [`@tas`](). - -`txt` is a span, an atom of odor [`@ta`](). - - ~zod/try=> `(unit ,@p)`((slat %p) '~pillyt') - [~ ~pillyt] - ~zod/try=> `(unit ,@ux)`((slat %ux) '0x12') - [~ 0x12] - ~zod/try=> `(unit ,@if)`((slat %if) '.127.0.0.1') - [~ .127.0.0.1] - ~zod/try=> `(unit ,@ta)`((slat %ta) '~.asd_a') - [~ ~.asd_a - ------------------------------------------------------------------------- - -### `++slav` - -Demand: parse span with input odor - - ++ slav |=([mod=@tas txt=@ta] (need (slaw mod txt))) - -Parses a span `txt` to an atom of the odor specificed by `mod`. Crashes -if it failes to parse. - -`mod` is a term, an atom of odor [`@tas`](). - -`txt` is a span, an atom of odor [`@ta`](). - - ~zod/try=> `@p`(slav %p '~pillyt') - ~pillyt - ~zod/try=> `@p`(slav %p '~pillam') - ! exit - ~zod/try=> `@ux`(slav %ux '0x12') - 0x12 - ~zod/try=> `@ux`(slav %ux '0b10') - ! exit - ~zod/try=> `@if`(slav %if '.127.0.0.1') - .127.0.0.1 - ~zod/try=> `@if`(slav %if '.fe80.0.0.202') - ! exit - ~zod/try=> `@ta`(slav %ta '~.asd_a') - ~.asd_a - ~zod/try=> `@ta`(slav %ta '~~asd-a') - ! exit - ------------------------------------------------------------------------- - -### `++slaw` - -Parse span to input odor - - ++ slaw - |= [mod=@tas txt=@ta] - ^- (unit ,@) - =+ con=(slay txt) - ?.(&(?=([~ %$ @ @] con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) - :: - -Parses a span `txt` to an atom of the odor specified by `mod`. - -`mod` is a term, an atom of odor [`@tas`](). - -`txt` is a span, an atom of odor [`@ta`](). - - ~zod/try=> `(unit ,@p)`(slaw %p '~pillyt') - [~ ~pillyt] - ~zod/try=> `(unit ,@p)`(slaw %p '~pillam') - ~ - ~zod/try=> `(unit ,@ux)`(slaw %ux '0x12') - [~ 0x12] - ~zod/try=> `(unit ,@ux)`(slaw %ux '0b10') - ~ - ~zod/try=> `(unit ,@if)`(slaw %if '.127.0.0.1') - [~ .127.0.0.1] - ~zod/try=> `(unit ,@if)`(slaw %if '.fe80.0.0.202') - ~ - ~zod/try=> `(unit ,@ta)`(slaw %ta '~.asd_a') - [~ ~.asd_a] - ~zod/try=> `(unit ,@ta)`(slaw %ta '~~asd-a') - ~ - ------------------------------------------------------------------------- - -### `++slay` - -Parse span to coin - - ++ slay - |= txt=@ta ^- (unit coin) - =+ vex=((full nuck:so) [[1 1] (trip txt)]) - ?~ q.vex - ~ - [~ p.u.q.vex] - :: - -Parses a span `txt` to the unit of a [`++coin`](). - -`txt` is a [`@ta`](). - - ~zod/try=> (slay '~pillyt') - [~ [% p=[p=~.p q=32.819]]] - ~zod/try=> (slay '0x12') - [~ [% p=[p=~.ux q=18]]] - ~zod/try=> (slay '.127.0.0.1') - [~ [% p=[p=~.if q=2.130.706.433]]] - ~zod/try=> `@ud`.127.0.0.1 - 2.130.706.433 - ~zod/try=> (slay '._20_0w25_sam__') - [ ~ - [ %many - p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]] - ] - ] - ~zod/try=> `@`%sam - 7.168.371 - ~zod/try=> (slay '~0ph') - [~ [%blob p=[1 1]]] - ~zod/try=> 0ph - ~ - ~zod/try=> ~0ph - [1 1] - ~zod/try=> `@uv`(jam [1 1]) - 0vph - ------------------------------------------------------------------------- - ------------------------------------------------------------------------- - -### `++smyt` - -Render path as tank - - ++ smyt - |= bon=path ^- tank - :+ %rose [['/' ~] ['/' ~] ['/' ~]] - |- ^- (list tank) - (turn bon |=(a=@ [%leaf (rip 3 a)])) - -Renders the path `bon` as a [`tank`](), which is used for -pretty-printing. - -`bon` is a [`++path`](). - - ~zod/try=> (smyt %) - [ %rose - p=[p="/" q="/" r="/"] - q - ~[ [%leaf p="~zod"] - [%leaf p="try"] - [%leaf p="~2014.10.28..18.36.58..a280"] - ] - ] - ~zod/try=> (smyt /as/les/top) - [ %rose - p=[p="/" q="/" r="/"] - q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]] - ] - ------------------------------------------------------------------------- - -### `++spat` - -Render path as cord - - ++ spat |=(pax=path (crip (spud pax))) :: path to cord - -Renders a path `pax` as cord. - -`pax` is a [`path`](). - - ~zod/try=> (spat %) - '~zod/try/~2014.10.28..18.40.20..4287' - ~zod/try=> (spat %/bin) - '~zod/try/~2014.10.28..18.41.12..3bcd/bin' - ~zod/try=> (spat /as/les/top) - '/as/les/top' - ------------------------------------------------------------------------- - -### `++spud` - -Render path as tape - - ++ spud |=(pax=path ~(ram re (smyt pax))) :: path to tape - -Renders a path `pax` as [tape](). - -`pax` is a [`path`](). - - ~zod/try=> (spud %) - "~zod/try/~2014.10.28..18.40.46..e951" - ~zod/try=> (spud %/bin) - "~zod/try/~2014.10.28..18.41.05..16f2/bin" - ~zod/try=> (spud /as/les/top) - "/as/les/top" - ------------------------------------------------------------------------- - -### `++stab` - -Parse span to path - - ++ stab :: parse span to path - |= zep=@ta ^- path - (rash zep ;~(pfix fas ;~(sfix (more fas urs:ab) fas))) - -Parsing rule. Parses a span `zep` to a static [`++path`](/doc/hoon/library/1#++path). - - ~zod/try=> (stab '/as/lek/tor') - /as/lek/tor - ~zod/try=> `(pole ,@ta)`(stab '/as/lek/tor') - [~.as [~.lek [~.tor ~]]] - ~zod/try=> (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse') - ~zod/arvo/~2014.10.28..18.48.41..335f/zuse - ~zod/try=> `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse') - [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]] - ~zod/try=> (stab '/a/~pillyt/pals/1') - /a/~pillyt/pals/1 - ~zod/try=> `(pole ,@ta)`(stab '/a/~pillyt/pals/1') - [~.a [~.~pillyt [~.pals [~.1 ~]]]] diff --git a/web/docs/dev/hoon/library/2em.md b/web/docs/dev/hoon/library/2em.md deleted file mode 100644 index 5b0ea2802..000000000 --- a/web/docs/dev/hoon/library/2em.md +++ /dev/null @@ -1,758 +0,0 @@ -section 2eM, regular-expressions -================================ - -### `++pars` - - ++ pars - |= [a=tape] :: parse tape to rege - ^- (unit rege) - =+ foo=((full apex:rags) [[1 1] a]) - ?~ q.foo - ~ - [~ p.u.q.foo] - :: - -Parse regular expression - - ~zod/try=> (pars "samo") - [ ~ - [ %pair - p=[%lite p=~~s] - q=[%pair p=[%lite p=~~a] q=[%pair p=[%lite p=~~m] q=[%lite p=~~o]]] - ] - ] - ~zod/try=> (pars "so[,.0-9]") - [ ~ - [ %pair - p=[%lite p=~~s] - q=[%pair p=[%lite p=~~o] q=[%brac p=288.036.862.105.223.168]] - ] - ] - ~zod/try=> `@ub`288.036.862.105.223.168 - 0b11.1111.1111.0101.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 - ~zod/try=> `@ub`(lsh 0 `@`'9' 1) - 0b10.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 - ~zod/try=> `@ub`(roll (turn ",.0123456789" |=(a=@ (lsh 0 a 1))) con) - 0b11.1111.1111.0101.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 - ~zod/try=> (pars "sop.*") - [ ~ - [ %pair - p=[%lite p=~~s] - q=[%pair p=[%lite p=~~o] q=[%pair p=[%lite p=~~p] q=[%mant p=%dote]]] - ] - ] - ~zod/try=> (pars "(hel)?") - [ ~ - [ %eith - p - [ %capt - p=[%pair p=[%lite p=~~h] q=[%pair p=[%lite p=~~e] q=[%lite p=~~l]]] - q=0 - ] - q=%empt - ] - ] - ~zod/try=> (pars "(hel)??") - [ ~ - [ %eith - p=%empt - q - [ %capt - p=[%pair p=[%lite p=~~h] q=[%pair p=[%lite p=~~e] q=[%lite p=~~l]]] - q=0 - ] - ] - ] - ~zod/try=> (pars "a\{1,20}") - [~ [%betw p=[%lite p=~~a] q=1 r=20]] - -### `++rags` - - ++ rags :: rege parsers - => |% - -Regex parser arms - -### `++nor` - - ++ nor ;~(less (mask "^$()|*?+.[\\") (shim 1 127)) :: non-control char - -XX document - -### `++les` - - ++ les ;~(less bas asp) :: not backslash - -XX document - -### `++lep` - - ++ lep ;~(less (mask "^[]\\") asp) :: charset non-control - -XX document - -### `++asp` - - ++ asp (shim 32 126) :: printable ascii - -XX document - -### `++alb` - - ++ alb ;~(less ser asp) :: charset literal char - -XX document - -### `++mis` - - ++ mis ;~(less aln asp) :: non alphanumeric - -- - |% - -XX document - -### `++apex` - - ++ apex :: top level - %+ knee *rege |. ~+ - ;~ pose - ;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar apex)) - (stag %eith ;~(plug (easy %empt) ;~(pfix bar apex))) - (easy %empt) - == - :: - -XX document - -### `++mall` - - ++ mall - %+ knee *rege |. ~+ - ;~((bend |=(a=[rege rege] (some [%pair a]))) bets mall) - :: - -XX document - -### `++bets` - - ++ bets - %+ knee *rege |. ~+ - |= tub=nail - =+ vex=(chun tub) - ?~ q.vex - vex - =+ a=p.u.q.vex - %- ;~ pose - (cold [%eith %empt a] (jest '??')) - (cold [%manl a] (jest '*?')) - (cold [%plll a] (jest '+?')) - (cold [%eith a %empt] wut) - (cold [%mant a] tar) - (cold [%plls a] lus) - (stag %betl ;~(plug (easy a) ;~(sfix rang wut))) - (stag %betw ;~(plug (easy a) rang)) - (stag %binl ;~(plug (easy a) (ifix [kel (jest ',}?')] dim:ag))) - (stag %bant ;~(plug (easy a) (ifix [kel (jest '}?')] dim:ag))) - (stag %bant ;~(plug (easy a) (ifix [kel ker] dim:ag))) - (stag %bint ;~(plug (easy a) (ifix [kel (jest ',}')] dim:ag))) - (easy a) - == - q.u.q.vex - :: - -XX document - -### `++ranc` - - ++ ranc - |= [a=@ b=@] - ^- @ - ?:((gth a b) 0 (con (bex a) $(a +(a)))) - :: - -XX document - -### `++flap` - - ++ flap |=(a=@ (mix a (dec (bex 256)))) - :: - -XX document - -### `++rang` - - ++ rang - %+ sear |=([a=@ b=@] ?:((lte a b) (some [a b]) ~)) - (ifix [kel ker] ;~(plug dim:ag ;~(pfix com dim:ag))) - :: - -XX document - -### `++chun` - - ++ chun - %+ knee *rege |. ~+ - ;~ pose - (cold %ende buc) - (cold %sart ket) - (cold %dote dot) - %+ cook |=(a=(list char) (reel a |=([p=char q=rege] [%pair [%lite p] q]))) - ;~(pfix (jest '\\Q') cape) - |= tub=nail - =+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker))) - =+ bar=(foo tub) - ?~(q.bar (chad tub) (fail tub)) - (cook |=([a=rege] [%capt a 0]) (ifix [pel per] apex)) - %+ cook |=([a=rege] [%capt a 0]) - (ifix [;~(plug (jest '(?P<') (plus aln) gar) per] apex) - (ifix [(jest '(?:') per] apex) - (stag %brac ;~(pfix sel seac)) - == - :: - -XX document - -### `++seac` - - ++ seac - |= tub=nail - ?~ q.tub - (fail tub) - ?: =(i.q.tub '^') - (;~(pfix ket (cook flap sead)) tub) - (sead tub) - :: - -XX document - -### `++sead` - - ++ sead - %+ knee *@ |. ~+ - ;~ pose - |= tub=nail - ?~ q.tub - (fail tub) - ?. =(i.q.tub ']') - (fail tub) - ?~ t.q.tub - (fail tub) - ?: =(i.t.q.tub '-') - ?~ t.t.q.tub - (fail tub) - ?: =(i.t.t.q.tub ']') - (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) - (fail tub) - (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) - |= tub=nail - ?~ q.tub - (fail tub) - ?. =(i.q.tub '-') - (fail tub) - ?~ t.q.tub - (fail tub) - ?: =(i.t.q.tub '-') - ?~ t.t.q.tub - (fail tub) - ?: =(i.t.t.q.tub ']') - (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) - (fail tub) - (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) - (cook |=(a=[@ @] (con a)) ;~(plug seap sade)) - == - :: - -XX document - -### `++sade` - - ++ sade - %+ knee *@ |. ~+ - ;~ pose - (cold (bex '-') (jest '-]')) - (cold 0 ser) - (cook |=([p=@ q=@] `@`(con p q)) ;~(plug seap sade)) - == - :: - -XX document - -### `++seap` - - ++ seap - %+ knee *@ |. ~+ - ;~ pose - unid - %+ ifix (jest '[:')^(jest ':]') - ;~(pose ;~(pfix ket (cook flap chas)) chas) - %+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b)))) - ;~(plug asp ;~(pfix hep alb)) - |= tub=nail - ?~ q.tub - (fail tub) - ?~ t.q.tub - ((cook bex les) tub) - ?: =(i.t.q.tub '-') - ?~ t.t.q.tub - ((cook bex les) tub) - ?: =(i.t.t.q.tub ']') - ((cook bex les) tub) - (fail tub) - ((cook bex les) tub) - ;~(pfix bas escd) - == - :: - -XX document - -### `++cape` - - ++ cape - %+ knee *tape |. ~+ - ;~ pose - (cold ~ (jest '\\E')) - ;~(plug next cape) - (cook |=(a=char (tape [a ~])) next) - (full (easy ~)) - == - -XX document - -### `++chas` - - ++ chas :: ascii character set - =- (sear ~(get by -) sym) - %- mo ^- (list ,[@tas @I]) - :~ alnum/alnum alpha/alpha ascii/ascii blank/blank cntrl/cntrl - digit/digit graph/graph lower/lower print/print punct/punct - space/space upper/upper word/wordc xdigit/xdigit - == - :: Character sets - -++ alnum :(con lower upper digit) - - - XX document - - ###++alpha - -++ alpha :(con lower upper) - - - XX document - - ###++ascii - -++ ascii (ranc 0 127) - - - ++ blank (con (bex 32) (bex 9)) - -XX document - -### `++cntrl` - - ++ cntrl :(con (ranc 0 31) (bex 127)) - -XX document - -### `++digit` - - ++ digit (ranc '0' '9') - -XX document - -### `++graph` - - ++ graph (ranc 33 126) - -XX document - -### `++lower` - - ++ lower (ranc 'a' 'z') - -XX document - -### `++print` - - ++ print (ranc 32 126) - -XX document - -### `++punct` - - ++ punct ;: con - (ranc '!' '/') - (ranc ':' '@') - (ranc '[' '`') - (ranc '{' '~') - == - -XX document - -### `++space` - - ++ space :(con (ranc 9 13) (bex ' ')) - -XX document - -### `++upper` - - ++ upper (ranc 'A' 'Z') - -XX document - -### `++white` - - ++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13)) - -XX document - -### `++wordc` - - ++ wordc :(con digit lower upper (bex '_')) - -XX document - -### `++xdigit` - - ++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit) - :: - -XX document - -### `++chad` - - ++ chad - %+ knee *rege |. ~+ - ;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp)) - :: - -XX document - -### `++escd` - - ++ escd - %+ knee *@ |. ~+ - ;~ pose - (cold (bex 7) (just 'a')) - (cold (bex 9) (just 't')) - (cold (bex 10) (just 'n')) - (cold (bex 11) (just 'v')) - (cold (bex 12) (just 'f')) - (cold (bex 13) (just 'r')) - (cold (bex 0) (just '0')) - (sear |=(a=@ ?:((lth a 256) (some (bex a)) ~)) (bass 8 (stun [2 3] cit))) - (cook bex ;~(pfix (just 'x') (bass 16 (stun [2 2] hit)))) - (cook bex (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit)))) - (cook bex mis) - == - :: - -XX document - -### `++escp` - - ++ escp - %+ knee *rege |. ~+ - ;~ pose - (cold %empt (just 'Q')) - (cold [%lite `@tD`0] (just '0')) - (cold [%lite `@tD`7] (just 'a')) - (cold [%lite `@tD`9] (just 't')) - (cold [%lite `@tD`10] (just 'n')) - (cold [%lite `@tD`11] (just 'v')) - (cold [%lite `@tD`12] (just 'f')) - (cold [%lite `@tD`13] (just 'r')) - (sear |=(a=@ ?:((lth a 256) (some [%lite a]) ~)) (bass 8 (stun [2 3] cit))) - (stag %lite ;~(pfix (just 'x') (bass 16 (stun [2 2] hit)))) - (stag %lite (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit)))) - (cold %dote (just 'C')) - (cold %sart (just 'A')) - (cold %ende (just 'z')) - (cold %boun (just 'b')) - (cold %bout (just 'B')) - (stag %brac (cold wordc (just 'w'))) - (stag %brac (cold (flap wordc) (just 'W'))) - (stag %lite mis) - == - :: - -XX document - -### `++unid` - - ++ unid - %+ knee *@ |. ~+ - ;~ pose - (cold digit (jest '\\d')) - (cold (flap digit) (jest '\\D')) - (cold white (jest '\\s')) - (cold (flap white) (jest '\\S')) - (cold wordc (jest '\\w')) - (cold (flap wordc) (jest '\\W')) - == - -- - :: - -XX document - -### `++ra` - - ++ ra :: regex engine - |_ a=rege - -XX document - -### `++proc` - - ++ proc :: capture numbering - |= b=@ - =- -(+ +>.$(a a)) - ^- [p=@ a=rege] - ?- a - [%capt *] =+ foo=$(a p.a, b +(b)) - [p.foo [%capt a.foo b]] - [%eith *] =+ foo=$(a p.a) - =+ bar=$(a q.a, b p.foo) - [p.bar [%eith a.foo a.bar]] - [%pair *] =+ foo=$(a p.a) - =+ bar=$(a q.a, b p.foo) - [p.bar [%pair a.foo a.bar]] - [%manl *] =+ foo=$(a p.a) - [p.foo [%manl a.foo]] - [%plll *] =+ foo=$(a p.a) - [p.foo [%plll a.foo]] - [%binl *] =+ foo=$(a p.a) - [p.foo [%binl a.foo q.a]] - [%betl *] =+ foo=$(a p.a) - [p.foo [%betl a.foo q.a r.a]] - [%mant *] =+ foo=$(a p.a) - [p.foo [%mant a.foo]] - [%plls *] =+ foo=$(a p.a) - [p.foo [%plls a.foo]] - [%bant *] =+ foo=$(a p.a) - [p.foo [%bant a.foo q.a]] - [%bint *] =+ foo=$(a p.a) - [p.foo [%bint a.foo q.a]] - [%betw *] =+ foo=$(a p.a) - [p.foo [%betw a.foo q.a r.a]] - * [b a] - == - :: - -XX document - -### `++cont` - - ++ cont - |= [a=(map ,@u tape) b=(map ,@u tape)] - (~(gas by _(map ,@u tape)) (weld (~(tap by a)) (~(tap by b)))) - :: - -XX document - -### `++abor` - - ++ abor - |= [a=char b=(unit ,[tape (map ,@u tape)])] - ^- (unit ,[tape (map ,@u tape)]) - ?~ b - b - [~ [[a -.u.b] +.u.b]] - :: - -XX document - -### `++matc` - - ++ matc - |= [b=tape c=tape] - ^- (unit (map ,@u tape)) - =+ foo=`(unit ,[tape (map ,@u tape)])`(deep b %empt c) - (bind foo |*(a=^ (~(put by +.a) 0 -.a))) - :: - -XX document - -### `++chet` - - ++ chet - |= [b=(unit ,[tape (map ,@u tape)]) c=tape d=tape] - ^- (unit ,[tape (map ,@u tape)]) - ?~ b - b - ?~ -.u.b - b - =+ bar=(deep (slag (lent -.u.b) c) %empt d) - ?~ bar - bar - b - -XX document - -### `++blak` - - ++ blak (some ["" _(map ,@u tape)]) - -XX document - -### `++word` - - ++ word |=(a=char =((dis wordc:rags (bex a)) 0)) - -XX document - -### `++deep` - - ++ deep - |= [b=tape c=rege d=tape] - ^- (unit ,[tape (map ,@u tape)]) - ?- a - %dote ?~(b ~ (some [[i.b ~] _(map ,@u tape)])) - %ende ?~(b blak ~) - %sart ?:(=(b d) blak ~) - %empt blak - %boun =+ ^= luc - ?: =(b d) - & - =+ foo=(slag (dec (sub (lent d) (lent b))) d) - (word -.foo) - =+ cuc=?~(b & (word -.b)) - ?:(!=(luc cuc) blak ~) - %bout =+ ^= luc - ?: =(b d) - & - =+ foo=(slag (dec (sub (lent d) (lent b))) d) - (word -.foo) - =+ cuc=?~(b & (word -.b)) - ?:(=(luc cuc) blak ~) - [%capt *] =+ foo=$(a p.a) - ?~ foo - foo - =+ ft=u.foo - =+ bar=$(a c, b (slag (lent -.ft) b), c %empt) - ?~ bar - bar - [~ [-.ft (~(put by +.ft) q.a -.ft)]] - [%lite *] ?~(b ~ ?:(=(i.b p.a) (some [[i.b ~] _(map ,@u tape)]) ~)) - [%brac *] ?~ b - ~ - ?. =((dis (bex `@`i.b) p.a) 0) - (some [[i.b ~] _(map ,@u tape)]) - ~ - [%eith *] =+ foo=(chet(a c) $(a p.a) b d) - =+ bar=(chet(a c) $(a q.a) b d) - ?~ foo - bar - ?~ bar - foo - =+ ft=u.foo - =+ bt=u.bar - ?: (gte (lent -.ft) (lent -.bt)) - foo - bar - [%pair *] =+ foo=$(a p.a, c [%pair q.a c]) - ?~ foo - foo - =+ ft=u.foo - =+ bar=$(a q.a, b (slag (lent -.ft) b)) - ?~ bar - bar - =+ bt=u.bar - [~ [(weld -.ft -.bt) (cont +.ft +.bt)]] - [%manl *] =+ foo=$(a p.a) - ?~ foo - blak - ?~ -.u.foo - blak - $(a [%eith %empt [%pair p.a [%eith %empt a]]]) - [%mant *] =+ foo=$(a p.a) - ?~ foo - blak - =+ ft=u.foo - ?~ -.ft - blak - $(a [%eith [%pair p.a [%eith a %empt]] %empt]) - [%plls *] $(a [%pair p.a [%mant p.a]]) - [%plll *] $(a [%pair p.a [%manl p.a]]) - [%binl *] =+ min=?:(=(q.a 0) 0 (dec q.a)) - ?: =(q.a 0) - $(a [%manl p.a]) - $(a [%pair p.a [%binl p.a min]]) - [%bant *] ?: =(0 q.a) - blak - $(a [%pair p.a [%bant p.a (dec q.a)]]) - [%bint *] =+ min=?:(=(q.a 0) 0 (dec q.a)) - ?: =(q.a 0) - $(a [%mant p.a]) - $(a [%pair p.a [%bint p.a min]]) - [%betw *] ?: =(0 r.a) - blak - ?: =(q.a 0) - $(a [%eith [%pair p.a [%betw p.a 0 (dec r.a)]] %empt]) - $(a [%pair p.a [%betw p.a (dec q.a) (dec r.a)]]) - [%betl *] ?: =(0 r.a) - blak - ?: =(q.a 0) - $(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]]) - $(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]]) - == - -- - :: - -XX document - -### `++rexp` - - ++ rexp :: Regex match - ~/ %rexp - |= [a=tape b=tape] - ^- (unit (unit (map ,@u tape))) - =+ ^= bar - |= [a=@ b=(map ,@u tape)] - ?: =(a 0) - b - =+ c=(~(get by b) a) - ?~ c - $(a (dec a), b (~(put by b) a "")) - $(a (dec a)) - =+ par=(pars a) - ?~ par ~ - =+ poc=(~(proc ra u.par) 1) - =+ c=b - |- - =+ foo=(matc:poc c b) - ?~ foo - ?~ c - [~ ~] - $(c t.c) - [~ [~ (bar (dec p.poc) u.foo)]] - :: - -XX document - -### `++repg` - - ++ repg :: Global regex replace - ~/ %repg - |= [a=tape b=tape c=tape] - ^- (unit tape) - =+ par=(pars a) - ?~ par ~ - =+ poc=(~(proc ra u.par) 1) - =+ d=b - :- ~ - |- - ^- tape - =+ foo=(matc:poc d b) - ?~ foo - ?~ d - ~ - [i.d $(d t.d)] - =+ ft=(need (~(get by u.foo) 0)) - ?~ d - c - (weld c $(d `tape`(slag (lent ft) `tape`d))) - :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/web/docs/dev/hoon/library/2en.md b/web/docs/dev/hoon/library/2en.md deleted file mode 100644 index b5c58ff87..000000000 --- a/web/docs/dev/hoon/library/2en.md +++ /dev/null @@ -1,378 +0,0 @@ -section 2eN, pseudo-cryptography -================================ - -### `++un` - -Reversible scrambling core - - ++ un :: =(x (wred (wren x))) - |% - -A core that contains arms that perform reversible scrambling operations. -Used in the `@p` phonetic base. - ------------------------------------------------------------------------- - -### `++wren` - -Conceal structure - - ++ wren :: conceal structure - |= pyn=@ ^- @ - =+ len=(met 3 pyn) - ?: =(0 len) - 0 - => .(len (dec len)) - =+ mig=(zaft (xafo len (cut 3 [len 1] pyn))) - %+ can 3 - %- flop ^- (list ,[@ @]) - :- [1 mig] - |- ^- (list ,[@ @]) - ?: =(0 len) - ~ - => .(len (dec len)) - =+ mog=(zyft :(mix mig (end 3 1 len) (cut 3 [len 1] pyn))) - [[1 mog] $(mig mog)] - :: - -Scrambles a bytestring `pyn` by adding the current position to each -byte, looking it up in an s-box, and then performing the XOR operation -on the result, pushing it forward. Produces an atom. - -`pyn` is an [atom](). - - ~zod/try=> `@ux`(wren:un 'testing') - 0x30.bf6a.b9fe.7d8f - ~zod/try=> `@ux`'testing' - 0x67.6e69.7473.6574 - ~zod/try=> `@da`(wred:un (wren:un ~2001.2.5)) - ~2001.2.5 - ------------------------------------------------------------------------- - -### `++wred` - -Restore structure - - ++ wred :: restore structure - |= cry=@ ^- @ - =+ len=(met 3 cry) - ?: =(0 len) - 0 - => .(len (dec len)) - =+ mig=(cut 3 [len 1] cry) - %+ can 3 - %- flop ^- (list ,[@ @]) - :- [1 (xaro len (zart mig))] - |- ^- (list ,[@ @]) - ?: =(0 len) - ~ - => .(len (dec len)) - =+ mog=(cut 3 [len 1] cry) - [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] - :: - -Unscrambles a bytestring `cry` by subtracting the current position from -each byte, looking it up in an s-box, and performing the XOR operation -on the result, pushing it forward. Produces an atom. - -`cry` is an [atom](). - - ~zod/try=> (wred:un 0x30.bf6a.b9fe.7d8f) - 29.113.321.805.538.676 - ~zod/try=> `@t`(wred:un 0x30.bf6a.b9fe.7d8f) - 'testing' - ~zod/try=> (wred:un (wren:un 200.038.426)) - 200.038.426 - ------------------------------------------------------------------------- - -### `++xafo` - -Add modulo 255 - - ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) - -Produces the sum of two atoms modulo 255, encoded as a nonzero byte. - - ~zod/try=> (xafo:un 5 6) - 11 - ~zod/try=> (xafo:un 256 20) - 21 - ------------------------------------------------------------------------- - -### `++xaro` - -Subtract modulo 255 - - ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) - -Produces the difference between two atoms modulo 255, encoded as a -nonzero byte. - - ~zod/try=> (xaro:un 17 57) - 40 - ~zod/try=> (xaro:un 265 12) - 2 - ------------------------------------------------------------------------- - -### `++zaft` - -Look up in 255 sub box - - ++ zaft :: forward 255-sbox - |= a=@D - =+ ^= b - 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0. - 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038. - 1f4a.dca2.6fdf.66f9.f561.a12e.5a16.f7b0.a39f.364e.cb70.7318. - 1de1.ad31.63d1.abd4.db68.6a33.134d.a760.edee.5434.493a.e323. - 930d.8f3d.3562.bb81.0b24.43cf.bea5.a6eb.52b4.0229.06b2.6704. - 78c9.45ec.d75e.58af.c577.b7b9.c40e.017d.90c3.87f8.96fa.1153. - 0372.7f30.1c32.ac83.ff17.c6e4.d36d.6b55.e2ce.8c71.8a5b.b6f3. - 9d4b.eab5.8b3c.e7f2.a8fe.9574.5de0.bf20.3f15.9784.9939.5f9c. - e609.564f.d8a4.b825.9819.94aa.2c08.8e4c.9b22.477a.2840.3ed6. - 3750.6ef1.44dd.89ef.6576.d00a.fbda.9ed2.3b6c.7b0c.bde9.2ade. - 5c88.c182.481a.1b0f.2bfd.d591.2726.57ba - (cut 3 [(dec a) 1] b) - :: - -The inverse of [`++zart`](). Looks up a nonzero byte`a\` in a substiution -box with 255 values, producing a unique nonzero byte. - -`a` is an [atom]() of one byte in length. - - ~zod/try=> (zaft:un 0x12) - 42 - ~zod/try=> (zaft:un 0xff) - 204 - ~zod/try=> (zaft:un 0x0) - ! decrement-underflow - ! exit - ------------------------------------------------------------------------- - -### `++zart` - -Reverse look up in 255 sub box - - ++ zart :: reverse 255-sbox - |= a=@D - =+ ^= b - 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613. - dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3. - 1e95.5fec.ffbc.f187.fbe2.6680.7c77.d30e.e94a.9414.fd9a.017d. - 3a7e.5a55.8ff5.8bf9.c181.e5b6.6ab2.35da.50aa.9293.3bc0.cdc6. - f3bf.1a58.4130.f844.3846.744e.36a0.f205.789e.32d8.5e54.5c22. - 0f76.fce7.4569.0d99.d26e.e879.dc16.2df4.887f.1ffe.4dba.6f5d. - bbcc.2663.1762.aed7.af8a.ca20.dbb4.9bc7.a942.834c.105b.c4d4. - 8202.3e61.a671.90e6.273d.bdab.3157.cfa4.0c2e.df86.2496.f7ed. - 2b48.2a9d.5318.a343.d128.be9c.a5ad.6bb5.6dfa.c5e1.3408.128d. - 2c04.0339.97a1.2ff0.49d0.eeb8.6c0a.0b37.b967.c347.d9ac.e072. - e409.7b9f.1598.1d3f.33de.8ce3.8970.8e7a - (cut 3 [(dec a) 1] b) - :: - -The inverse of [`++zaft`](). Looks up the index of a nonzero byte `a` in -the substitution box with 255 values, producing a unique nonzero byte. - -`a` is an [atom]() of one byte in length. - - ~zod/try=> `@ux`(zart:un 204) - 0xff - ~zod/try=> `@ux`(zart:un 42) - 0x12 - ------------------------------------------------------------------------- - -### `++zyft` - -Lookup byte in 256 sub box - - ++ zyft :: forward 256-sbox - |= a=@D - =+ ^= b - 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5. - 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d. - 986a.768c.f8e8.c4c7.2f1c.effe.3cae.01c0.253e.65d3.3872. - ce0e.7a74.8ac6.daac.7e5c.6479.44ec.4143.3d20.4af0.ee6c. - c828.deca.0377.249f.ffcd.7b4f.eb7d.66f2.8951.042e.595a. - 8e13.f9c3.a79a.f788.6199.9391.7fab.6200.4ce5.0758.e2f1. - 7594.c945.d218.4248.afa1.e61a.54fb.1482.bea4.96a2.3473. - 63c2.e7cb.155b.120a.4ed7.bfd8.b31b.4008.f329.fca3.5380. - 9556.0cb2.8722.2bea.e96e.3ac5.d1bc.10e3.2c52.a62a.b1d6. - 35aa.d05e.f6a8.0f3b.31ed.559d.09ad.f585.6d21.fd1d.8d67. - 370b.26f4.70c1.b923.4684.6fbd.cf8b.5036.0539.9cdc.d93f. - 9068.1edf.8f33.b632.d427.97fa.9ee1 - (cut 3 [a 1] b) - :: - -The inverse of [`++zyrt`](). Looks up a byte `a` in a substituion box -with 256 values, producing a byte. - -`a` is an [atom]() of one byte in length. - - ~zod/try=> (zyft:un 0x12) - 57 - ~zod/try=> (zyft:un 0x0) - 225 - ~zod/try=> (zyft:un 0xff) - 187 - ------------------------------------------------------------------------- - -### `++zyrt` - -Reverse lookup byte in 256 sub box - - ++ zyrt :: reverse 256-sbox - |= a=@D - =+ ^= b - 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48. - 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605. - c077.4337.17bd.9eda.62a4.79a7.ccb8.44cd.8e64.1ec4.5b6b. - 1842.ffd8.1dfb.fd07.f2f9.594c.3be3.73c6.2cb6.8438.e434. - 8d3d.ea6a.5268.72db.a001.2e11.de8c.88d3.0369.4f7a.87e2. - 860d.0991.25d0.16b9.978a.4bf4.2a1a.e96c.fa50.85b5.9aeb. - 9dbb.b2d9.a2d1.7bba.66be.e81f.1946.29a8.f5d2.f30c.2499. - c1b3.6583.89e1.ee36.e0b4.6092.937e.d74e.2f6f.513e.9615. - 9c5d.d581.e7ab.fe74.f01b.78b1.ae75.af57.0ec2.adc7.3245. - 12bf.2314.3967.0806.31dc.cb94.d43f.493c.54a6.0421.c3a1. - 1c4a.28ac.fc0b.26ca.5870.e576.f7f1.616d.905f.ef41.33bc. - df4d.225e.2d56.7fd6.1395.a3f8.c582 - (cut 3 [a 1] b) - -The inverse of [`++zyft`](/doc/hoon/library/2en#++zyft). Looks up a byte `a` in a substituion box -with 256 values, producing a byte. - -`a` is an [atom]() of one byte in length. - - ~zod/try=> `@ux`(zyrt:un 57) - 0x12 - ~zod/try=> `@ux`(zyrt:un 225) - 0x0 - ~zod/try=> `@ux`(zyrt:un 187) - 0xff - -### `++ob` - -Reversible scrambling core, v2 - - ++ ob - |% - -A core for performing reversible scrambling operations for the `@p` phonetic base. - ------------------------------------------------------------------------- - -### `++feen` - -Conceal structure, v2 - - ++ feen :: conceal structure v2 - |= pyn=@ ^- @ - ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) - (add 0x1.0000 (fice (sub pyn 0x1.0000))) - ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) - =+ lo=(dis pyn 0xffff.ffff) - =+ hi=(dis pyn 0xffff.ffff.0000.0000) - %+ con hi - (add 0x1.0000 (fice (sub lo 0x1.0000))) - pyn - -Randomly permutes atoms that fit into 17 to 32 bits into one another. If the atom fits into 33 to 64 bits, does the same permutation on the low 32 bits only. Otherwise, passes the atom through unchanged. - ------------------------------------------------------------------------- - -### `++fend` - - ++ fend :: restore structure v2 - |= cry=@ ^- @ - ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) - (add 0x1.0000 (teil (sub cry 0x1.0000))) - ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) - =+ lo=(dis cry 0xffff.ffff) - =+ hi=(dis cry 0xffff.ffff.0000.0000) - %+ con hi - (add 0x1.0000 (teil (sub lo 0x1.0000))) - cry - -Randomly permutes atoms that fit into 17 to 32 bits into one another, and randomly permutes the low 32 bits of atoms that fit into 33 to 64 bits; otherwise, passes the atom through unchanged. The permutation is the inverse of the one applied by [`++feen`](). - ------------------------------------------------------------------------- - -### `++fice` - - ++ fice :: adapted from - |= nor=@ :: black and rogaway - ^- @ :: "ciphers with - =+ ^= sel :: arbitrary finite - %+ rynd 2 :: domains", 2002 - %+ rynd 1 - %+ rynd 0 - [(mod nor 65.535) (div nor 65.535)] - (add (mul 65.535 -.sel) +.sel) - -Applies a 3-round Feistel-like cipher to randomly permute atoms in the range `0` to `2^32 - 2^16`. The construction given in Black and Rogaway is ideal for a domain with a size of that form, and as with a conventionel Feistel cipher, three rounds suffice to make the permutation pseudorandom. - ------------------------------------------------------------------------- - -### `++teil` - - ++ teil :: reverse ++fice - |= vip=@ - ^- @ - =+ ^= sel - %+ rund 0 - %+ rund 1 - %+ rund 2 - [(mod vip 65.535) (div vip 65.535)] - (add (mul 65.535 -.sel) +.sel) - -Applies the reverse of the Feistel-like cipher applied by [`++fice`](). Unlike a conventional Feistel cipher that is its own inverse if keys are used in reverse order, this Feistel-like cipher uses two moduli that must be swapped when applying the reverse transformation. - ------------------------------------------------------------------------- - -### `++rynd` - - ++ rynd :: feistel round - |= [n=@ l=@ r=@] - ^- [@ @] - :- r - ?~ (mod n 2) - (~(sum fo 65.535) l (en:aesc (snag n raku) r)) - (~(sum fo 65.536) l (en:aesc (snag n raku) r)) - -A single round of the Feistel-like cipher [`++fice`](). AES ([`++aesc`]()) is used as the round function. - ------------------------------------------------------------------------- - -### `++rund` - - ++ rund :: reverse round - |= [n=@ l=@ r=@] - ^- [@ @] - :- r - ?~ (mod n 2) - (~(dif fo 65.535) l (en:aesc (snag n raku) r)) - (~(dif fo 65.536) l (en:aesc (snag n raku) r)) - -A single round of the Feistel-like reverse cipher [`++teil`](). - ------------------------------------------------------------------------- - -### `++raku` - - ++ raku - ^- (list ,@ux) - :~ 0x15f6.25e3.083a.eb3e.7a55.d4db.fb99.32a3. - 43af.2750.219e.8a24.e5f8.fac3.6c36.f968 - 0xf2ff.24fe.54d0.1abd.4b2a.d8aa.4402.8e88. - e82f.19ec.948d.b1bb.ed2e.f791.83a3.8133 - 0xa3d8.6a7b.400e.9e91.187d.91a7.6942.f34a. - 6f5f.ab8e.88b9.c089.b2dc.95a6.aed5.e3a4 - == - -Arbitrary keys for use with [`++aesc`](). diff --git a/web/docs/dev/hoon/library/2eo.md b/web/docs/dev/hoon/library/2eo.md deleted file mode 100644 index 136011a35..000000000 --- a/web/docs/dev/hoon/library/2eo.md +++ /dev/null @@ -1,453 +0,0 @@ -section 2eO, virtualization -=========================== - -### `++mack` - -Nock subject to unit - - ++ mack - |= [sub=* fol=*] - ^- (unit) - =+ ton=(mink [sub fol] |=(* ~)) - ?.(?=([0 *] ton) ~ [~ p.ton]) - :: - -Accepts a nock subject-formula cell and wraps it into a [`++unit`](). -`fol` is pure nock, meaning that nock `11` operations result in a block, -producing a `~`. - -`sub` is a subject [noun](). - -`fol` is a formula [noun](), which is generally a `++nock`. - - ~zod/try=> (mack [[1 2 3] [0 1]]) - [~ [1 2 3]] - ~zod/try=> (mack [41 4 0 1]) - [~ 42] - ~zod/try=> (mack [4 0 4]) - ~ - ~zod/try=> (mack [[[0 2] [1 3]] 4 4 4 4 0 5]) - [~ 6] - ~zod/try=> ;;((unit ,@tas) (mack [[1 %yes %no] 6 [0 2] [0 6] 0 7])) - [~ %no] - ------------------------------------------------------------------------- - -### `++mink` - -Mock interpreter - - ++ mink - ~/ %mink - |= [[sub=* fol=*] sky=$+(* (unit))] - =+ tax=*(list ,[@ta *]) - |- ^- tone - ?@ fol - [%2 tax] - ?: ?=(^ -.fol) - =+ hed=$(fol -.fol) - ?: ?=(%2 -.hed) - hed - =+ tal=$(fol +.fol) - ?- -.tal - %0 ?-(-.hed %0 [%0 p.hed p.tal], %1 hed) - %1 ?-(-.hed %0 tal, %1 [%1 (weld p.hed p.tal)]) - %2 tal - == - ?+ fol - [%2 tax] - :: - [0 b=@] - ?: =(0 b.fol) [%2 tax] - ?: =(1 b.fol) [%0 sub] - ?: ?=(@ sub) [%2 tax] - =+ [now=(cap b.fol) lat=(mas b.fol)] - $(b.fol lat, sub ?:(=(2 now) -.sub +.sub)) - :: - [1 b=*] - [%0 b.fol] - :: - [2 b=[^ *]] - =+ ben=$(fol b.fol) - ?. ?=(%0 -.ben) ben - ?>(?=(^ p.ben) $(sub -.p.ben, fol +.p.ben)) - ::?>(?=(^ p.ben) $([sub fol] p.ben) - :: - [3 b=*] - =+ ben=$(fol b.fol) - ?. ?=(%0 -.ben) ben - [%0 .?(p.ben)] - :: - [4 b=*] - =+ ben=$(fol b.fol) - ?. ?=(%0 -.ben) ben - ?. ?=(@ p.ben) [%2 tax] - [%0 .+(p.ben)] - :: - [5 b=*] - =+ ben=$(fol b.fol) - ?. ?=(%0 -.ben) ben - ?. ?=(^ p.ben) [%2 tax] - [%0 =(-.p.ben +.p.ben)] - :: - [6 b=* c=* d=*] - $(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b])) - :: - [7 b=* c=*] $(fol =>(fol [2 b 1 c])) - [8 b=* c=*] $(fol =>(fol [7 [[0 1] b] c])) - [9 b=* c=*] $(fol =>(fol [7 c 0 b])) - [10 @ c=*] $(fol c.fol) - [10 [b=* c=*] d=*] - =+ ben=$(fol c.fol) - ?. ?=(%0 -.ben) ben - ?: ?=(?(%hunk %lose %mean %spot) b.fol) - $(fol d.fol, tax [[b.fol p.ben] tax]) - $(fol d.fol) - :: - [11 b=*] - =+ ben=$(fol b.fol) - ?. ?=(%0 -.ben) ben - =+ val=(sky p.ben) - ?~(val [%1 p.ben ~] [%0 u.val]) - :: - == - :: - -Bottom-level [mock]() (virtual nock) interpreter. Produces a -[`++tone`](), a nock computation result. If nock 11 is invoked, `sky` -computes on the subject and produces a [`++unit`]() result. An empty -result becomes a `%1` `++tone`, indicating a block. - -`sub` is the subject as a [noun](). - -`fol` is the formula as a [noun](). - -`sky` is an [`%iron`]() gate invoked with [nock operator 11](). - - ~zod/try=> (mink [20 [4 0 1]] ,~) - [%0 p=21] - ~zod/try=> (mink [[90 5 3] [0 3]] ,~) - [%0 p=[5 3]] - ~zod/try=> (mink 20^[4 0 1] ,~) - [%0 p=21] - ~zod/try=> (mink [90 5 3]^[0 3] ,~) - [%0 p=[5 3]] - ~zod/try=> (mink [0]^[11 1 20] ,~) - [%1 p=~[20]] - ~zod/try=> (mink [0]^[11 1 20] |=(a=* `[40 a])) - [%0 p=[40 20]] - ~zod/try=> (mink [5]^[0 2] ,~) - [%2 p=~] - ~zod/try=> (mink [5]^[10 yelp/[0 1] 0 0] ,~) - [%2 p=~[[~.yelp 5]]] - ------------------------------------------------------------------------- - -### `++mock` - -Compute formula on subject with hint - - ++ mock - |= [[sub=* fol=*] sky=$+(* (unit))] - (mook (mink [sub fol] sky)) - :: - -Produces a [`++toon`](), which is either a sucessful, blocked, or -crashed result. If nock 11 is invoked, `sky` computes on the subject and -produces a [`++unit`]() result. An empty result becomes a `%1` `++tune`, -indicating a block. - -`sub` is the subject as a [noun](). - -`fol` is the formula as a [noun](). - -`sky` is an [%iron]() gate invoked with [nock operator 11](). - - ~zod/try=> (mock [5 4 0 1] ,~) - [%0 p=6] - ~zod/try=> (mock [~ 11 1 0] |=(* `999)) - [%0 p=999] - ~zod/try=> (mock [~ 0 1.337] ,~) - [%2 p=~] - ~zod/try=> (mock [~ 11 1 1.337] ,~) - [%1 p=~[1.337]] - ~zod/try=> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[+<])) - [%0 p=14] - ~zod/try=> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>])) - [%0 p=[49 52 0]] - ~zod/try=> ;;(tape +:(mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>]))) - "14" - ------------------------------------------------------------------------- - -### `++mook` - -Intelligently render crash annotation - - ++ mook - |= ton=tone - ^- toon - ?. ?=([2 *] ton) ton - :- %2 - =+ yel=(lent p.ton) - =. p.ton - ?. (gth yel 256) p.ton - %+ weld - (scag 128 p.ton) - ^- (list ,[@ta *]) - :_ (slag (sub yel 128) p.ton) - :- %lose - %+ rap 3 - ;: weld - "[skipped " - ~(rend co %$ %ud (sub yel 256)) - " frames]" - == - |- ^- (list tank) - ?~ p.ton ~ - =+ rex=$(p.ton t.p.ton) - ?+ -.i.p.ton rex - %hunk [(tank +.i.p.ton) rex] - %lose [[%leaf (rip 3 (,@ +.i.p.ton))] rex] - %mean :_ rex - ?@ +.i.p.ton [%leaf (rip 3 (,@ +.i.p.ton))] - =+ mac=(mack +.i.p.ton +<.i.p.ton) - ?~(mac [%leaf "####"] (tank u.mac)) - %spot :_ rex - =+ sot=(spot +.i.p.ton) - :- %leaf - ;: weld - ~(ram re (smyt p.sot)) - ":<[" - ~(rend co ~ %ud p.p.q.sot) - " " - ~(rend co ~ %ud q.p.q.sot) - "].[" - ~(rend co ~ %ud p.q.q.sot) - " " - ~(rend co ~ %ud q.q.q.sot) - "]>" - == - == - :: - -Converts a `%2` `++tone` nock stack trace to a list of [`++tank`](). -Each may be a tank, cord, [`++spot`](), or trapped tank. Produces a -[`++toon`](). - -`ton` is a [`++tone`](). - - ~zod/try=> (mook [%0 5 4 5 1]) - [%0 p=[5 4 5 1]] - ~zod/try=> (mook [%2 ~[[%hunk %rose ["<" "," ">"] ~[[%leaf "err"]]]]]) - [%2 p=~[[%rose p=[p="<" q="," r=">"] q=[i=[%leaf p="err"] t=~]]]] - ~zod/try=> (mook [%2 ~[[%malformed %elem] [%lose 'do print']]]) - [%2 p=~[[%leaf p="do print"]]] - ~zod/try=> (mook [%2 ~[[%mean |.(>(add 5 6)<)]]]) - [%2 p=~[[%leaf p="11"]]] - ~zod/try=> (mook [%2 ~[[%spot /b/repl [1 1]^[1 2]] [%mean |.(!!)]]]) - [%2 p=~[[%leaf p="/b/repl/:<[1 1].[1 2]>"] [%leaf p="####"]]] - ------------------------------------------------------------------------- - -### `++mang` - -Unit: Slam gate with sample - - ++ mang - |= [[gat=* sam=*] sky=$+(* (unit))] - ^- (unit) - =+ ton=(mong [[gat sam] sky]) - ?.(?=([0 *] ton) ~ [~ p.ton]) - :: - -Produces a [`++unit`]() computation result from slamming `gat` with -`sam`, using `sky` to compute or block on nock 11 when applicable. -Similar to [`++mong`](). - -`gat` is a [noun]() that is generally a [`gate`](). - -`sam` is a [`sample`]() noun. - -`sky` is an [%iron]() gate invoked with [nock operator 11](). - - ~zod/try=> (mang [|=(@ 20) ~] ,~) - [~ 20] - ~zod/try=> (mang [|=(@ !!) ~] ,~) - ~ - ~zod/try=> (mang [|=(a=@ (add 20 a)) ~] ,~) - [~ 20] - ~zod/try=> (mang [|=(a=[@ @] (add 20 -.a)) ~] ,~) - ~ - ~zod/try=> (mang [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) - [~ 24] - ~zod/try=> (mang [|=(a=@ .^(a)) ~] ,~) - ~ - ~zod/try=> (mang [|=(a=@ .^(a)) ~] ,[~ %42]) - [~ 42] - ~zod/try=> (mang [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) - [~ [0 6]] - ~zod/try=> (mang [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) - [~ [8 6]] - ------------------------------------------------------------------------- - -### `++mong` - -Slam gate with sample - - ++ mong - |= [[gat=* sam=*] sky=$+(* (unit))] - ^- toon - ?. &(?=(^ gat) ?=(^ +.gat)) - [%2 ~] - (mock [[-.gat [sam +>.gat]] -.gat] sky) - :: - -Produces a [`++toon`]() computation result from slamming `gat` with -`sam`, using `sky` to compute or block on nock 11 when applicable. - -`gat` is a [noun]() that is generally a [`gate`](). - -`sam` is a [`sample`]() noun. - -`sky` is an [%iron]() gate invoked with [nock operator 11](). - - ~zod/try=> (mong [|=(@ 20) ~] ,~) - [%0 p=20] - ~zod/try=> (mong [|=(@ !!) ~] ,~) - [%2 p=~] - ~zod/try=> (mong [|=(a=@ (add 20 a)) ~] ,~) - [%0 p=20] - ~zod/try=> (mong [|=(a=[@ @] (add 20 -.a)) ~] ,~) - [%2 p=~] - ~zod/try=> (mong [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) - [%0 p=24] - ~zod/try=> (mong [|=(a=@ .^(a)) ~] ,~) - [%1 p=~[0]] - ~zod/try=> (mong [|=(a=@ .^(a)) ~] ,[~ %42]) - [%0 p=42] - ~zod/try=> (mong [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) - [%0 p=[0 6]] - ~zod/try=> (mong [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) - [%0 p=[8 6]] - ------------------------------------------------------------------------- - -### `++mung` - -Virtualize slamming gate - - ++ mung - |= [[gat=* sam=*] sky=$+(* (unit))] - ^- tone - ?. &(?=(^ gat) ?=(^ +.gat)) - [%2 ~] - (mink [[-.gat [sam +>.gat]] -.gat] sky) - :: - -Produces a [`++tone`]() computation result from slamming `gat` with -`sam`, using `sky` to compute or block on nock 11 when applicable. - -`gat` is a [noun]() that is generally a [`gate`](). - -`sam` is a [`sample`]() noun. - -`sky` is an [%iron]() gate invoked with [nock operator 11](). - - ~zod/try=> (mung [|=(@ 20) ~] ,~) - [%0 p=20] - ~zod/try=> (mung [|=(@ !!) ~] ,~) - [%2 p=~] - ~zod/try=> (mung [|=(a=@ (add 20 a)) ~] ,~) - [%0 p=20] - ~zod/try=> (mung [|=(a=[@ @] (add 20 -.a)) ~] ,~) - [%2 p=~] - ~zod/try=> (mung [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) - [%0 p=24] - ~zod/try=> (mung [|=(a=@ .^(a)) ~] ,~) - [%1 p=~[0]] - ~zod/try=> (mung [|=(a=@ .^(a)) ~] ,[~ %42]) - [%0 p=42] - ~zod/try=> (mung [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) - [%0 p=[0 6]] - ~zod/try=> (mung [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) - [%0 p=[8 6]] - ------------------------------------------------------------------------- - -### `++mule` - -Typed virtual - - ++ mule :: typed virtual - ~/ %mule - |* taq=_|.(_*) - =+ mud=(mute taq) - ?- -.mud - & [%& p=$:taq] - | [%| p=p.mud] - == - :: - -Kicks a `++trap`, producing its results or any errors that occur along -the way. Used to lazily compute stack traces. - -`taq` is a [`++trap`](), generally producing a list of [`++tank`]()s. - - ~zod/try=> (mule |.(leaf/"hello")) - [%.y p=[%leaf "hello"]] - ~zod/try=> (mule |.(!!)) - [%.n p=~] - ~zod/try=> (mule |.(.^(a//=pals/1))) - [ %.n - p - ~[ - [ %rose - p=[p="/" q="/" r="/"] - q - [ i=[%leaf p="a"] - t=[i=[%leaf p="~zod"] t=[i=[%leaf p="pals"] t=[i=[%leaf p="1"] t=~]]] - ] - ] - ] - ] - ------------------------------------------------------------------------- - -### `++mute` - -Untyped virtual - - ++ mute :: untyped virtual - |= taq=_^?(|.(_*)) - ^- (each ,* (list tank)) - =+ ton=(mock [taq 9 2 0 1] |=(* ~)) - ?- -.ton - %0 [%& p.ton] - %1 [%| (turn p.ton |=(a=* (smyt (path a))))] - %2 [%| p.ton] - == - -Kicks a `++trap`, producing its result as a noun or the tanks of any -error that occurs. Similar to [`++mule`](), but preserves no type -information. - -`taq` is a [`++trap`](/doc/hoon/library/1#++trap). - - ~zod/try=> (mute |.(leaf/"hello")) - [%.y p=[1.717.658.988 104 101 108 108 111 0]] - ~zod/try=> (mute |.(!!)) - [%.n p=~] - ~zod/try=> (mute |.(.^(a//=pals/1))) - [ %.n - p - ~[ - [ %rose - p=[p="/" q="/" r="/"] - q=[i=[%leaf p="a"] t=[i=[%leaf p="~zod"] t=[i=[%leaf p="pals"] t=[i=[%leaf p="1"] t=~]]]] - ] - ] - ] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ep.md b/web/docs/dev/hoon/library/2ep.md deleted file mode 100644 index 0bcb847b6..000000000 --- a/web/docs/dev/hoon/library/2ep.md +++ /dev/null @@ -1,586 +0,0 @@ -section 2eP, diff -================= - -A- more or less low priority and/or currently in the wrong section -anyway. - ------------------------------------------------------------------------- - ------------------------------------------------------------------------- - -### `++berk` - -Invert diff patches - - ++ berk :: invert diff patch - |* bur=(urge) - |- ^+ bur - ?~ bur ~ - :_ $(bur t.bur) - ?- -.i.bur - & i.bur - | [%| q.i.bur p.i.bur] - == - :: - -Inverts a list of changes `bur`. Skips stay constant and replaces are -swapped. Produces a `bur`. - -`bur` is a [`++urge`](). - - ~zod/try=> (berk `(urge)`~[`10 %|^[~[2] ~[3 4]] `5]) - ~[[%.y p=10] [%.n p=~[3 4] q=~[2]] [%.y p=5]] - ~zod/try=> (lurk "somes" `(urge char)`~[`1 [%| "o" "a"] `3]) - "sames" - ~zod/try=> (berk `(urge char)`~[`1 [%| "o" "a"] `3]) - ~[[%.y p=1] [%.n p="a" q="o"] [%.y p=3]] - ~zod/try=> (lurk "sames" (berk `(urge char)`~[`1 [%| "o" "a"] `3])) - "somes" - ------------------------------------------------------------------------- - -### `++diff` - -Generate patch - - ++ diff :: generate patch - |= pum=umph - |= [old=* new=*] ^- udon - :- pum - ?+ pum ~|(%unsupported !!) - %a [%d (nude old new)] - %b =+ [hel=(cue ((hard ,@) old)) hev=(cue ((hard ,@) new))] - [%d (nude hel hev)] - %c =+ [hel=(lore ((hard ,@) old)) hev=(lore ((hard ,@) new))] - [%c (lusk hel hev (loss hel hev))] - == - :: - -Produces a patch between two nouns, by change type - -`pum` is an [`++umph`](). - - ~zod/try=> ((diff %a) 20 21) - [p=%a q=[%d p=[%1 p=21] q=[%1 p=20]]] - ~zod/try=> ((diff %a) [1 2 3] [1 2 4]) - [ p=%a - q - [ %d - p=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=4]]] - q=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=3]]] - ] - ] - ~zod/try=> ~04hh - [1 2] - ~zod/try=> ~0ph - [1 1] - ~zod/try=> ((diff %b) 0v4hh 0vph) - [p=%b q=[%d p=[p=[%0 p=2] q=[%0 p=2]] q=[p=[%0 p=3] q=[%1 p=2]]]] - ~zod/try=> ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~)) - [p=%c q=[%c p=~[[%.y p=1] [%.n p=~[7.562.604 7.562.604] q=~[7.499.629]] [%.y p=1]]]] - ~[[%.y p=0] [%.y p=0] [%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]] - ~zod/try=> (,[%c %c (urge cord)] ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~))) - [%c %c ~[[%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]]] - ------------------------------------------------------------------------- - -### `++loss` - -Longest subsequence - - ++ loss :: longest subsequence - ~/ %loss - |* [hel=(list) hev=(list)] - |- ^+ hev - =+ ^= sev - =+ [inx=0 sev=*(map ,@t (list ,@ud))] - |- ^+ sev - ?~ hev sev - =+ guy=(~(get by sev) i.hev) - $(hev t.hev, inx +(inx), sev (~(put by sev) i.hev [inx ?~(guy ~ u.guy)])) - =| gox=[p=@ud q=(map ,@ud ,[p=@ud q=_hev])] - =< abet - =< main - |% - ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag)) - ++ hink :: extend fits top - |= [inx=@ud goy=@ud] ^- ? - |(=(p.gox inx) (lth goy p:(need (~(get by q.gox) inx)))) - :: - ++ lonk :: extend fits bottom - |= [inx=@ud goy=@ud] ^- ? - |(=(0 inx) (gth goy p:(need (~(get by q.gox) (dec inx))))) - :: - ++ lune :: extend - |= [inx=@ud goy=@ud] - ^+ +> - %_ +>.$ - gox - :- ?:(=(inx p.gox) +(p.gox) p.gox) - %+ ~(put by q.gox) inx - [goy (snag goy hev) ?:(=(0 inx) ~ q:(need (~(get by q.gox) (dec inx))))] - == - :: - ++ merg :: merge all matches - |= gay=(list ,@ud) - ^+ +> - =+ ^= zes - =+ [inx=0 zes=*(list ,[p=@ud q=@ud])] - |- ^+ zes - ?: |(?=(~ gay) (gth inx p.gox)) zes - ?. (lonk inx i.gay) $(gay t.gay) - ?. (hink inx i.gay) $(inx +(inx)) - $(inx +(inx), gay t.gay, zes [[inx i.gay] zes]) - |- ^+ +>.^$ - ?~(zes +>.^$ $(zes t.zes, +>.^$ (lune i.zes))) - :: - ++ main - |- ^+ + - ?~ hel - ?~ hev - ?>(?=(~ lcs) +) - $(hev t.hev, rag (done %| ~ [i.hev ~])) - ?~ hev - $(hel t.hel, rag (done %| [i.hel ~] ~)) - ?~ lcs - +(rag (done %| (flop hel) (flop hev))) - ?: =(i.hel i.lcs) - ?: =(i.hev i.lcs) - $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1)) - $(hev t.hev, rag (done %| ~ [i.hev ~])) - ?: =(i.hev i.lcs) - $(hel t.hel, rag (done %| [i.hel ~] ~)) - $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~])) - -- - -Finds a subsequence of repeated elements within two [`++list`]()s, using -several internal helper arms. Produces a [`++tape`](). - -`hel` is a [`++list`]() of characters. - -`hev` is a [++list\`]() of characters. - - ~zod/try=> (loss "sam" "sem") - "sm" - ~zod/try=> (loss "samo" "semo") - "smo" - ~zod/try=> (loss "sakmo" "semo") - "smo" - ~zod/try=> (loss "ferdinham" "ferdilapos - ~ - ~zod/try=> (loss "ferdinham" "ferdilapos") - "ferdia" - ------------------------------------------------------------------------- - -### `++locz` - -Find common - - ++ locz :: trivial algorithm - |= [hel=tape hev=tape] - ^- tape - =+ [leh=(lent hel) veh=(lent hev)] - =- (flop q.yun) - ^= yun - |- ^- [p=@ud q=tape] - ~+ - ?: |(=(0 leh) =(0 veh)) [0 ~] - =+ [dis=(snag (dec leh) hel) dat=(snag (dec veh) hev)] - ?: =(dis dat) - =+ say=$(leh (dec leh), veh (dec veh)) - [+(p.say) [dis q.say]] - =+ [lef=$(leh (dec leh)) rig=$(veh (dec veh))] - ?:((gth p.lef p.rig) lef rig) - :: - -Finds a subsequence of repeated elements within two [`++list`](/doc/hoon/library/1#++list)s, -producing a [\`++tape](). - - ~zod/try=> (locz "samukot" "semelkot") - "smkot" - ~zod/try=> (locz "samukot" "samelkot") - "samkot" - ------------------------------------------------------------------------- - -### `++lore` - -Split on `\n` - - ++ lore :: atom to line list - ~/ %lore - |= lub=@ - =| tez=(list ,@t) - |- ^+ tez - ?: =(0 lub) (flop tez) - =+ ^= meg - =+ meg=0 - |- ^- @ud - =+ gam=(cut 3 [meg 1] lub) - ?:(|(=(10 gam) =(0 gam)) meg $(meg +(meg))) - =+ res=(rsh 3 +(meg) lub) - ?: &(=(0 (cut 3 [meg 1] lub)) !=(0 res)) - !! - $(lub res, tez [(end 3 meg lub) tez]) - :: - -Split on newlines, ascii `10` - - ~zod/try=> (lore 'soke\0alas\0amep') - <|soke las mep|> - ~zod/try=> (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)') - <||= a=@ =+ b=(add a 5) (mix b a)|> - ~zod/try=> `wain`[(fil 3 80 ' ') (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)')] - <| - |= a=@ - =+ b=(add a 5) - (mix b a) - |> - ------------------------------------------------------------------------- - -### `++role` - -Join with `\n` - - ++ role :: line list to atom - |= tez=(list ,@t) - (rap 3 (turn tez |=(a=@t (cat 3 a 10)))) - :: - -Join line list with newlines. - - ~zod/try=> (role 'sep' 'tek' 'lap' ~) - 3.230.709.852.558.292.782.985.274.739 - ~zod/try=> `@t`(role 'sep' 'tek' 'lap' ~) - ''' - sep - tek - lap - ''' - ------------------------------------------------------------------------- - -### `++lump` - -Change with `++udon` - - ++ lump :: apply patch - |= [don=udon src=*] - ^- * - ?+ p.don ~|(%unsupported !!) - %a - ?+ -.q.don ~|(%unsupported !!) - %a q.q.don - %c (lurk ((hard (list)) src) p.q.don) - %d (lure src p.q.don) - == - :: - %c - =+ dst=(lore ((hard ,@) src)) - %- role - ?+ -.q.don ~|(%unsupported !!) - %a ((hard (list ,@t)) q.q.don) - %c (lurk dst p.q.don) - == - == - :: - -Use udon to change noun - - ~zod/try=> (lump [%a %a 20 25] 20) - 25 - ~zod/try=> (lump [%a %d [[%0 1] [%0 1]] [%0 2]] 20) - [20 20] - ~zod/try=> (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale') - 11.473.670.267.251 - ~zod/try=> (,@t (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale')) - ''' - sa - lo - ''' - ~zod/try=> (,@t (lump [%c %c `1 [%| ~['le'] ~['lo' 'ma']] ~] 'sa\0ale')) - ''' - sa - ma - lo - ''' - ------------------------------------------------------------------------- - -### `++lure` - -Patch `a` - - ++ lure :: apply tree diff - |= [a=* b=upas] - ^- * - ?^ -.b - [$(b -.b) $(b +.b)] - ?+ -.b ~|(%unsupported !!) - %0 .*(a [0 p.b]) - %1 .*(a [1 p.b]) - == - -Patch a by references to axis and literal. - - ~zod/try=> (lure ~[1 2] [[%0 2] [%1 3] [%0 7]]) - [1 3 0] - ~zod/try=> (lure ~[1 2 4] [[%0 2] [%1 3] [%0 7]]) - [1 3 4 0] - ------------------------------------------------------------------------- - -### `++limp` - -Reverse patch - - ++ limp :: invert patch - |= don=udon ^- udon - :- p.don - ?+ -.q.don ~|(%unsupported !!) - %a [%a q.q.don p.q.don] - %c [%c (berk p.q.don)] - %d [%d q.q.don p.q.don] - == - :: - -Reverse a patch (preprocessor unchanged) - - ~zod/try=> (limp [%a %a 20 40]) - [p=%a q=[%a p=40 q=20]] - ~zod/try=> (limp [%c %c ~[`20 [%| ~[52 53] ~[51]] `6]]) - [p=%c q=[%c p=~[[%.y p=20] [%.n p=~[51] q=~[52 53]] [%.y p=6]]]] - ~zod/try=> (limp [%a %d [[%0 1] [%0 1]] [%0 2]]) - [p=%a q=[%d p=[%0 p=2] q=[p=[%0 p=1] q=[%0 p=1]]]] - ------------------------------------------------------------------------- - -### `++hump` - -Prep for diff - - ++ hump :: general prepatch - |= [pum=umph src=*] ^- * - ?+ pum ~|(%unsupported !!) - %a src - %b (cue ((hard ,@) src)) - %c (lore ((hard ,@) src)) - == - :: - -Prep atom for diff: leave alone, cue, or split by newlines. - - ~zod/try=> (hump %a ~) - 0 - ~zod/try=> (hump %a 40) - 40 - ~zod/try=> (hump %c 40) - [40 0] - ~zod/try=> (hump %c 'as') - [29.537 0] - ~zod/try=> (hump %c 'as\0alok') - [29.537 7.040.876 0] - ~zod/try=> (hump %b 0vph) - [1 1] - ------------------------------------------------------------------------- - -### `++husk` - -Atomize post diff - - ++ husk :: unprepatch - |= [pum=umph dst=*] ^- * - ?+ pum ~|(%unsupported !!) - %a dst - %b (jam dst) - %c (role ((hard (list ,@)) dst)) - == - :: - -Re-atomize after diff: leave alone, jam, or join with newlines. - - ~zod/try=> (husk %a 0) - 0 - ~zod/try=> (husk %a 40) - 40 - ~zod/try=> (husk %c [40 0]) - 2.600 - ~zod/try=> (rip 3 (,@ (husk %c [40 0]))) - ~[40 10] - ~zod/try=> (husk %c [%as 0]) - 684.897 - ~zod/try=> (husk %c [%as 0]) - 684.897 - ~zod/try=> (,@t (husk %c [%as 0])) - ''' - as - ''' - ~zod/try=> (husk %c [%as %lok 0]) - 2.932.876.065.272.673 - ~zod/try=> (,@t (husk %c [%as %lok 0])) - ''' - as - lok - ''' - ~zod/try=> (husk %b [1 1]) - 817 - ~zod/try=> (,@uv (husk %b [1 1])) - 0vph - ~zod/try=> ~0ph - [1 1] - ------------------------------------------------------------------------- - -### `++lurk` - -Apply list patch - - ++ lurk :: apply list patch - |* [hel=(list) rug=(urge)] - ^+ hel - =+ war=`_hel`~ - |- ^+ hel - ?~ rug (flop war) - ?- -.i.rug - & - %= $ - rug t.rug - hel (slag p.i.rug hel) - war (weld (flop (scag p.i.rug hel)) war) - == - :: - | - %= $ - rug t.rug - hel =+ gur=(flop p.i.rug) - |- ^+ hel - ?~ gur hel - ?>(&(?=(^ hel) =(i.gur i.hel)) $(hel t.hel, gur t.gur)) - war (weld q.i.rug war) - == - == - :: - -Amend list using an urge: list of `[%& {number skipped}]` and -`[%| old new]` - - ~zod/try=> (lurk "hema" `(urge char)`~[`1 [%| "e" "ru"] `2]) - "hurma" - ~zod/try=> (lurk "koltep" `(urge char)`~[`3 [%| "et" ""] `1]) - "kolp" - ------------------------------------------------------------------------- - -### `++lusk` - -`lcs` to list patch - - ++ lusk :: lcs to list patch - |* [hel=(list) hev=(list) lcs=(list)] - =+ ^= rag - ^- $% [& p=@ud] - [| p=_lcs q=_lcs] - == - [%& 0] - => .(rag [p=rag q=*(list ,_rag)]) - =< abet =< main - |% - ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag)) - ++ done - |= new=_p.rag - ^+ rag - ?- -.p.rag - | ?- -.new - | [[%| (weld p.new p.p.rag) (weld q.new q.p.rag)] q.rag] - & [new [p.rag q.rag]] - == - & ?- -.new - | [new ?:(=(0 p.p.rag) q.rag [p.rag q.rag])] - & [[%& (add p.p.rag p.new)] q.rag] - == - == - :: - ++ main - |- ^+ + - ?~ hel - ?~ hev - ?>(?=(~ lcs) +) - $(hev t.hev, rag (done %| ~ [i.hev ~])) - ?~ hev - $(hel t.hel, rag (done %| [i.hel ~] ~)) - ?~ lcs - +(rag (done %| (flop hel) (flop hev))) - ?: =(i.hel i.lcs) - ?: =(i.hev i.lcs) - $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1)) - $(hev t.hev, rag (done %| ~ [i.hev ~])) - ?: =(i.hev i.lcs) - $(hel t.hel, rag (done %| [i.hel ~] ~)) - $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~])) - -- - -Using a common sequence, generate urge from two lists - - ~zod/try=> (lusk "hamok" "hasok" "haok") - ~[[%.y p=2] [%.n p="m" q="s"] [%.y p=2]] - ~zod/try=> (lusk "hamok" "hasok" "hak") - ~[[%.y p=2] [%.n p="om" q="os"] [%.y p=1]] - ~zod/try=> (lusk "telroga" "tesomga" "teoga") - ~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]] - ~zod/try=> (lurk "telroga" `(urge char)`~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]]) - "tesomga" - ------------------------------------------------------------------------- - -### `++nude` - -Tree change - - ++ nude :: tree change - |= [a=* b=*] - ^- [p=upas q=upas] - =< [p=(tred a b) q=(tred b a)] - |% - ++ axes :: locs of nouns - |= [a=@ b=*] ^- (map ,* axis) - =+ c=*(map ,* axis) - |- ^- (map ,* axis) - => .(c (~(put by c) b a)) - ?@ b - c - %- ~(uni by c) - %- ~(uni by $(a (mul 2 a), b -.b)) - $(a +((mul 2 a)), b +.b) - :: - ++ tred :: diff a->b - |= [a=* b=*] ^- upas - =| c=(unit ,*) - =+ d=(axes 1 a) - |- ^- upas - => .(c (~(get by d) b)) - ?~ c - ?@ b - [%1 b] - =+ e=^-(upas [$(b -.b) $(b +.b)]) - ?- e - [[%1 *] [%1 *]] [%1 [p.p.e p.q.e]] - * e - == - [%0 u.c] - -- - -Generate tree diff from two nouns. - - ~zod/try=> (nude 40 20) - [p=[%1 p=20] q=[%1 p=40]] - ~zod/try=> (nude [5 5] 5) - [p=[%0 p=3] q=[p=[%0 p=1] q=[%0 p=1]]] - ~zod/try=> (nude "sam" "sal") - [ p=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=108] q=[%0 p=15]]]] - q=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=109] q=[%0 p=15]]]] - ] - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ew.md b/web/docs/dev/hoon/library/2ew.md deleted file mode 100644 index ffbb96245..000000000 --- a/web/docs/dev/hoon/library/2ew.md +++ /dev/null @@ -1,439 +0,0 @@ -section 2eW, lite number theory -=============================== - -### `++egcd` - -GCD - - ++ egcd :: schneier's egcd - |= [a=@ b=@] - =+ si - =+ [c=(sun a) d=(sun b)] - =+ [u=[c=(sun 1) d=--0] v=[c=--0 d=(sun 1)]] - |- ^- [d=@ u=@ v=@] - ?: =(--0 c) - [(abs d) d.u d.v] - :: ?> ?& =(c (sum (pro (sun a) c.u) (pro (sun b) c.v))) - :: =(d (sum (pro (sun a) d.u) (pro (sun b) d.v))) - :: == - =+ q=(fra d c) - %= $ - c (dif d (pro q c)) - d c - u [(dif d.u (pro q c.u)) c.u] - v [(dif d.v (pro q c.v)) c.v] - == - :: - -Greatest common denominator - - ~zod/try=> (egcd 20 15) - [d=5 u=2 v=1] - ~zod/try=> (egcd 24 16) - [d=8 u=2 v=1] - ~zod/try=> (egcd 7 5) - [d=1 u=3 v=6] - ~zod/try=> (egcd (shaf ~ %ham) (shaf ~ %sam)) - [ d=1 - u=59.983.396.314.566.203.239.184.568.129.921.874.787 - v=38.716.650.351.034.402.960.165.718.823.532.275.722 - ] - ------------------------------------------------------------------------- - -### `++pram` - -Probable prime - - ++ pram :: rabin-miller - |= a=@ ^- ? - ?: ?| =(0 (end 0 1 a)) - =(1 a) - =+ b=1 - |- ^- ? - ?: =(512 b) - | - ?|(=+(c=+((mul 2 b)) &(!=(a c) =(a (mul c (div a c))))) $(b +(b))) - == - | - =+ ^= b - =+ [s=(dec a) t=0] - |- ^- [s=@ t=@] - ?: =(0 (end 0 1 s)) - $(s (rsh 0 1 s), t +(t)) - [s t] - ?> =((mul s.b (bex t.b)) (dec a)) - =+ c=0 - |- ^- ? - ?: =(c 64) - & - =+ d=(~(raw og (add c a)) (met 0 a)) - =+ e=(~(exp fo a) s.b d) - ?& ?| =(1 e) - =+ f=0 - |- ^- ? - ?: =(e (dec a)) - & - ?: =(f (dec t.b)) - | - $(e (~(pro fo a) e e), f +(f)) - == - $(c +(c)) - == - :: - -Probable prime test - - ~zod/try=> (pram 31) - %.y - ~zod/try=> =+(a=2 |-(?:(=(a 31) ~ [i=(mod 31 a) t=$(a +(a))]))) - ~[1 1 3 1 1 3 7 4 1 9 7 5 3 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1] - ~zod/try=> =+(a=2 |-(?:(=(a 31) ~ [i=(mod 30 a) t=$(a +(a))]))) - ~[0 0 2 0 0 2 6 3 0 8 6 4 2 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0] - ~zod/try=> (pram 256) - %.n - ~zod/try=> (pram (dec (bex 127))) - %.y - ------------------------------------------------------------------------- - -### `++ramp` - -`r-m` prime - - ++ ramp :: make r-m prime - |= [a=@ b=(list ,@) c=@] ^- @ux :: [bits snags seed] - => .(c (shas %ramp c)) - =+ d=_@ - |- - ?: =((mul 100 a) d) - ~|(%ar-ramp !!) - =+ e=(~(raw og c) a) - ?: &((levy b |=(f=@ !=(1 (mod e f)))) (pram e)) - e - $(c +(c), d (shax d)) - :: - -Random `a` bit prime, which isn't 1 modulo a list of other numbers, -using salt `c`. - - ~zod/try=> (ramp 20 ~ %hamelok) - 0xf.1f0d - ~zod/try=> (ramp 20 ~ %hameloe) - 0x2.d341 - ~zod/try=> (ramp 5 ~ %kole) - 0x1f - ~zod/try=> (ramp 7 ~ %kole) - 0x4f - ~zod/try=> (ramp 7 ~[0x4e] %kole) - 0x43 - ~zod/try=> `@uw`(ramp 128 ~ %late) - 0w3y.irKIL.l-pp1.2CkG4.3lsTF - ------------------------------------------------------------------------- - -### `++fo` - -Prime engine - - ++ fo :: modulo prime - |_ a=@ - -XX DO NOT RERUN GET.LS, THERE EXIST ARM COLLISIONS - -Core for performing arithmetic modulo a prime number - - ~zod/try=> ~(. fo 79) - <7.get [@ud <373.jdd 100.kzl 1.ypj %164>]> - ------------------------------------------------------------------------- - -### `++dif` - -Difference - - ++ dif - |= [b=@ c=@] - (sit (sub (add a b) (sit c))) - :: - -Subtract - - ~zod/try=> (~(dif fo 79) 10 5) - 5 - ~zod/try=> (~(dif fo 79) 5 10) - 74 - ------------------------------------------------------------------------- - -### `++exp` - -Exponent - - ++ exp - |= [b=@ c=@] - ?: =(0 b) - 1 - =+ d=$(b (rsh 0 1 b)) - =+ e=(pro d d) - ?:(=(0 (end 0 1 b)) e (pro c e)) - :: - -Exponent - - ~zod/try=> (~(exp fo 79) 3 5) - 46 - ------------------------------------------------------------------------- - -### `++fra` - -Divide - - ++ fra - |= [b=@ c=@] - (pro b (inv c)) - :: - -Divide - - ~zod/try=> (~(fra fo 79) 20 4) - 5 - ~zod/try=> (~(fra fo 79) 7 11) - 15 - ------------------------------------------------------------------------- - -### `++inv` - -Inverse - - ++ inv - |= b=@ - =+ c=(dul:si u:(egcd b a) a) - c - :: - -Multiplicative inverse - - ~zod/try=> (~(inv fo 79) 12) - 33 - ~zod/try=> (~(pro fo 79) 12 33) - 1 - ~zod/try=> (~(inv fo 79) 0) - 0 - ------------------------------------------------------------------------- - -### `++pro` - -Product - - ++ pro - |= [b=@ c=@] - (sit (mul b c)) - :: - -Product - - ~zod/try=> (~(pro fo 79) 5 10) - 50 - ~zod/try=> (~(pro fo 79) 5 20) - 21 - ------------------------------------------------------------------------- - -### `++sit` - -Bounds - - ++ sit - |= b=@ - (mod b a) - :: - -Bounds check - - ~zod/try=> (~(sit fo 79) 9) - 9 - ~zod/try=> (~(sit fo 79) 99) - 20 - ------------------------------------------------------------------------- - -### `++sum` - -Sum - - ++ sum - |= [b=@ c=@] - (sit (add b c)) - -- - -Add - - ~zod/try=> (~(sum fo 79) 9 9) - 18 - ~zod/try=> (~(sum fo 79) 70 9) - 0 - ------------------------------------------------------------------------- - -### `++ga` - - ++ ga :: GF (bex p.a) - |= a=[p=@ q=@ r=@] :: dim poly gen - =+ si=(bex p.a) - =+ ma=(dec si) - => |% - -RSA internals - -XX document - ------------------------------------------------------------------------- - -### `++dif` - - ++ dif :: add and sub - |= [b=@ c=@] - ~| [%dif-ga a] - ?> &((lth b si) (lth c si)) - (mix b c) - :: - -XX document - ------------------------------------------------------------------------- - -### `++dub` - - ++ dub :: mul by x - |= b=@ - ~| [%dub-ga a] - ?> (lth b si) - ?: =(1 (cut 0 [(dec p.a) 1] b)) - (dif (sit q.a) (sit (lsh 0 1 b))) - (lsh 0 1 b) - :: - -XX document - ------------------------------------------------------------------------- - -### `++pro` - - ++ pro :: slow multiply - |= [b=@ c=@] - ?: =(0 b) - 0 - ?: =(1 (dis 1 b)) - (dif c $(b (rsh 0 1 b), c (dub c))) - $(b (rsh 0 1 b), c (dub c)) - :: - -XX document - ------------------------------------------------------------------------- - -### `++toe` - - ++ toe :: exp/log tables - =+ ^= nu - |= [b=@ c=@] - ^- (map ,@ ,@) - =+ d=*(map ,@ ,@) - |- - ?: =(0 c) - d - %= $ - c (dec c) - d (~(put by d) c b) - == - =+ [p=(nu 0 (bex p.a)) q=(nu ma ma)] - =+ [b=1 c=0] - |- ^- [p=(map ,@ ,@) q=(map ,@ ,@)] - ?: =(ma c) - [(~(put by p) c b) q] - %= $ - b (pro r.a b) - c +(c) - p (~(put by p) c b) - q (~(put by q) b c) - == - :: - -XX document - ------------------------------------------------------------------------- - -### `++sit` - - ++ sit :: reduce - |= b=@ - (mod b (bex p.a)) - -- - -XX document - ------------------------------------------------------------------------- - -### `++fra` - - ++ fra :: divide - |= [b=@ c=@] - (pro b (inv c)) - :: - -XX document - ------------------------------------------------------------------------- - -### `++inv` - - ++ inv :: invert - |= b=@ - ~| [%inv-ga a] - =+ c=(~(get by q) b) - ?~ c !! - =+ d=(~(get by p) (sub ma u.c)) - (need d) - :: - -XX document - ------------------------------------------------------------------------- - -### `++pow` - - ++ pow :: exponent - |= [b=@ c=@] - =+ [d=1 e=c f=0] - |- - ?: =(p.a f) - d - ?: =(1 (cut 0 [f 1] b)) - $(d (pro d e), e (pro e e), f +(f)) - $(e (pro e e), f +(f)) - :: - -XX document - ------------------------------------------------------------------------- - -### `++pro` - - ++ pro :: multiply - |= [b=@ c=@] - ~| [%pro-ga a] - =+ d=(~(get by q) b) - ?~ d 0 - =+ e=(~(get by q) c) - ?~ e 0 - =+ f=(~(get by p) (mod (add u.d u.e) ma)) - (need f) - -- - -XX document - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ex.md b/web/docs/dev/hoon/library/2ex.md deleted file mode 100644 index c29a2b018..000000000 --- a/web/docs/dev/hoon/library/2ex.md +++ /dev/null @@ -1,717 +0,0 @@ -section 2eX, jetted crypto -========================== - ------------------------------------------------------------------------- - -### `++aesc` - - ++ aesc :: AES-256 - ~% %aesc + ~ - |% - -XX document - -### `++en` - - ++ en :: ECB enc - ~/ %en - |= [a=@I b=@H] ^- @uxH - =+ ahem - (be & (ex a) b) - -XX document - -### `++de` - - ++ de :: ECB dec - ~/ %de - |= [a=@I b=@H] ^- @uxH - =+ ahem - (be | (ix (ex a)) b) - -- - -XX document - -### `++ahem` - - ++ ahem :: AES helpers - :: XX should be in aesc, isn't for performance reasons - => - =+ =+ [gr=(ga 8 0x11b 3) few==>(fe .(a 5))] - =+ [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few] - [pro=pro dif=dif pow=pow ror=ror nnk=8 nnb=4 nnr=14] - => |% - -XX document - -### `++cipa` - - ++ cipa :: AES params - $_ ^? |% - -XX document - -### `++co` - - ++ co [0xe 0xb 0xd 0x9] - -XX document - -### `++ix` - - ++ ix :: key expand, inv - |= a=@ ^- @ - =+ [i=1 j=_@ b=_@ c=co:pin] - |- - ?: =(nnr i) - a - => .(b (cut 7 [i 1] a)) - => .(b (rep 5 (mcol (pode 5 4 b) c))) - => .(j (sub nnr i)) - %= $ - i +(i) - a - %+ can 7 - :~ [i (cut 7 [0 i] a)] - [1 b] - [j (cut 7 [+(i) j] a)] - == - == - -- - :: - -XX document - -### `++ro` - - ++ ro [0 3 2 1] - -XX document - -### `++su` - - ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. - 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. - ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. - 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. - f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. - 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. - 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. - 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. - 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. - 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. - 849d.8da7.5746.155e.dab9.edfd.5048.706c. - 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. - 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. - 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. - cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. - fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 - -- - :: - -XX document - -### `++pen` - - ++ pen :: encrypt - ^- cipa - |% - -XX document - -### `++co` - - ++ co [0xe 0xb 0xd 0x9] - -XX document - -### `++ix` - - ++ ix :: key expand, inv - |= a=@ ^- @ - =+ [i=1 j=_@ b=_@ c=co:pin] - |- - ?: =(nnr i) - a - => .(b (cut 7 [i 1] a)) - => .(b (rep 5 (mcol (pode 5 4 b) c))) - => .(j (sub nnr i)) - %= $ - i +(i) - a - %+ can 7 - :~ [i (cut 7 [0 i] a)] - [1 b] - [j (cut 7 [+(i) j] a)] - == - == - -- - :: - -XX document - -### `++ro` - - ++ ro [0 3 2 1] - -XX document - -### `++su` - - ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. - 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. - ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. - 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. - f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. - 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. - 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. - 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. - 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. - 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. - 849d.8da7.5746.155e.dab9.edfd.5048.706c. - 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. - 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. - 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. - cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. - fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 - -- - :: - -XX document - -### `++pin` - - ++ pin :: decrypt - ^- cipa - |% - -XX document - -### `++co` - - ++ co [0xe 0xb 0xd 0x9] - -XX document - -### `++ix` - - ++ ix :: key expand, inv - |= a=@ ^- @ - =+ [i=1 j=_@ b=_@ c=co:pin] - |- - ?: =(nnr i) - a - => .(b (cut 7 [i 1] a)) - => .(b (rep 5 (mcol (pode 5 4 b) c))) - => .(j (sub nnr i)) - %= $ - i +(i) - a - %+ can 7 - :~ [i (cut 7 [0 i] a)] - [1 b] - [j (cut 7 [+(i) j] a)] - == - == - -- - :: - -XX document - -### `++ro` - - ++ ro [0 3 2 1] - -XX document - -### `++su` - - ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. - 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. - ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. - 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. - f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. - 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. - 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. - 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. - 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. - 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. - 849d.8da7.5746.155e.dab9.edfd.5048.706c. - 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. - 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. - 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. - cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. - fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 - -- - :: - -XX document - -### `++mcol` - - ++ mcol - |= [a=(list ,@) b=[p=@ q=@ r=@ s=@]] ^- (list ,@) - =+ c=[p=_@ q=_@ r=_@ s=_@] - |- ^- (list ,@) - ?~ a ~ - => .(p.c (cut 3 [0 1] i.a)) - => .(q.c (cut 3 [1 1] i.a)) - => .(r.c (cut 3 [2 1] i.a)) - => .(s.c (cut 3 [3 1] i.a)) - :_ $(a t.a) - %+ rep 3 - %+ turn - %- limo - :~ [[p.c p.b] [q.c q.b] [r.c r.b] [s.c s.b]] - [[p.c s.b] [q.c p.b] [r.c q.b] [s.c r.b]] - [[p.c r.b] [q.c s.b] [r.c p.b] [s.c q.b]] - [[p.c q.b] [q.c r.b] [r.c s.b] [s.c p.b]] - == - |= [a=[@ @] b=[@ @] c=[@ @] d=[@ @]] - :(dif (pro a) (pro b) (pro c) (pro d)) - :: - -XX document - -### `++pode` - - ++ pode :: explode to block - |= [a=bloq b=@ c=@] ^- (list ,@) - =+ d=(rip a c) - =+ m=(met a c) - |- - ?: =(m b) - d - $(m +(m), d (weld d (limo [0 ~]))) - -XX document - -### `++sube` - - ++ sube :: s-box word - |= [a=@ b=@] ^- @ - (rep 3 (turn (pode 3 4 a) |=(c=@ (cut 3 [c 1] b)))) - -- - |% - -XX document - -### `++be` - - ++ be :: block cipher - |= [a=? b=@ c=@H] ^- @uxH - ~| %be-aesc - => %= . - + - => + - |% - -XX document - -### `++ankh` - - ++ ankh - |= [a=cipa b=@ c=@] - (pode 5 nnb (cut 5 [(mul (ix.a b) nnb) nnb] c)) - -XX document - -### `++sark` - - ++ sark - |= [c=(list ,@) d=(list ,@)] ^- (list ,@) - ?~ c ~ - ?~ d !! - [(mix i.c i.d) $(c t.c, d t.d)] - -XX document - -### `++srow` - - ++ srow - |= [a=cipa b=(list ,@)] ^- (list ,@) - =+ [c=0 d=~ e=ro.a] - |- - ?: =(c nnb) - d - :_ $(c +(c)) - %+ rep 3 - %+ turn - (limo [0 p.e] [1 q.e] [2 r.e] [3 s.e] ~) - |= [f=@ g=@] - (cut 3 [f 1] (snag (mod (add g c) nnb) b)) - -XX document - -### `++subs` - - ++ subs - |= [a=cipa b=(list ,@)] ^- (list ,@) - ?~ b ~ - [(sube i.b su.a) $(b t.b)] - -- - == - =+ [d=?:(a pen pin) e=(pode 5 nnb c) f=1] - => .(e (sark e (ankh d 0 b))) - |- - ?. =(nnr f) - => .(e (subs d e)) - => .(e (srow d e)) - => .(e (mcol e co.d)) - => .(e (sark e (ankh d f b))) - $(f +(f)) - => .(e (subs d e)) - => .(e (srow d e)) - => .(e (sark e (ankh d nnr b))) - (rep 5 e) - -XX document - -### `++ex` - - ++ ex :: key expand - |= a=@I ^- @ - =+ [b=a c=0 d=su:pen i=nnk] - |- - ?: =(i (mul nnb +(nnr))) - b - => .(c (cut 5 [(dec i) 1] b)) - => ?: =(0 (mod i nnk)) - => .(c (ror 3 1 c)) - => .(c (sube c d)) - .(c (mix c (pow (dec (div i nnk)) 2))) - ?: &((gth nnk 6) =(4 (mod i nnk))) - .(c (sube c d)) - . - => .(c (mix c (cut 5 [(sub i nnk) 1] b))) - => .(b (can 5 [i b] [1 c] ~)) - $(i +(i)) - -XX document - -### `++ix` - - ++ ix :: key expand, inv - |= a=@ ^- @ - =+ [i=1 j=_@ b=_@ c=co:pin] - |- - ?: =(nnr i) - a - => .(b (cut 7 [i 1] a)) - => .(b (rep 5 (mcol (pode 5 4 b) c))) - => .(j (sub nnr i)) - %= $ - i +(i) - a - %+ can 7 - :~ [i (cut 7 [0 i] a)] - [1 b] - [j (cut 7 [+(i) j] a)] - == - == - -- - :: - -XX document - -### `++curt` - - ++ curt :: curve25519 - |= [a=@ b=@] - => %= . - + - => + - =+ =+ [p=486.662 q=(sub (bex 255) 19)] - =+ fq=~(. fo q) - [p=p q=q fq=fq] - |% - -XX document - -### `++cla` - - ++ cla - |= raw=@ - =+ low=(dis 248 (cut 3 [0 1] raw)) - =+ hih=(con 64 (dis 127 (cut 3 [31 1] raw))) - =+ mid=(cut 3 [1 30] raw) - (can 3 [[1 low] [30 mid] [1 hih] ~]) - -XX document - -### `++sqr` - - ++ sqr |=(a=@ (mul a a)) - -XX document - -### `++inv` - - ++ inv |=(a=@ (~(exp fo q) (sub q 2) a)) - -XX document - -### `++cad` - - ++ cad - |= [n=[x=@ z=@] m=[x=@ z=@] d=[x=@ z=@]] - =+ ^= xx - ;: mul 4 z.d - %- sqr %- abs:si - %+ dif:si - (sun:si (mul x.m x.n)) - (sun:si (mul z.m z.n)) - == - =+ ^= zz - ;: mul 4 x.d - %- sqr %- abs:si - %+ dif:si - (sun:si (mul x.m z.n)) - (sun:si (mul z.m x.n)) - == - [(sit.fq xx) (sit.fq zz)] - -XX document - -### `++cub` - - ++ cub - |= [x=@ z=@] - =+ ^= xx - %+ mul - %- sqr %- abs:si - (dif:si (sun:si x) (sun:si z)) - (sqr (add x z)) - =+ ^= zz - ;: mul 4 x z - :(add (sqr x) :(mul p x z) (sqr z)) - == - [(sit.fq xx) (sit.fq zz)] - -- - == - =+ one=[b 1] - =+ i=253 - =+ r=one - =+ s=(cub one) - |- - ?: =(i 0) - =+ x=(cub r) - (sit.fq (mul -.x (inv +.x))) - =+ m=(rsh 0 i a) - ?: =(0 (mod m 2)) - $(i (dec i), s (cad r s one), r (cub r)) - $(i (dec i), r (cad r s one), s (cub s)) - :: - -XX document - -### `++ed` - - ++ ed :: ed25519 - => - =+ =+ [b=256 q=(sub (bex 255) 19)] - =+ fq=~(. fo q) - =+ ^= l - %+ add - (bex 252) - 27.742.317.777.372.353.535.851.937.790.883.648.493 - =+ d=(dif.fq 0 (fra.fq 121.665 121.666)) - =+ ii=(exp.fq (div (dec q) 4) 2) - [b=b q=q fq=fq l=l d=d ii=ii] - ~% %coed +> ~ - |% - -### `++norm` - - ++ norm |=(x=@ ?:(=(0 (mod x 2)) x (sub q x))) - :: - -XX document - -### `++xrec` - - ++ xrec :: recover x-coord - |= y=@ ^- @ - =+ ^= xx - %+ mul (dif.fq (mul y y) 1) - (inv.fq +(:(mul d y y))) - =+ x=(exp.fq (div (add 3 q) 8) xx) - ?: !=(0 (dif.fq (mul x x) (sit.fq xx))) - (norm (pro.fq x ii)) - (norm x) - :: - -XX document - -### `++ward` - - ++ ward :: edwards multiply - |= [pp=[@ @] qq=[@ @]] ^- [@ @] - =+ dp=:(pro.fq d -.pp -.qq +.pp +.qq) - =+ ^= xt - %+ pro.fq - %+ sum.fq - (pro.fq -.pp +.qq) - (pro.fq -.qq +.pp) - (inv.fq (sum.fq 1 dp)) - =+ ^= yt - %+ pro.fq - %+ sum.fq - (pro.fq +.pp +.qq) - (pro.fq -.pp -.qq) - (inv.fq (dif.fq 1 dp)) - [xt yt] - :: - -XX document - -### `++scam` - - ++ scam :: scalar multiply - |= [pp=[@ @] e=@] ^- [@ @] - ?: =(0 e) - [0 1] - =+ qq=$(e (div e 2)) - => .(qq (ward qq qq)) - ?: =(1 (dis 1 e)) - (ward qq pp) - qq - :: - -XX document - -### `++etch` - - ++ etch :: encode point - |= pp=[@ @] ^- @ - (can 0 ~[[(sub b 1) +.pp] [1 (dis 1 -.pp)]]) - :: - -XX document - -### `++curv` - - ++ curv :: point on curve? - |= [x=@ y=@] ^- ? - .= 0 - %+ dif.fq - %+ sum.fq - (pro.fq (sub q (sit.fq x)) x) - (pro.fq y y) - (sum.fq 1 :(pro.fq d x x y y)) - :: - -XX document - -### `++deco` - - ++ deco :: decode point - |= s=@ ^- (unit ,[@ @]) - =+ y=(cut 0 [0 (dec b)] s) - =+ si=(cut 0 [(dec b) 1] s) - =+ x=(xrec y) - => .(x ?:(!=(si (dis 1 x)) (sub q x) x)) - =+ pp=[x y] - ?. (curv pp) - ~ - [~ pp] - :: - -XX document - -### `++bb` - - ++ bb - =+ bby=(pro.fq 4 (inv.fq 5)) - [(xrec bby) bby] - :: - -- - ~% %ed + ~ - |% - -XX document - -### `++puck` - - ++ puck :: public key - ~/ %puck - |= sk=@I ^- @ - ?: (gth (met 3 sk) 32) !! - =+ h=(shal (rsh 0 3 b) sk) - =+ ^= a - %+ add - (bex (sub b 2)) - (lsh 0 3 (cut 0 [3 (sub b 5)] h)) - =+ aa=(scam bb a) - (etch aa) - -XX document - -### `++suck` - - ++ suck :: keypair from seed - |= se=@I ^- @uJ - =+ pu=(puck se) - (can 0 ~[[b se] [b pu]]) - :: - -XX document - -### `++sign` - - ++ sign :: certify - ~/ %sign - |= [m=@ se=@] ^- @ - =+ sk=(suck se) - =+ pk=(cut 0 [b b] sk) - =+ h=(shal (rsh 0 3 b) sk) - =+ ^= a - %+ add - (bex (sub b 2)) - (lsh 0 3 (cut 0 [3 (sub b 5)] h)) - =+ ^= r - =+ hm=(cut 0 [b b] h) - =+ ^= i - %+ can 0 - :~ [b hm] - [(met 0 m) m] - == - (shaz i) - =+ rr=(scam bb r) - =+ ^= ss - =+ er=(etch rr) - =+ ^= ha - %+ can 0 - :~ [b er] - [b pk] - [(met 0 m) m] - == - (~(sit fo l) (add r (mul (shaz ha) a))) - (can 0 ~[[b (etch rr)] [b ss]]) - :: - -XX document - -### `++veri` - - ++ veri :: validate - ~/ %veri - |= [s=@ m=@ pk=@] ^- ? - ?: (gth (div b 4) (met 3 s)) | - ?: (gth (div b 8) (met 3 pk)) | - =+ cb=(rsh 0 3 b) - =+ rr=(deco (cut 0 [0 b] s)) - ?~ rr | - =+ aa=(deco pk) - ?~ aa | - =+ ss=(cut 0 [b b] s) - =+ ha=(can 3 ~[[cb (etch u.rr)] [cb pk] [(met 3 m) m]]) - =+ h=(shaz ha) - =((scam bb ss) (ward u.rr (scam u.aa h))) - :: - -- - :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -XX document - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/2ey.md b/web/docs/dev/hoon/library/2ey.md deleted file mode 100644 index 2e2f95db6..000000000 --- a/web/docs/dev/hoon/library/2ey.md +++ /dev/null @@ -1,399 +0,0 @@ -section 2eY, SHA-256 -==================== - -### `++shad` - - ++ shad |=(ruz=@ (shax (shax ruz))) :: double sha-256 - -XX document - -### `++shaf` - - ++ shaf :: half sha-256 - |= [sal=@ ruz=@] - =+ haz=(shas sal ruz) - (mix (end 7 1 haz) (rsh 7 1 haz)) - :: - -XX document - -### `++shak` - - ++ shak :: XX shd be PBKDF - |= [who=@p wud=@] - (shas (mix %shak who) wud) - :: - -XX document - -### `++sham` - - ++ sham :: noun hash - |= yux=* ^- @uvH ^- @ - ?@ yux - (shaf %mash yux) - (shaf %sham (jam yux)) - :: - -XX document - -### `++shas` - - ++ shas :: salted hash - |= [sal=@ ruz=@] - (shax (mix sal (shax ruz))) - :: - -XX document - -### `++shax` - - ++ shax :: sha-256 - ~/ %shax - |= ruz=@ ^- @ - ~| %sha - =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] - =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 (met 3 ruz)) - =+ ^= ful - %+ can 0 - :~ [ral ruz] - [8 128] - [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0] - [64 (~(net fe 6) ral)] - == - =+ lex=(met 9 ful) - =+ ^= kbx 0xc671.78f2.bef9.a3f7.a450.6ceb.90be.fffa. - 8cc7.0208.84c8.7814.78a5.636f.748f.82ee. - 682e.6ff3.5b9c.ca4f.4ed8.aa4a.391c.0cb3. - 34b0.bcb5.2748.774c.1e37.6c08.19a4.c116. - 106a.a070.f40e.3585.d699.0624.d192.e819. - c76c.51a3.c24b.8b70.a81a.664b.a2bf.e8a1. - 9272.2c85.81c2.c92e.766a.0abb.650a.7354. - 5338.0d13.4d2c.6dfc.2e1b.2138.27b7.0a85. - 1429.2967.06ca.6351.d5a7.9147.c6e0.0bf3. - bf59.7fc7.b003.27c8.a831.c66d.983e.5152. - 76f9.88da.5cb0.a9dc.4a74.84aa.2de9.2c6f. - 240c.a1cc.0fc1.9dc6.efbe.4786.e49b.69c1. - c19b.f174.9bdc.06a7.80de.b1fe.72be.5d74. - 550c.7dc3.2431.85be.1283.5b01.d807.aa98. - ab1c.5ed5.923f.82a4.59f1.11f1.3956.c25b. - e9b5.dba5.b5c0.fbcf.7137.4491.428a.2f98 - =+ ^= hax 0x5be0.cd19.1f83.d9ab.9b05.688c.510e.527f. - a54f.f53a.3c6e.f372.bb67.ae85.6a09.e667 - =+ i=0 - |- ^- @ - ?: =(i lex) - (rep 5 (turn (rip 5 hax) net)) - =+ ^= wox - =+ dux=(cut 9 [i 1] ful) - =+ wox=(rep 5 (turn (rip 5 dux) net)) - =+ j=16 - |- ^- @ - ?: =(64 j) - wox - =+ :* l=(wac (sub j 15) wox) - m=(wac (sub j 2) wox) - n=(wac (sub j 16) wox) - o=(wac (sub j 7) wox) - == - =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh 0 3 l)) - =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh 0 10 m)) - =+ z=:(sum n x o y) - $(wox (con (lsh 5 j z) wox), j +(j)) - =+ j=0 - =+ :* a=(wac 0 hax) - b=(wac 1 hax) - c=(wac 2 hax) - d=(wac 3 hax) - e=(wac 4 hax) - f=(wac 5 hax) - g=(wac 6 hax) - h=(wac 7 hax) - == - |- ^- @ - ?: =(64 j) - %= ^$ - i +(i) - hax %+ rep 5 - :~ (sum a (wac 0 hax)) - (sum b (wac 1 hax)) - (sum c (wac 2 hax)) - (sum d (wac 3 hax)) - (sum e (wac 4 hax)) - (sum f (wac 5 hax)) - (sum g (wac 6 hax)) - (sum h (wac 7 hax)) - == - == - =+ l=:(mix (ror 0 2 a) (ror 0 13 a) (ror 0 22 a)) :: s0 - =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj - =+ n=(sum l m) :: t2 - =+ o=:(mix (ror 0 6 e) (ror 0 11 e) (ror 0 25 e)) :: s1 - =+ p=(mix (dis e f) (dis (inv e) g)) :: ch - =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1 - $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) - :: - -XX document - -### `++shaw` - - ++ shaw :: hash to nbits - |= [sal=@ len=@ ruz=@] - (~(raw og (shas sal (mix len ruz))) len) - :: - -XX document - -### `++og` - - ++ og :: shax-powered rng - ~/ %og - |_ a=@ - -XX document - -### `++rad` - - ++ rad :: random in range - |= b=@ ^- @ - =+ c=(raw (met 0 b)) - ?:((lth c b) c $(a +(a))) - :: - -XX document - -### `++rads` - - ++ rads :: random continuation - |= b=@ - =+ r=(rad b) - [r +>.$(a (shas %og-s r))] - -XX document - -### `++raw` - - ++ raw :: random bits - ~/ %raw - |= b=@ ^- @ - %+ can - 0 - =+ c=(shas %og-a (mix b a)) - |- ^- (list ,[@ @]) - ?: =(0 b) - ~ - =+ d=(shas %og-b (mix b (mix a c))) - ?: (lth b 256) - [[b (end 0 b d)] ~] - [[256 d] $(c d, b (sub b 256))] - -XX document - -### `++raws` - - ++ raws :: random bits continuation - |= b=@ - =+ r=(raw b) - [r +>.$(a (shas %og-s r))] - -- - -XX document - -### `++shaz` - - ++ shaz :: sha-512 - |= ruz=@ ^- @ - (shal [(met 3 ruz) ruz]) - -XX document - -### `++shal` - - ++ shal :: sha-512 with length - ~/ %shal - |= [len=@ ruz=@] ^- @ - => .(ruz (cut 3 [0 len] ruz)) - =+ [few==>(fe .(a 6)) wac=|=([a=@ b=@] (cut 6 [a 1] b))] - =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 len) - =+ ^= ful - %+ can 0 - :~ [ral ruz] - [8 128] - [(mod (sub 1.920 (mod (add 8 ral) 1.024)) 1.024) 0] - [128 (~(net fe 7) ral)] - == - =+ lex=(met 10 ful) - =+ ^= kbx 0x6c44.198c.4a47.5817.5fcb.6fab.3ad6.faec. - 597f.299c.fc65.7e2a.4cc5.d4be.cb3e.42b6. - 431d.67c4.9c10.0d4c.3c9e.be0a.15c9.bebc. - 32ca.ab7b.40c7.2493.28db.77f5.2304.7d84. - 1b71.0b35.131c.471b.113f.9804.bef9.0dae. - 0a63.7dc5.a2c8.98a6.06f0.67aa.7217.6fba. - f57d.4f7f.ee6e.d178.eada.7dd6.cde0.eb1e. - d186.b8c7.21c0.c207.ca27.3ece.ea26.619c. - c671.78f2.e372.532b.bef9.a3f7.b2c6.7915. - a450.6ceb.de82.bde9.90be.fffa.2363.1e28. - 8cc7.0208.1a64.39ec.84c8.7814.a1f0.ab72. - 78a5.636f.4317.2f60.748f.82ee.5def.b2fc. - 682e.6ff3.d6b2.b8a3.5b9c.ca4f.7763.e373. - 4ed8.aa4a.e341.8acb.391c.0cb3.c5c9.5a63. - 34b0.bcb5.e19b.48a8.2748.774c.df8e.eb99. - 1e37.6c08.5141.ab53.19a4.c116.b8d2.d0c8. - 106a.a070.32bb.d1b8.f40e.3585.5771.202a. - d699.0624.5565.a910.d192.e819.d6ef.5218. - c76c.51a3.0654.be30.c24b.8b70.d0f8.9791. - a81a.664b.bc42.3001.a2bf.e8a1.4cf1.0364. - 9272.2c85.1482.353b.81c2.c92e.47ed.aee6. - 766a.0abb.3c77.b2a8.650a.7354.8baf.63de. - 5338.0d13.9d95.b3df.4d2c.6dfc.5ac4.2aed. - 2e1b.2138.5c26.c926.27b7.0a85.46d2.2ffc. - 1429.2967.0a0e.6e70.06ca.6351.e003.826f. - d5a7.9147.930a.a725.c6e0.0bf3.3da8.8fc2. - bf59.7fc7.beef.0ee4.b003.27c8.98fb.213f. - a831.c66d.2db4.3210.983e.5152.ee66.dfab. - 76f9.88da.8311.53b5.5cb0.a9dc.bd41.fbd4. - 4a74.84aa.6ea6.e483.2de9.2c6f.592b.0275. - 240c.a1cc.77ac.9c65.0fc1.9dc6.8b8c.d5b5. - efbe.4786.384f.25e3.e49b.69c1.9ef1.4ad2. - c19b.f174.cf69.2694.9bdc.06a7.25c7.1235. - 80de.b1fe.3b16.96b1.72be.5d74.f27b.896f. - 550c.7dc3.d5ff.b4e2.2431.85be.4ee4.b28c. - 1283.5b01.4570.6fbe.d807.aa98.a303.0242. - ab1c.5ed5.da6d.8118.923f.82a4.af19.4f9b. - 59f1.11f1.b605.d019.3956.c25b.f348.b538. - e9b5.dba5.8189.dbbc.b5c0.fbcf.ec4d.3b2f. - 7137.4491.23ef.65cd.428a.2f98.d728.ae22 - =+ ^= hax 0x5be0.cd19.137e.2179.1f83.d9ab.fb41.bd6b. - 9b05.688c.2b3e.6c1f.510e.527f.ade6.82d1. - a54f.f53a.5f1d.36f1.3c6e.f372.fe94.f82b. - bb67.ae85.84ca.a73b.6a09.e667.f3bc.c908 - =+ i=0 - |- ^- @ - ?: =(i lex) - (rep 6 (turn (rip 6 hax) net)) - =+ ^= wox - =+ dux=(cut 10 [i 1] ful) - =+ wox=(rep 6 (turn (rip 6 dux) net)) - =+ j=16 - |- ^- @ - ?: =(80 j) - wox - =+ :* l=(wac (sub j 15) wox) - m=(wac (sub j 2) wox) - n=(wac (sub j 16) wox) - o=(wac (sub j 7) wox) - == - =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh 0 7 l)) - =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh 0 6 m)) - =+ z=:(sum n x o y) - $(wox (con (lsh 6 j z) wox), j +(j)) - =+ j=0 - =+ :* a=(wac 0 hax) - b=(wac 1 hax) - c=(wac 2 hax) - d=(wac 3 hax) - e=(wac 4 hax) - f=(wac 5 hax) - g=(wac 6 hax) - h=(wac 7 hax) - == - |- ^- @ - ?: =(80 j) - %= ^$ - i +(i) - hax %+ rep 6 - :~ (sum a (wac 0 hax)) - (sum b (wac 1 hax)) - (sum c (wac 2 hax)) - (sum d (wac 3 hax)) - (sum e (wac 4 hax)) - (sum f (wac 5 hax)) - (sum g (wac 6 hax)) - (sum h (wac 7 hax)) - == - == - =+ l=:(mix (ror 0 28 a) (ror 0 34 a) (ror 0 39 a)) :: S0 - =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj - =+ n=(sum l m) :: t2 - =+ o=:(mix (ror 0 14 e) (ror 0 18 e) (ror 0 41 e)) :: S1 - =+ p=(mix (dis e f) (dis (inv e) g)) :: ch - =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1 - $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) - :: - -XX document - -### `++shan` - - ++ shan :: sha-1 (deprecated) - |= ruz=@ - =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] - =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 (met 3 ruz)) - =+ ^= ful - %+ can 0 - :~ [ral ruz] - [8 128] - [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0] - [64 (~(net fe 6) ral)] - == - =+ lex=(met 9 ful) - =+ kbx=0xca62.c1d6.8f1b.bcdc.6ed9.eba1.5a82.7999 - =+ hax=0xc3d2.e1f0.1032.5476.98ba.dcfe.efcd.ab89.6745.2301 - =+ i=0 - |- - ?: =(i lex) - (rep 5 (flop (rip 5 hax))) - =+ ^= wox - =+ dux=(cut 9 [i 1] ful) - =+ wox=(rep 5 (turn (rip 5 dux) net)) - =+ j=16 - |- ^- @ - ?: =(80 j) - wox - =+ :* l=(wac (sub j 3) wox) - m=(wac (sub j 8) wox) - n=(wac (sub j 14) wox) - o=(wac (sub j 16) wox) - == - =+ z=(rol 0 1 :(mix l m n o)) - $(wox (con (lsh 5 j z) wox), j +(j)) - =+ j=0 - =+ :* a=(wac 0 hax) - b=(wac 1 hax) - c=(wac 2 hax) - d=(wac 3 hax) - e=(wac 4 hax) - == - |- ^- @ - ?: =(80 j) - %= ^$ - i +(i) - hax %+ rep 5 - :~ - (sum a (wac 0 hax)) - (sum b (wac 1 hax)) - (sum c (wac 2 hax)) - (sum d (wac 3 hax)) - (sum e (wac 4 hax)) - == - == - =+ fx=(con (dis b c) (dis (not 5 1 b) d)) - =+ fy=:(mix b c d) - =+ fz=:(con (dis b c) (dis b d) (dis c d)) - =+ ^= tem - ?: &((gte j 0) (lte j 19)) - :(sum (rol 0 5 a) fx e (wac 0 kbx) (wac j wox)) - ?: &((gte j 20) (lte j 39)) - :(sum (rol 0 5 a) fy e (wac 1 kbx) (wac j wox)) - ?: &((gte j 40) (lte j 59)) - :(sum (rol 0 5 a) fz e (wac 2 kbx) (wac j wox)) - :(sum (rol 0 5 a) fy e (wac 3 kbx) (wac j wox)) - $(j +(j), a tem, b a, c (rol 0 30 b), d c, e d) - -XX document - --- diff --git a/web/docs/dev/hoon/library/2ez.md b/web/docs/dev/hoon/library/2ez.md deleted file mode 100644 index fd089bf61..000000000 --- a/web/docs/dev/hoon/library/2ez.md +++ /dev/null @@ -1,250 +0,0 @@ -section 2eZ, OLD rendering -========================== - -### `++show` - - ++ show :: XX deprecated, use type - |= vem=* - |^ ^- tank - ?: ?=(@ vem) - [%leaf (mesc (trip vem))] - ?- vem - [s=~ c=*] - [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])] - :: - [s=%a c=@] [%leaf (mesc (trip c.vem))] - [s=%b c=*] (shop c.vem |=(a=@ ~(rub at a))) - [s=[%c p=@] c=*] - :+ %palm - [['.' ~] ['-' ~] ~ ~] - [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~] - :: - [s=%d c=*] (shop c.vem |=(a=@ ~(rud at a))) - [s=%k c=*] (tank c.vem) - [s=%h c=*] - ?: =(0 c.vem) :: XX remove after 220 - [%leaf '#' ~] - :+ %rose - [['/' ~] ['/' ~] ~] - =+ yol=((list ,@ta) c.vem) - (turn yol |=(a=@ta [%leaf (trip a)])) - :: - [s=%o c=*] - %= $ - vem - :- [%m '%h:<[%d %d].[%d %d]>'] - [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~] - == - :: - [s=%p c=*] (shop c.vem |=(a=@ ~(rup at a))) - [s=%q c=*] (shop c.vem |=(a=@ ~(r at a))) - [s=%r c=*] $(vem [[%r ' ' '{' '}'] c.vem]) - [s=%t c=*] (shop c.vem |=(a=@ ~(rt at a))) - [s=%v c=*] (shop c.vem |=(a=@ ~(ruv at a))) - [s=%x c=*] (shop c.vem |=(a=@ ~(rux at a))) - [s=[%m p=@] c=*] (shep p.s.vem c.vem) - [s=[%r p=@] c=*] - $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem]) - :: - [s=[%r p=@ q=@ r=@] c=*] - :+ %rose - :* p=(mesc (trip p.s.vem)) - q=(mesc (trip q.s.vem)) - r=(mesc (trip r.s.vem)) - == - |- ^- (list tank) - ?@ c.vem - ~ - [^$(vem -.c.vem) $(c.vem +.c.vem)] - :: - [s=%z c=*] $(vem [[%r %$ %$ %$] c.vem]) - * !! - == - -XX document - -### `++shep` - - ++ shep - |= [fom=@ gar=*] - ^- tank - =+ l=(met 3 fom) - =+ i=0 - :- %leaf - |- ^- tape - ?: (gte i l) - ~ - =+ c=(cut 3 [i 1] fom) - ?. =(37 c) - (weld (mesc [c ~]) $(i +(i))) - =+ d=(cut 3 [+(i) 1] fom) - ?. .?(gar) - ['\\' '#' $(i (add 2 i))] - (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar)) - :: - -XX document - -### `++shop` - - ++ shop - |= [aug=* vel=$+(a=@ tape)] - ^- tank - ?: ?=(@ aug) - [%leaf (vel aug)] - :+ %rose - [[' ' ~] ['[' ~] [']' ~]] - => .(aug `*`aug) - |- ^- (list tank) - ?: ?=(@ aug) - [^$ ~] - [^$(aug -.aug) $(aug +.aug)] - -- - -XX document - -### `++at` - - ++ at - |_ a=@ - -XX document - -### `++r` - - ++ r - ?: ?& (gte (met 3 a) 2) - |- - ?: =(0 a) - & - =+ vis=(end 3 1 a) - ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z'))) - $(a (rsh 3 1 a)) - == - == - rtam - ?: (lte (met 3 a) 2) - rud - rux - :: - -XX document - -### `++rf` - - ++ rf `tape`[?-(a & '&', | '|', * !!) ~] - -XX document - -### `++rn` - - ++ rn `tape`[?>(=(0 a) '~') ~] - -XX document - -### `++rt` - - ++ rt `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])] - -XX document - -### `++rta` - - ++ rta rt - -XX document - -### `++rtam` - - ++ rtam `tape`['%' (trip a)] - -XX document - -### `++rub` - - ++ rub `tape`['0' 'b' (rum 2 ~ |=(b=@ (add '0' b)))] - -XX document - -### `++rud` - - ++ rud (rum 10 ~ |=(b=@ (add '0' b))) - -XX document - -### `++rum` - - ++ rum - |= [b=@ c=tape d=$+(@ @)] - ^- tape - ?: =(0 a) - [(d 0) c] - =+ e=0 - |- ^- tape - ?: =(0 a) - c - =+ f=&(!=(0 e) =(0 (mod e ?:(=(10 b) 3 4)))) - %= $ - a (div a b) - c [(d (mod a b)) ?:(f [?:(=(10 b) ',' '-') c] c)] - e +(e) - == - :: - -XX document - -### `++rup` - - ++ rup - =+ b=(met 3 a) - ^- tape - :- '-' - |- ^- tape - ?: (gth (met 5 a) 1) - %+ weld - $(a (rsh 5 1 a), b (sub b 4)) - `tape`['-' '-' $(a (end 5 1 a), b 4)] - ?: =(0 b) - ['~' ~] - ?: (lte b 1) - (trip (tos:po a)) - |- ^- tape - ?: =(2 b) - =+ c=(rsh 3 1 a) - =+ d=(end 3 1 a) - (weld (trip (tod:po c)) (trip (tos:po (mix c d)))) - =+ c=(rsh 3 2 a) - =+ d=(end 3 2 a) - (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)]) - :: - -XX document - -### `++ruv` - - ++ ruv - ^- tape - :+ '0' - 'v' - %^ rum - 64 - ~ - |= b=@ - ?: =(63 b) - '+' - ?: =(62 b) - '-' - ?:((lth b 26) (add 65 b) ?:((lth b 52) (add 71 b) (sub b 4))) - :: - -XX document - -### `++rux` - - ++ rux `tape`['0' 'x' (rum 16 ~ |=(b=@ (add b ?:((lth b 10) 48 87))))] - -- - :::::::::::::::::::::::::::::::::::::::::::::::::::::: :: - -XX document - ------------------------------------------------------------------------- diff --git a/web/docs/dev/hoon/library/3ba.md b/web/docs/dev/hoon/library/3ba.md deleted file mode 100644 index 56ebab299..000000000 --- a/web/docs/dev/hoon/library/3ba.md +++ /dev/null @@ -1,67 +0,0 @@ -section 3bA, lite number theory -=============================== - -### `++fu` - - ++ fu :: modulo (mul p q) - |= a=[p=@ q=@] - =+ b=?:(=([0 0] a) 0 (~(inv fo p.a) (~(sit fo p.a) q.a))) - |% - -XX document - -### `++dif` - - ++ dif - |= [c=[@ @] d=[@ @]] - [(~(dif fo p.a) -.c -.d) (~(dif fo q.a) +.c +.d)] - :: - -XX document - -### `++exp` - - ++ exp - |= [c=@ d=[@ @]] - :- (~(exp fo p.a) (mod c (dec p.a)) -.d) - (~(exp fo q.a) (mod c (dec q.a)) +.d) - :: - -XX document - -### `++out` - - ++ out :: garner's formula - |= c=[@ @] - %+ add - +.c - (mul q.a (~(pro fo p.a) b (~(dif fo p.a) -.c (~(sit fo p.a) +.c)))) - :: - -XX document - -### `++pro` - - ++ pro - |= [c=[@ @] d=[@ @]] - [(~(pro fo p.a) -.c -.d) (~(pro fo q.a) +.c +.d)] - :: - -XX document - -### `++sum` - - ++ sum - |= [c=[@ @] d=[@ @]] - [(~(sum fo p.a) -.c -.d) (~(sum fo q.a) +.c +.d)] - :: - -XX document - -### `++sit` - - ++ sit - |= c=@ - [(mod c p.a) (mod c q.a)] - -XX document diff --git a/web/docs/dev/hoon/library/3bb.md b/web/docs/dev/hoon/library/3bb.md deleted file mode 100644 index 28d6071c0..000000000 --- a/web/docs/dev/hoon/library/3bb.md +++ /dev/null @@ -1,600 +0,0 @@ -section 3bB, cryptosuites -========================= - -### `++crua` - - ++ crua !: :: cryptosuite A (RSA) - ^- acru - =| [mos=@ pon=(unit ,[p=@ q=@ r=[p=@ q=@] s=_*fu])] - => |% - -XX document - -### `++mx` - - ++ mx (dec (met 0 mos)) :: bit length - -XX document - -### `++dap` - - ++ dap :: OEAP decode - |= [wid=@ xar=@ dog=@] ^- [p=@ q=@] - =+ pav=(sub wid xar) - =+ qoy=(cut 0 [xar pav] dog) - =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy)) - [dez (mix qoy (shaw %pad-a pav dez))] - :: - -XX document - -### `++pad` - - ++ pad :: OEAP encode - |= [wid=@ rax=[p=@ q=@] meg=@] ^- @ - =+ pav=(sub wid p.rax) - ?> (gte pav (met 0 meg)) - ^- @ - =+ qoy=(mix meg (shaw %pad-a pav q.rax)) - =+ dez=(mix q.rax (shaw %pad-b p.rax qoy)) - (can 0 [p.rax dez] [pav qoy] ~) - |% - -XX document - -### `++pull` - - ++ pull |=(a=@ (~(exp fo mos) 3 a)) - -XX document - -### `++push` - - ++ push |=(a=@ (~(exp fo mos) 5 a)) - -XX document - -### `++pump` - - ++ pump - |= a=@ ^- @ - ?~ pon !! - (out.s.u.pon (exp.s.u.pon p.r.u.pon (sit.s.u.pon a))) - :: - -XX document - -### `++punt` - - ++ punt - |= a=@ ^- @ - ?~ pon !! - (out.s.u.pon (exp.s.u.pon q.r.u.pon (sit.s.u.pon a))) - |% - -XX document - -### `++as` - - ++ as - => |% - -XX document - -### `++haul` - - ++ haul :: revealing haul - |= a=pass - !! - ^? - |% ++ seal - |= [a=pass b=@ c=@] - ^- @ - !! - -XX document - -### `++seal` - - - XX document - - ###++sign - - ``` - ++ sign - |= [a=@ b=@] ^- @ - !! - ``` - - XX document - - ###++sure - - ``` - ++ sure - |= [a=@ b=@] - ^- (unit ,@) - !! - ``` - - XX document - - ###++tear - - ``` - ++ tear - |= [a=pass b=@] - ^- (unit ,[p=@ q=@]) - !! - :: - ``` - - XX document - - ###++de - - ``` - ++ de - |+ [key=@ cep=@] ^- (unit ,@) - !! - :: - ``` - - XX document - - ###++dy - - ``` - ++ dy - |+ [a=@ b=@] ^- @ - !! - ``` - - XX document - - ###++en - - ``` - ++ en - |+ [key=@ msg=@] ^- @ux - !! - :: - ``` - - XX document - - ###++ex - - ``` - ++ ex ^? - |% ++ fig ^- @uvH (shaf %bfig puc) - ``` - - XX document - - ###++fig - -XX document - -### `++pac` - - ++ pac ^- @uvG (end 6 1 (shaf %acod sec)) - -XX document - -### `++pub` - - ++ pub ^- pass (cat 3 'b' puc) - -XX document - -### `++sec` - - ++ sec ^- ring sed - :: - -XX document - -### `++nu` - - ++ nu - ^? - |% ++ com - |= a=@ - ^+ ^?(..nu) - ..nu(sed ~, puc a) - :: - -XX document - -### `++elcm` - - ++ elcm - |= [a=@ b=@] - (div (mul a b) d:(egcd a b)) - :: - -XX document - -### `++eldm` - - ++ eldm - |= [a=@ b=@ c=@] - (~(inv fo (elcm (dec b) (dec c))) a) - :: - -XX document - -### `++ersa` - - ++ ersa - |= [a=@ b=@] - [a b [(eldm 3 a b) (eldm 5 a b)] (fu a b)] - ^? - |% ++ com - |= a=@ - ^+ ^?(..nu) - ..nu(mos a, pon ~) - :: - -XX document - -### `++com` - - - XX document - - ###++pit - - ``` - ++ pit - |= [a=@ b=@] - ^+ ^?(..nu) - ..nu(sed b, puc (puck:ed b)) - :: - ``` - - XX document - - ###++nol - - ``` - ++ nol - |= a=@ - ^+ ^?(..nu) - ..nu(sed a, puc (puck:ed a)) - ``` - - XX document - - ###++bruw - - ``` - ++ bruw :: create keypair - |= [a=@ b=@] :: width seed - ^- acru - (pit:nu:crua a b) - :: - ``` - - XX document - - ###++haul - - ``` - ++ haul :: revealing haul - |= a=pass - !! - ^? - |% ++ seal - |= [a=pass b=@ c=@] - ^- @ - !! - ``` - - XX document - - ###++weur - - ``` - ++ weur :: activate secret key - |= a=ring - ^- acru - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] - ?> =('A' mag) - (nol:nu:crua bod) - :: - ``` - - XX document - - ###++trua - - ``` - ++ trua :: test rsa - |= msg=@tas - ^- @ - =+ ali=(bruw 1.024 (shax 'ali')) - =+ bob=(bruw 1.024 (shax 'bob')) - =+ tef=(sign:as.ali [0 msg]) - =+ lov=(sure:as.ali [0 tef]) - ?. &(?=(^ lov) =(msg u.lov)) - ~|(%test-fail-sign !!) - =+ key=(shax (shax (shax msg))) - =+ sax=(seal:as.ali pub:ex.bob key msg) - =+ tin=(tear:as.bob pub:ex.ali sax) - ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin)) - ~|(%test-fail-seal !!) - msg - :: - ``` - - XX document - - ###++crub - - ``` - ++ crub :: cryptosuite B (Ed) - ^- acru - =| [puc=pass sed=ring] - => |% - ``` - - XX document - - ###++dap - - ``` - ++ dap :: OEAP decode - |= [wid=@ xar=@ dog=@] ^- [p=@ q=@] - =+ pav=(sub wid xar) - =+ qoy=(cut 0 [xar pav] dog) - =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy)) - [dez (mix qoy (shaw %pad-a pav dez))] - :: - ``` - - XX document - - ###++pad - - ``` - ++ pad :: OEAP encode - |= [wid=@ rax=[p=@ q=@] meg=@] ^- @ - =+ pav=(sub wid p.rax) - ?> (gte pav (met 0 meg)) - ^- @ - =+ qoy=(mix meg (shaw %pad-a pav q.rax)) - =+ dez=(mix q.rax (shaw %pad-b p.rax qoy)) - (can 0 [p.rax dez] [pav qoy] ~) - |% - ``` - - XX document - - ###++as - - ``` - ++ as - => |% - ``` - - XX document - - ###++haul - - ``` - ++ haul :: revealing haul - |= a=pass - !! - ^? - |% ++ seal - |= [a=pass b=@ c=@] - ^- @ - !! - ``` - - XX document - - ###++seal - -XX document - -### `++sign` - - ++ sign - |= [a=@ b=@] ^- @ - !! - -XX document - -### `++sure` - - ++ sure - |= [a=@ b=@] - ^- (unit ,@) - !! - -XX document - -### `++tear` - - ++ tear - |= [a=pass b=@] - ^- (unit ,[p=@ q=@]) - !! - :: - -XX document - -### `++de` - - ++ de - |+ [key=@ cep=@] ^- (unit ,@) - !! - :: - -XX document - -### `++dy` - - ++ dy - |+ [a=@ b=@] ^- @ - !! - -XX document - -### `++en` - - ++ en - |+ [key=@ msg=@] ^- @ux - !! - :: - -XX document - -### `++ex` - - ++ ex ^? - |% ++ fig ^- @uvH (shaf %bfig puc) - -XX document - -### `++fig` - - - XX document - - ###++pac - - ``` - ++ pac ^- @uvG (end 6 1 (shaf %acod sec)) - ``` - - XX document - - ###++pub - - ``` - ++ pub ^- pass (cat 3 'b' puc) - ``` - - XX document - - ###++sec - - ``` - ++ sec ^- ring sed - :: - ``` - - XX document - - ###++nu - - ``` - ++ nu - ^? - |% ++ com - |= a=@ - ^+ ^?(..nu) - ..nu(sed ~, puc a) - :: - ``` - - XX document - - ###++com - -XX document - -### `++pit` - - ++ pit - |= [a=@ b=@] - ^+ ^?(..nu) - ..nu(sed b, puc (puck:ed b)) - :: - -XX document - -### `++nol` - - ++ nol - |= a=@ - ^+ ^?(..nu) - ..nu(sed a, puc (puck:ed a)) - -XX document - -### `++brew` - - ++ brew :: create keypair - |= [a=@ b=@] :: width seed - ^- acru - (pit:nu:crub a b) - :: - -XX document - -### `++hail` - - ++ hail :: activate public key - |= a=pass - ^- acru - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] - ?> =('b' mag) - (com:nu:crub bod) - :: - -XX document - -### `++wear` - - ++ wear :: activate secret key - |= a=ring - ^- acru - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] - ?> =('b' mag) - (nol:nu:crub bod) - :: - -XX document - -### `++trub` - - ++ trub :: test ed - |= msg=@tas - ^- @ - =+ ali=(brew 1.024 (shax 'ali')) - =+ bob=(brew 1.024 (shax 'bob')) - =+ tef=(sign:as.ali [0 msg]) - =+ lov=(sure:as.ali [0 tef]) - ?. &(?=(^ lov) =(msg u.lov)) - ~|(%test-fail-sign !!) - =+ key=(shax (shax (shax msg))) - =+ sax=(seal:as.ali pub:ex.bob key msg) - =+ tin=(tear:as.bob pub:ex.ali sax) - ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin)) - ~|(%test-fail-seal !!) - msg - :: - -XX document - -### `++hmac` - - ++ hmac :: HMAC-SHA1 - |= [key=@ mes=@] - =+ ip=(fil 3 64 0x36) - =+ op=(fil 3 64 0x5c) - =+ ^= kex - ?: (gth (met 3 key) 64) - (lsh 3 44 (shan (swap 3 key))) - (lsh 3 (sub 64 (met 3 key)) (swap 3 key)) - =+ inn=(shan (swap 3 (cat 3 (swap 3 mes) (mix ip kex)))) - (shan (swap 3 (cat 3 inn (mix op kex)))) - :: - -XX document diff --git a/web/docs/dev/hoon/library/3bc.md b/web/docs/dev/hoon/library/3bc.md deleted file mode 100644 index 7264cfdba..000000000 --- a/web/docs/dev/hoon/library/3bc.md +++ /dev/null @@ -1,382 +0,0 @@ -section 3bC, Gregorian UTC -========================== - -### `++dawn` - -Weekday of Jan 1 - - ++ dawn :: weekday of jan 1 - |= yer=@ud - =+ yet=(sub yer 1) - %- mod :_ 7 - :(add 1 (mul 5 (mod yet 4)) (mul 4 (mod yet 100)) (mul 6 (mod yet 400))) - :: - -Computes which day of the week January 1st falls on for a year `yer`, -producing an atom. Weeks are zero-indexed beginning on Sunday. - -`yer` is an unsigned decimal, [`@ud`](). - - ~zod/try=> (dawn 2.015) - 4 - ~zod/try=> (dawn 1) - 1 - ~zod/try=> (dawn 0) - ! subtract-underflow - ! exit - ------------------------------------------------------------------------- - -### `++daws` - -Weekday of date - - ++ daws :: weekday of date - |= yed=date - %- mod :_ 7 - (add (dawn y.yed) (sub (yawn [y.yed m.yed d.t.yed]) (yawn y.yed 1 1))) - :: - -Produces the day of the week of a given date `yed` as an atom. Weeks are -zero-indexed beginning on Sunday. - -`yed` is a [`date`](). - - ~zod/try=> (daws [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]) - 5 - ~zod/try=> (daws (yore -<-)) - 2 - -(second example always returns the current date). - ------------------------------------------------------------------------- - -### `++deal` - -Add leap seconds - - ++ deal :: to leap sec time - |= yer=@da - =+ n=0 - =+ yud=(yore yer) - |- ^- date - ?: (gte yer (add (snag n lef:yu) ~s1)) - (yore (year yud(s.t (add n s.t.yud)))) - ?: &((gte yer (snag n lef:yu)) (lth yer (add (snag n lef:yu) ~s1))) - yud(s.t (add +(n) s.t.yud)) - ?: =(+(n) (lent lef:yu)) - (yore (year yud(s.t (add +(n) s.t.yud)))) - $(n +(n)) - :: - -Produces a [`date`]() with the 25 leap seconds added. - -`yer` is an absolute date, [`@da`](). - - ~zod/try=> (yore (bex 127)) - [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=8 f=~]] - ~zod/try=> (deal `@da`(bex 127)) - [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=33 f=~]] - ~zod/try=> (yore (bex 126)) - [[a=%.n y=146.138.512.088] m=6 t=[d=19 h=7 m=45 s=4 f=~]] - ------------------------------------------------------------------------- - -### `++lead` - -Subtract leap seconds - - ++ lead :: from leap sec time - |= ley=date - =+ ler=(year ley) - =+ n=0 - |- ^- @da - =+ led=(sub ler (mul n ~s1)) - ?: (gte ler (add (snag n les:yu) ~s1)) - led - ?: &((gte ler (snag n les:yu)) (lth ler (add (snag n les:yu) ~s1))) - ?: =(s.t.ley 60) - (sub led ~s1) - led - ?: =(+(n) (lent les:yu)) - (sub led ~s1) - $(n +(n)) - :: - -Produces an absolute date ([`@ud`]()) with the 25 leap seconds -subtracted. - -`ley` is a [`date`](). - - ~zod/try=> (yore `@da`(bex 127)) - [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=8 f=~]] - ~zod/try=> (lead (yore `@da`(bex 127))) - ~226.12.5..15.29.43 - ~zod/try=> (lead (yore `@da`(bex 126))) - ~146138512088-.6.19..07.44.39 - ------------------------------------------------------------------------- - -### `++dust` - -Print UTC format - - ++ dust :: print UTC format - |= yed=date - ^- tape - =+ wey=(daws yed) - ;: weld - `tape`(snag wey (turn wik:yu |=(a=tape (scag 3 a)))) - ", " ~(rud at d.t.yed) " " - `tape`(snag (dec m.yed) (turn mon:yu |=(a=tape (scag 3 a)))) - " " (scag 1 ~(rud at y.yed)) (slag 2 ~(rud at y.yed)) " " - ~(rud at h.t.yed) ":" ~(rud at m.t.yed) ":" ~(rud at s.t.yed) - " " "+0000" - == - :: - -Produces a [tape]() of the date in UTC format. - -`yed` is a [`date`](). - - ~zod/try=> (dust (yore ->-)) - "Tue, 21 Oct 2014 21:35:12 +0000" - ~zod/try=> (dust [[a=%.y y=2.002] m=10 t=[d=11 h=12 m=20 s=55 f=~]]) - "Fri, 11 Oct 2002 12:20:55 +0000" - ------------------------------------------------------------------------- - -### `++stud` - -Parse UTC format - - ++ stud :: parse UTC format - |= cud=tape - ^- (unit date) - =- ?~ tud ~ - `[[%.y &3.u.tud] &2.u.tud &1.u.tud &4.u.tud &5.u.tud &6.u.tud ~] - ^= tud - %+ rust cud - ;~ plug - ;~(pfix (stun [5 5] next) dim:ag) - :: - %+ cook - |= a=tape - =+ b=0 - |- ^- @ - ?: =(a (snag b (turn mon:yu |=(a=tape (scag 3 a))))) - +(b) - $(b +(b)) - (ifix [ace ace] (star alf)) - :: - ;~(sfix dim:ag ace) - ;~(sfix dim:ag col) - ;~(sfix dim:ag col) - dim:ag - (cold ~ (star next)) - == - :: - -Accepts a [tape]() containing a date in UTC format and produces the -[unit]() of a [`date`](). - - ~zod/try=> (stud "Tue, 21 Oct 2014 21:21:55 +0000") - [~ [[a=%.y y=2.014] m=10 t=[d=21 h=21 m=21 s=55 f=~]]] - ~zod/try=> (stud "Wed, 11 Oct 2002 12:20:55 +0000") - [~ [[a=%.y y=2.002] m=10 t=[d=11 h=12 m=20 s=55 f=~]]] - ~zod/try=> (stud "Wed, 11 Oct 2002") - ~ - ------------------------------------------------------------------------- - -### `++unt` - -UGT to UTC time - - ++ unt :: UGT to UTC time - |= a=@da - (div (sub a ~1970.1.1) (bex 64)) - :: - - ~zod/try=/hom> (unt -<-) - 1.413.927.704 - ~zod/try=> (unt ~20014.1.1) - 569.413.670.400 - ~zod/try=> (unt ~2014.1.1) - 1.388.534.400 - -Transforms Urbit Galactic Time to UTC time, producing an atom. - -`a` is an [atom](). - ------------------------------------------------------------------------- - -### `++yu` - -UTC format constants - - ++ yu :: UTC format constants - |% - - ~zod/try=/hom> yu - <4.pgn 250.tmw 41.cmo 414.rvm 101.jzo 1.ypj %164> - ------------------------------------------------------------------------- - -### `++mon` - -Months - - ++ mon ^- (list tape) - :~ "January" "February" "March" "April" "May" "June" "July" - "August" "September" "October" "November" "December" - == - :: - -Produces a list of [tapes]() containing the 12 months of the year. - - ~zod/try=/hom> mon:yu - << - "January" - "February" - "March" - "April" - "May" - "June" - "July" - "August" - "September" - "October" - "November" - "December" - >> - ~zod/try=/hom> (snag 1 mon:yu) - "February" - ------------------------------------------------------------------------- - -### `++wik` - -Weeks - - ++ wik ^- (list tape) - :~ "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" - "Friday" "Saturday" - == - :: - -Produces a list of [tapes]() containing the 7 days of the week, -beginning with Sunday. - - ~zod/try=/hom> wik:yu - <<"Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday">> - ~zod/try=/hom> (snag 2 wik:yu) - "Tuesday" - ~zod/try=/hom> (snag (daws (yore -<-)) wik:yu) - "Tuesday" - ------------------------------------------------------------------------- - -### `++les` - -Leap second dates - - ++ les ^- (list ,@da) - :~ ~2015.7.1 ~2012.7.1 ~2009.1.1 ~2006.1.1 ~1999.1.1 ~1997.7.1 - ~1996.1.1 ~1994.7.1 ~1993.7.1 ~1992.7.1 ~1991.1.1 ~1990.1.1 - ~1988.1.1 ~1985.7.1 ~1983.7.1 ~1982.7.1 ~1981.7.1 ~1980.1.1 - ~1979.1.1 ~1978.1.1 ~1977.1.1 ~1976.1.1 ~1975.1.1 ~1974.1.1 - ~1973.1.1 ~1972.7.1 - == - -Produces a list of the (absolute) dates ([`@da`]) of the 25 leap seconds - - ~zod/try=/hom> les:yu - ~[ - ~2015.7.1 - ~2012.7.1 - ~2009.1.1 - ~2006.1.1 - ~1999.1.1 - ~1997.7.1 - ~1996.1.1 - ~1994.7.1 - ~1993.7.1 - ~1992.7.1 - ~1991.1.1 - ~1990.1.1 - ~1988.1.1 - ~1985.7.1 - ~1983.7.1 - ~1982.7.1 - ~1981.7.1 - ~1980.1.1 - ~1979.1.1 - ~1978.1.1 - ~1977.1.1 - ~1976.1.1 - ~1975.1.1 - ~1974.1.1 - ~1973.1.1 - ~1972.7.1 - ] - ~zod/try=/hom> (snag 2 les:yu) - ~2006.1.1 - ------------------------------------------------------------------------- - -### `++lef` - -Back-shifted leap second dates - - ++ lef ^- (list ,@da) - :~ ~2015.6.30..23.59.59 ~2012.6.30..23.59.59 - ~2008.12.31..23.59.58 ~2005.12.31..23.59.57 - ~1998.12.31..23.59.56 ~1997.6.30..23.59.55 - ~1995.12.31..23.59.54 ~1994.6.30..23.59.53 - ~1993.6.30..23.59.52 ~1992.6.30..23.59.51 - ~1990.12.31..23.59.50 ~1989.12.31..23.59.49 - ~1987.12.31..23.59.48 ~1985.6.30..23.59.47 - ~1983.6.30..23.59.46 ~1982.6.30..23.59.45 - ~1981.6.30..23.59.44 ~1979.12.31..23.59.43 - ~1978.12.31..23.59.42 ~1977.12.31..23.59.41 - ~1976.12.31..23.59.40 ~1975.12.31..23.59.39 - ~1974.12.31..23.59.38 ~1973.12.31..23.59.37 - ~1972.12.31..23.59.36 ~1972.6.30..23.59.35 - == - :: - -Produces a list of absolute dates ([`@da`]()) that represent the Urbit -Galactc Time equivalents of the UTC leap second dates in [`++les`](/doc/hoon/library/3bc#++les). - - ~zod/try=/hom> lef:yu - ~[ - ~2015.6.30..23.59.59 - ~2012.6.30..23.59.59 - ~2008.12.31..23.59.58 - ~2005.12.31..23.59.57 - ~1998.12.31..23.59.56 - ~1997.6.30..23.59.55 - ~1995.12.31..23.59.54 - ~1994.6.30..23.59.53 - ~1993.6.30..23.59.52 - ~1992.6.30..23.59.51 - ~1990.12.31..23.59.50 - ~1989.12.31..23.59.49 - ~1987.12.31..23.59.48 - ~1985.6.30..23.59.47 - ~1983.6.30..23.59.46 - ~1982.6.30..23.59.45 - ~1981.6.30..23.59.44 - ~1979.12.31..23.59.43 - ~1978.12.31..23.59.42 - ~1977.12.31..23.59.41 - ~1976.12.31..23.59.40 - ~1975.12.31..23.59.39 - ~1974.12.31..23.59.38 - ~1973.12.31..23.59.37 - ~1972.12.31..23.59.36 - ~1972.6.30..23.59.35 - ] - ~zod/try=/hom> (snag 2 lef:yu) - ~2005.12.31..23.59.57 diff --git a/web/docs/dev/hoon/library/3bd.md b/web/docs/dev/hoon/library/3bd.md deleted file mode 100644 index d252a62a8..000000000 --- a/web/docs/dev/hoon/library/3bd.md +++ /dev/null @@ -1,1807 +0,0 @@ -section 3bD, JSON and XML -========================= - -### `++moon` - -Mime type to `++cord` - - ++ moon :: mime type to text - |= myn=mite - %+ rap - 3 - |- ^- tape - ?~ myn ~ - ?: =(~ t.myn) (trip i.myn) - (weld (trip i.myn) `tape`['/' $(myn t.myn)]) - :: - -Renders a [mime](http://en.wikipedia.org/wiki/MIME) type path with infix -`/` to a [cord](). - -`myn` is a ++[mite](), a list of [@ta](). - - ~zod/try=> `@t`(moon /image/png) - 'image/png' - ~zod/try=> `@t`(moon /text/x-hoon) - 'text/x-hoon' - ~zod/try=> `@t`(moon /application/x-pnacl) - 'application/x-pnacl' - -### `++perk` - -Parse cube with fork - - ++ perk :: parse cube with fork - |* a=(pole ,@tas) - ?~ a fail - ;~ pose - (cold -.a (jest -.a)) - $(a +.a) - == - :: - -Parser generator. Produces a parser that succeeds upon encountering one -of the [`++term`]()s in a faceless list `a`. - -A- perk is an arm used to parse one of a finite set of options, formally -a choice between terms: if you want to match "true" or "false", and -nothing else, (perk \~[%true %false]) produces the relevant parser, -whose result type is `?(%true %false)`. For more complicated -transformations, a combintation of ++sear and map ++get is recommended, -e.g. `(sear ~(get by (mo ~[[%true &] [%false |]]))) sym)` will have a -similar effect but produce `?(& |)` ,a loobean. However, constructions -such as `(sear (flit ~(has in (sa %true %false %other ~))) sym)` are -needlessly unwieldy. - -`a` is a [`++pole`](), which is a [`++list`]() without [`%face`]()s - - ~zod/try=> (scan "ham" (perk %sam %ham %lam ~)) - %ham - ~zod/try=> (scan "ram" (perk %sam %ham %lam ~)) - ! {1 1} - ! exit - -### `++poja` - -JSON parser core - - ++ poja :: JSON parser core - =< |=(a=cord (rush a apex)) - |% - -JSON parser core: parses a `++cord` `a` to the hoon structure for JSON, -a [`++json`](). - -`a` is [`++cord`](). - - ~zod/try=> (poja '[1,2,3]') - [~ [%a p=~[[%n p=~.1] [%n p=~.2] [%n p=~.3]]]] - ~zod/try=> (poja 'null') - [~ ~] - ~zod/try=> (poja 'invalid{json') - ~ - -### `++apex` - -Parse object - - ++ apex ;~(pose abox obox) :: JSON object - -Top level parsing rule. Parses either a single JSON object, or an array -of JSON objects to a [`++json`](). See also: [`++abox`](), [`++obox`](). - -A- this is now called ++tops, and ++apex is the old ++valu, which -apparently didn't make its way into the docs. Apologies for the -confusion, many things have been restructured in ++shell inconsistently -with current test:urbit.git - - ~zod/try=> (rash '[1,2]' apex:poja) - [%a p=~[[%n p=~.1] [%n p=~.2]]] - ~zod/try=> (rash '{"sam": "kot"}' apex:poja) - [%o p={[p=~.sam q=[%s p=~.kot]]}] - ~zod/try=> (rash 'null' apex:poja) - ! {1 1} - ! exit - -### `++valu` - -Parse value - - ++ valu :: JSON value - %+ knee *json |. ~+ - ;~ pfix spac - ;~ pose - (cold ~ (jest 'null')) - (jify %b bool) - (jify %s stri) - (cook |=(s=tape [%n p=(rap 3 s)]) numb) - abox - obox - == - == - -Parsing rule. Parses JSON values to [`++json`](). - - ~zod/try=> (rash '[1,2]' valu:poja) - [%a p=~[[%n p=~.1] [%n p=~.2]]] - ~zod/try=> (rash '{"sam": "kot"}' valu:poja) - [%o p={[p='sam' q=[%s p=~.kot]]}] - ~zod/try=> (rash 'null' valu:poja) - ~ - ~zod/try=> (rash '20' valu:poja) - [%n p=~.20] - ~zod/try=> (rash '"str"' valu:poja) - [%s p=~.str] - ~zod/try=> (rash 'true' valu:poja) - [%b p=%.y] - -### `++abox` - -Parse array - - ++ abox (stag %a (ifix [sel (ws ser)] (more (ws com) valu))) - -Parsing rule. Parses a JSON array with values enclosed within `[]` and -delimited by a `,`. - - ~zod/try=> (rash '[1, 2,4]' abox:poja) - [[%n p=~.1] ~[[%n p=~.2] [%n p=~.4]]] - -JSON Objects ------------- - -### `++pair` - -Parse key value pair - - ++ pair ;~(plug ;~(sfix (ws stri) (ws col)) valu) - -Parsing rule. Parses a [`++json`]() from a JSON key-value pair of a -string and value delimited by `:`. - - ~zod/try=> (rash '"ham": 2' pair:poja) - ['ham' [%n p=~.2]] - -### `++obje` - -Parse array of objects - - ++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair)) - -Parsing rule. Parses a [`++json`]() from an array of JSON object -key-value pairs that are enclosed within `{}` and separated by `,`. - - ~zod/try=> (rash '{"ham": 2, "lam":true}' obje:poja) - [['ham' [%n p=~.2]] ~[['lam' [%b p=%.y]]]] - -### `++obox` - -Parse boxed object - - ++ obox (stag %o (cook mo obje)) - -Parsing rule. Parses an array of JSON objects to a [`++json`]() map with -a tag of `%o`. See also: [`++json`](). - - ~zod/try=> (rash '{"ham": 2, "lam":true}' obox:poja) - [%o {[p='lam' q=[%b p=%.y]] [p='ham' q=[%n p=~.2]]}] - -JSON Booleans -------------- - -### `++bool` - -Parse boolean - - ++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false'))) - -Parsing rule. Parses a string of either `true` or `false` to a -[`++json`]() boolean. - - ~zod/try=> (rash 'true' bool:poja) - %.y - ~zod/try=> (rash 'false' bool:poja) - %.n - ~zod/try=> (rash 'null' bool:poja) - ! {1 1} - ! exit - -JSON strings ------------- - -### `++stri` - -Parse string - - ++ stri - (cook crip (ifix [doq doq] (star jcha))) - -Parsing rule. Parse a string to a [`++cord`](). A JSON string is a list -of characters enclosed in double quotes along with escaping `\`s, to a -[`++cord`](). See also [`++jcha`](). - - ~zod/try=> (rash '"ham"' stri:poja) - 'ham' - ~zod/try=> (rash '"h\\nam"' stri:poja) - 'h - am' - ~zod/try=> (rash '"This be \\"quoted\\""' stri:poja) - 'This be "quoted"' - -### `++jcha` - -Parse char from string - - ++ jcha ;~(pose ;~(less doq bas prn) esca) :: character in string - -Parsing rule. Parses either a literal or escaped character from a JSON -string to a [`++cord`](). - - ~zod/try=> (rash 'a' jcha:poja) - 'a'. - ~zod/try=> (rash '!' jcha:poja) - '!' - ~zod/try=> (rash '\\"' jcha:poja) - '"' - ~zod/try=> (rash '\\u00a4' jcha:poja) - '¤' - ~zod/try=> (rash '\\n' jcha:poja) - ' - ' - -### `++esca` - -Parse escaped char - - ++ esca :: Escaped character - ;~ pfix bas - ;~ pose - doq fas soq bas - (sear ~(get by `(map ,@t ,@)`(mo b/8 t/9 n/10 f/12 r/13 ~)) low) - ;~(pfix (just 'u') (cook tuft qix:ab)) :: 4-digit hex to UTF-8 - == - -Parsing rule. Parses a backslash-escaped special character, low ASCII, -or UTF16 codepoint, to a [`++cord`](). - - ~zod/try=> (rash 'b' esca:poja) - ! {1 1} - ! exit - ~zod/try=> (rash '\n' esca:poja) - ~ - ~zod/try=> (rash '\\n' esca:poja) - ' - ' - ~zod/try=> `@`(rash '\\r' esca:poja) - 13 - ~zod/try=> (rash '\\u00c4' esca:poja) - 'Ä' - ~zod/try=> (rash '\\u00df' esca:poja) - 'ß' - -JSON numbers ------------- - -A- JSON numbers are stored as cords internally in lieu of full float -support, so ++numb and subarms are really more *validators* than parsers -per se. - -### `++numb` - -Parse number - - ++ numb - ;~ (comp twel) - (mayb (piec hep)) - ;~ pose - (piec (just '0')) - ;~(plug (shim '1' '9') digs) - == - (mayb frac) - (mayb expo) - == - -Parsing rule. Parses decimal numbers with an optional `-`, fractional -part, or exponent part, to a [`++cord`](). - - ~zod/try=> (rash '0' numb:poja) - ~[~~0] - ~zod/try=> (rash '1' numb:poja) - ~[~~1] - ~zod/try=> `tape`(rash '1' numb:poja) - "1" - ~zod/try=> `tape`(rash '12.6' numb:poja) - "12.6" - ~zod/try=> `tape`(rash '-2e20' numb:poja) - "-2e20" - ~zod/try=> `tape`(rash '00e20' numb:poja) - ! {1 2} - ! exit - -### `++digs` - -Parse 1-9 - - ++ digs (star (shim '0' '9')) - -Parsing rule. Parses digits `0` through `9` to a [`++tape`](). - - ~zod/try=> (rash '' digs:poja) - "" - ~zod/try=> (rash '25' digs:poja) - "25" - ~zod/try=> (rash '016' digs:poja) - "016" - ~zod/try=> (rash '7' digs:poja) - "7" - -### `++expo` - -Parse exponent part - - ++ expo :: Exponent part - ;~ (comp twel) - (piec (mask "eE")) - (mayb (piec (mask "+-"))) - digs - == - -Parsing rule. Parses an exponent to a [`++cord`](). An exponent is an -`e`, followed by an optional `+` or `-`, followed by digits. - - ~zod/try=> `tape`(rash 'e7' expo:poja) - "e7" - ~zod/try=> `tape`(rash 'E17' expo:poja) - "E17" - ~zod/try=> `tape`(rash 'E-4' expo:poja) - "E-4" - -### `++frac` - -Fractional part - - ++ frac ;~(plug dot digs) :: Fractional part - -Parsing rule. Parses a dot followed by digits to a [`++cord`](). - - ~zod/try=> (rash '.25' frac:poja) - [~~~. "25"] - ~zod/try=> (rash '.016' frac:poja) - [~~~. "016"] - ~zod/try=> (rash '.7' frac:poja) - [~~~. "7"] - -whitespace ----------- - -### `++spac` - -Parse whitespace - - ++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~])) - -Parsing rule. Parses a whitespace to a [`++tape`](). - - ~zod/try=> (scan "" spac:poja) - "" - ~zod/try=> (scan " " spac:poja) - " " - ~zod/try=> `*`(scan `tape`~[' ' ' ' ' ' `@`9 ' ' ' ' `@`13] spac:poja) - [32 32 32 9 32 32 13 0] - ~zod/try=> (scan " m " spac:poja) - ! {1 4} - ! exit - -### `++ws` - -Allow prefix whitespace - - ++ ws |*(sef=_rule ;~(pfix spac sef)) - -Parser modifier. Produces a rule that allows for a whitespace before -applying `sef`. - -`sef` is a [`++rule`](). - - ~zod/try=> (rash ' 4' digs:poja) - ! {1 1} - ! exit - ~zod/try=> (rash ' 4' (ws digs):poja) - "4" - ~zod/try=> (rash ''' - - 4 - ''' (ws digs):poja) - "4" - -Plumbing --------- - -### `++mayb` - -Maybe parse - - ++ mayb |*(bus=_rule ;~(pose bus (easy ""))) - -Parser modifier. Need to document, an example showing failure. - - ~zod/try=> (abox:poja 1^1 "not-an-array") - [p=[p=1 q=1] q=~] - ~zod/try=> ((mayb abox):poja 1^1 "not-an-array") - [p=[p=1 q=1] q=[~ [p="" q=[p=[p=1 q=1] q="not-an-array"]]]] - -### `++twel` - -Weld two tapes - - ++ twel |=([a=tape b=tape] (weld a b)) - -Concatenates two tapes, `a` and `b`, producing a `++tape`. - -`a` is a [`++tape`](). - -`b` is a [`++tape`](). - - ~zod/try=> (twel "sam" "hok"):poja - ~[~~s ~~a ~~m ~~h ~~o ~~k] - ~zod/try=> (twel "kre" ""):poja - ~[~~k ~~r ~~e] - -### `++piec` - -Parse char to list - - ++ piec - |* bus=_rule - (cook |=(a=@ [a ~]) bus) - :: - -Parser modifer. Parses an atom with `bus` and then wraps it in a -[`++list`](). - -`bus` is a [`++rule`](). - - ~zod/try=> (scan "4" (piec:poja dem:ag)) - [4 ~] - -### `++pojo` - -Print JSON - - ++ pojo :: print json - |= val=json - ^- tape - ?~ val "null" - ?- -.val - %a - ;: weld - "[" - =| rez=tape - |- ^+ rez - ?~ p.val rez - $(p.val t.p.val, rez :(weld rez ^$(val i.p.val) ?~(t.p.val ~ ","))) - "]" - == - :: - %b ?:(p.val "true" "false") - %n (trip p.val) - %s - ;: welp - "\"" - %+ reel - (turn (trip p.val) jesc) - |=([p=tape q=tape] (welp +<)) - "\"" - == - %o - ;: welp - "\{" - =+ viz=(~(tap by p.val) ~) - =| rez=tape - |- ^+ rez - ?~ viz rez - %= $ - viz t.viz - rez - :(welp rez "\"" (trip p.i.viz) "\":" ^$(val q.i.viz) ?~(t.viz ~ ",")) - == - "}" - == - == - :: - -Renders a `++json` `val` as a [`++tape`](). - -`val` is a [`json`](). - - ~zod/try=> (pojo [%n '12.6']) - "12.6" - ~zod/try=> (crip (pojo %n '12.6')) - '12.6' - ~zod/try=> (crip (pojo %s 'samtel')) - '"samtel"' - ~zod/try=> (crip (pojo %a ~[(jone 12) (jape "ha")])) - '[12,"ha"]' - ~zod/try=> (crip (pojo %a ~[(jone 12) ~ (jape "ha")])) - '[12,null,"ha"]' - ~zod/try=> (crip (pojo %o (mo sale/(jone 12) same/b/| ~))) - '{"same":false,"sale":12}' - -### `++poxo` - -Print XML - - ++ poxo :: node to tape - =< |=(a=manx `tape`(apex a ~)) - |_ unq=? :: unq - -Renders a `++manx` `a` as a [`++tape`](). - -`a` is a [`++manx`](). - - ~zod/try=> (poxo ;div;) - "
" - ~zod/try=> (poxo ;div:(p a)) - "

" - ~zod/try=> (poxo ;div:(p:"tree > text" a)) - "

tree > text

" - -### `++apex` - -Inner XML printer - - ++ apex :: top level - |= [mex=manx rez=tape] - ^- tape - ?: ?=([%$ [[%$ *] ~]] g.mex) - (escp v.i.a.g.mex rez) - =+ man=`mane`n.g.mex - =. unq |(unq =(%script man) =(%style man)) - =+ tam=(name man) - =. rez :(weld "" rez) - =+ att=`mart`a.g.mex - :- '<' - %+ welp tam - =. rez ['>' (many c.mex rez)] - ?~(att rez [' ' (attr att rez)]) - :: - -Renders a `++manx` as a [`++tape`](), appending a suffix `rez\`. - -`rez` is a [`++tape`](). - - ~zod/try=> (apex:poxo ;div; "") - "
" - ~zod/try=> (apex:poxo ;div:(p a) ""). - "

" - ~zod/try=> (apex:poxo ;div:(p a) "--sfix") - "

--sfix" - ~zod/try=> (apex:poxo ;div:(p:"tree > text" a) "") - "

tree > text

" - ~zod/try=> (~(apex poxo &) ;div:(p:"tree > text" a) "") - "

tree > text

" - -### `++attr` - -Print attributes - - ++ attr :: attributes to tape - |= [tat=mart rez=tape] - ^- tape - ?~ tat rez - =. rez $(tat t.tat) - ;: weld - (name n.i.tat) - "=\"" - (escp(unq |) v.i.tat '"' ?~(t.tat rez [' ' rez])) - == - -Render XML attributes as a [`++tape`](). - -`tat` is a [`++mart`](). - -`rez` is a [`++tape`](). - - ~zod/try=> (attr:poxo ~ "") - "" - ~zod/try=> (crip (attr:poxo ~[sam/"hem" [%tok %ns]^"reptor"] "")) - 'sam="hem" tok:ns="reptor"' - ~zod/try=> (crip (attr:poxo ~[sam/"hem" [%tok %ns]^"reptor"] "|appen")) - 'sam="hem" tok:ns="reptor"|appen' - -### `++escp` - -Escape XML - - ++ escp :: escape for xml - |= [tex=tape rez=tape] - ?: unq - (weld tex rez) - =+ xet=`tape`(flop tex) - |- ^- tape - ?~ xet rez - %= $ - xet t.xet - rez ?- i.xet - 34 ['&' 'q' 'u' 'o' 't' ';' rez] - 38 ['&' 'a' 'm' 'p' ';' rez] - 39 ['&' '#' '3' '9' ';' rez] - 60 ['&' 'l' 't' ';' rez] - 62 ['&' 'g' 't' ';' rez] - * [i.xet rez] - == - == - :: - -Escapes the XML special characters `"`, `&`, `'`, `<`, `>`. - -`tex`is a [`++tape`](). - -`rez` is a [`++tape`](). - - ~zod/try=> (escp:poxo "astra" ~) - ~[~~a ~~s ~~t ~~r ~~a] - ~zod/try=> `tape`(escp:poxo "astra" ~) - "astra" - ~zod/try=> `tape`(escp:poxo "x > y" ~) - "x > y" - ~zod/try=> `tape`(~(escp poxo &) "x > y" ~) - "x > y" - -### `++name` - -Print name - - ++ name :: name to tape - |= man=mane ^- tape - ?@ man (trip man) - (weld (trip -.man) `tape`[':' (trip +.man)]) - :: - -Renders a `++mane` as a `++tape`. - -`man` is a [`++mane`](). - - ~zod/try=> (name:poxo %$) - "" - ~zod/try=> (name:poxo %ham) - "ham" - ~zod/try=> (name:poxo %ham^%tor) - "ham:tor" - -### `++many` - -Print node list - - ++ many :: nodelist to tape - |= [lix=(list manx) rez=tape] - |- ^- tape - ?~ lix rez - (apex i.lix $(lix t.lix)) - :: - -Renders multiple XML nodes as a [`++tape`]() - -`lix` is a [`++list`]() of [`++manx`](). - -`rez` is a [`++tape`](). - - ~zod/try=> (many:poxo ~ "") - "" - ~zod/try=> (many:poxo ;"hare" "") - "hare" - ~zod/try=> (many:poxo ;"hare;{lep}ton" "") - "hareton" - ~zod/try=> ;"hare;{lep}ton" - [[[%~. [%~. "hare"] ~] ~] [[%lep ~] ~] [[%~. [%~. "ton"] ~] ~] ~] - ------------------------------------------------------------------------- - -### `++poxa` - -Parse XML - - ++ poxa :: xml parser - =< |=(a=cord (rush a apex)) - |% - -Parses an XML node from a [`++cord`](), producing a unit [`++manx`](). - -`a` is a [`++cord`](). - - ~zod/try=> (poxa '
') - [~ [g=[n=%div a=~] c=~]] - ~zod/try=> (poxa ' ') - [~ [g=[n=%html a=~] c=~[[g=[n=%head a=~] c=~] [g=[n=%body a=~] c=~]]]] - ~zod/try=> (poxa '" - -Here we go through a similar example, passing a list of urls for a -script tag to a gate that produces a `