Urbit Developers
  • Hoon

    • Overview
    • Cheat Sheet
    • Irregular forms
    • Hoon Errors
    • Hoon Style Guide
    • Basic Types
    • Advanced Types
    • Auras
    • Arvo
    • Standard Library

      • 1a: Basic Arithmetic
      • 1b: Tree Addressing
      • 1c: Molds and Mold-Builders
      • 2a: Unit Logic
      • 2b: List Logic
      • 2c: Bit Arithmetic
      • 2d: Bit Logic
      • 2e: Insecure Hashing
      • 2f: Noun Ordering
      • 2g: Unsigned Powers
      • 2h: Set Logic
      • 2i: Map Logic
      • 2j: Jar and Jug Logic
      • 2k: Queue Logic
      • 2l: Container from Container
      • 2m: Container from Noun
      • 2n: Functional Hacks
      • 2o: Normalizing Containers
      • 2p: Serialization
      • 2q: Molds and Mold-Builders
      • 3a: Modular and Signed Ints
      • 3b: Floating Point
      • 3c: Urbit Time
      • 3d: SHA Hash Family
      • 3e: AES encryption (Removed)
      • 3f: Scrambling
      • 3g: Molds and Mold-Builders
      • 4a: Exotic Bases
      • 4b: Text Processing
      • 4c: Tank Printer
      • 4d: Parsing (Tracing)
      • 4e: Parsing (Combinators)
      • 4f: Parsing (Rule-Builders)
      • 4g: Parsing (Outside Caller)
      • 4h: Parsing (ASCII Glyphs)
      • 4i: Parsing (Useful Idioms)
      • 4j: Parsing (Bases and Base Digits)
      • 4k: Atom Printing
      • 4l: Atom Parsing
      • 4m: Formatting Functions
      • 4n: Virtualization
      • 4o: Molds
      • 5a: Compiler Utilities
      • 5b: Macro Expansion
      • 5c: Compiler Backend & Prettyprinter
      • 5d: Parser
      • 5e: Molds and mold builders
      • 5f: Profiling support
      • Runes

        • Constants (Atoms and Strings)
        • + lus · Arms
        • | bar · Cores
        • $ buc · Structures
        • % cen · Calls
        • : col · Cells
        • . dot · Nock
        • / fas · Imports
        • ^ ket · Casts
        • ; mic · Make
        • ~ sig · Hints
        • = tis · Subject
        • ? wut · Conditionals
        • ! zap · Wild
        • --, == Terminators
        • Limbs and wings

          • Limbs
          • Wings
          • Zuse

            • 2d(1-5): To JSON, Wains
            • 2d(6): From JSON
            • 2d(7): From JSON (unit)
            • 2e(2-3): Print & Parse JSON
            • 2m: Ordered Maps
          • Arvo

            • Overview
            • Ames

              • Overview
              • Cryptography
              • API Reference
              • Scry Reference
              • Data Types
              • Behn

                • Overview
                • API Reference
                • Scry Reference
                • Examples
                • Clay

                  • Overview
                  • Architecture
                  • Using Clay
                  • Data Types
                  • Scry Reference
                  • API Reference
                  • Examples
                  • Marks

                    • Overview
                    • Writing Marks
                    • Using Marks
                    • Examples
                  • Dill

                    • Overview
                    • API Reference
                    • Scry Reference
                    • Data Types
                    • Eyre

                      • Overview
                      • External API Reference
                      • Internal API Reference
                      • Scry Reference
                      • Data Types
                      • Guide
                      • Gall

                        • Overview
                        • API Reference
                        • Scry Reference
                        • Data Types
                        • Threads Reference
                        • Iris

                          • Overview
                          • API Reference
                          • Data Types
                          • Example
                          • Jael

                            • Overview
                            • API Reference
                            • Scry Reference
                            • Data Types
                            • Examples
                            • Khan

                              • Overview
                              • API Reference
                              • Data Types
                              • Example
                              • Threads

                                • Overview
                                • HTTP API
                                • Reference
                                • Gall

                                  • Start Thread
                                  • Take Result
                                  • Take Facts
                                  • Stop Thread
                                  • Poke Thread
                                  • Examples

                                    • Fetch JSON
                                    • Child Thread
                                    • Main-loop
                                    • Poke Agent
                                    • Scry
                                    • Take Fact
                                  • Concepts

                                    • Scries
                                    • Subscriptions
                                    • Tutorials

                                      • Move Trace
                                      • Reference

                                        • Cryptography
                                        • Filesystem Hierarchy
                                      • Nock

                                        • Nock Definition
                                        • Explanation
                                        • Example
                                        • Implementations
                                        • Vere

                                          • C Runtime System
                                          • Land of Nouns
                                          • API overview by prefix
                                          • C in Urbit
                                          • Writing Jets
                                          • Cryptography
                                          • Azimuth

                                            • Overview
                                            • Urbit HD Wallet
                                            • Azimuth Data Flow
                                            • Azimuth.eth
                                            • Ecliptic.eth
                                            • Advanced Azimuth Tools
                                            • Life and Rift
                                            • Layer 2

                                              • Layer 2 Overview
                                              • Layer 2 Actions
                                              • Transaction Format
                                              • Rollers
                                              • Roller HTTP RPC-API
                                              • Custom Roller Tutorial
                                            • Glossary

                                              • Agent
                                              • Ames
                                              • API
                                              • Aqua
                                              • Arm
                                              • Arvo
                                              • Atom
                                              • Aura
                                              • Aural ASCII
                                              • Azimuth
                                              • Battery
                                              • Behn
                                              • Bowl
                                              • Bridge
                                              • Bunt
                                              • Card
                                              • Case
                                              • Cask
                                              • Cell
                                              • Censures
                                              • Claims
                                              • Clay
                                              • Cold atom
                                              • Comet
                                              • Commit
                                              • Cons
                                              • Context
                                              • Cord
                                              • Core
                                              • Delegated Sending
                                              • Desk
                                              • Dill
                                              • Document Proposal
                                              • Dojo
                                              • Door
                                              • Double-boot
                                              • Dry Gate
                                              • Duct
                                              • Ecliptic
                                              • Entropy
                                              • Event Log
                                              • Eyre
                                              • Face
                                              • Fact
                                              • Foo Bar Baz
                                              • Galaxy
                                              • Gall
                                              • Garden
                                              • Gate
                                              • Generator
                                              • Gift
                                              • Glob
                                              • HD Wallet
                                              • Helm
                                              • Hood
                                              • Hoon
                                              • Invite Tree
                                              • Iris
                                              • Jael
                                              • Jet
                                              • Kelvin versioning
                                              • Kelvin versioning
                                              • Keyfile
                                              • Keywords
                                              • Khan
                                              • Kiln
                                              • Landscape
                                              • Leg
                                              • List
                                              • Loobean
                                              • Lull
                                              • Mark
                                              • Metals
                                              • Mold
                                              • Monad
                                              • Moon
                                              • Move
                                              • Nock
                                              • Noun
                                              • ~
                                              • OTA Updates
                                              • Path Prefix
                                              • Path
                                              • @p
                                              • Payload
                                              • Peek
                                              • pH
                                              • Pier
                                              • Pill
                                              • Planet
                                              • Poke
                                              • Proxies
                                              • Scry
                                              • Replay
                                              • Factory Reset
                                              • Roller
                                              • Naive rollups
                                              • Rune
                                              • Runtime
                                              • Sail
                                              • Sample
                                              • Scry
                                              • Senate
                                              • Ship
                                              • Slam
                                              • Spider
                                              • Sponsor
                                              • Star
                                              • String
                                              • Subject Oriented Programming
                                              • Subject
                                              • Subscription
                                              • Tape
                                              • Thread
                                              • Trap
                                              • Udon
                                              • Upgrade Proposal
                                              • Userspace
                                              • Vane
                                              • Vase
                                              • Vere
                                              • Voting
                                              • Warm atom
                                              • Wet Gate
                                              • Wing
                                              • Wire
                                              • Wrapper
                                              • ~zod
                                              • Zuse
                                              • Additional

                                                • Cryptography
                                                • Mips (Maps of Maps)
                                                • Software Distribution

                                                  • Overview
                                                  • Docket File
                                                  • Glob
                                                Urbit Developers
                                                • Hoon

                                                  • Overview
                                                  • Cheat Sheet
                                                  • Irregular forms
                                                  • Hoon Errors
                                                  • Hoon Style Guide
                                                  • Basic Types
                                                  • Advanced Types
                                                  • Auras
                                                  • Arvo
                                                  • Standard Library

                                                    • 1a: Basic Arithmetic
                                                    • 1b: Tree Addressing
                                                    • 1c: Molds and Mold-Builders
                                                    • 2a: Unit Logic
                                                    • 2b: List Logic
                                                    • 2c: Bit Arithmetic
                                                    • 2d: Bit Logic
                                                    • 2e: Insecure Hashing
                                                    • 2f: Noun Ordering
                                                    • 2g: Unsigned Powers
                                                    • 2h: Set Logic
                                                    • 2i: Map Logic
                                                    • 2j: Jar and Jug Logic
                                                    • 2k: Queue Logic
                                                    • 2l: Container from Container
                                                    • 2m: Container from Noun
                                                    • 2n: Functional Hacks
                                                    • 2o: Normalizing Containers
                                                    • 2p: Serialization
                                                    • 2q: Molds and Mold-Builders
                                                    • 3a: Modular and Signed Ints
                                                    • 3b: Floating Point
                                                    • 3c: Urbit Time
                                                    • 3d: SHA Hash Family
                                                    • 3e: AES encryption (Removed)
                                                    • 3f: Scrambling
                                                    • 3g: Molds and Mold-Builders
                                                    • 4a: Exotic Bases
                                                    • 4b: Text Processing
                                                    • 4c: Tank Printer
                                                    • 4d: Parsing (Tracing)
                                                    • 4e: Parsing (Combinators)
                                                    • 4f: Parsing (Rule-Builders)
                                                    • 4g: Parsing (Outside Caller)
                                                    • 4h: Parsing (ASCII Glyphs)
                                                    • 4i: Parsing (Useful Idioms)
                                                    • 4j: Parsing (Bases and Base Digits)
                                                    • 4k: Atom Printing
                                                    • 4l: Atom Parsing
                                                    • 4m: Formatting Functions
                                                    • 4n: Virtualization
                                                    • 4o: Molds
                                                    • 5a: Compiler Utilities
                                                    • 5b: Macro Expansion
                                                    • 5c: Compiler Backend & Prettyprinter
                                                    • 5d: Parser
                                                    • 5e: Molds and mold builders
                                                    • 5f: Profiling support
                                                    • Runes

                                                      • Constants (Atoms and Strings)
                                                      • + lus · Arms
                                                      • | bar · Cores
                                                      • $ buc · Structures
                                                      • % cen · Calls
                                                      • : col · Cells
                                                      • . dot · Nock
                                                      • / fas · Imports
                                                      • ^ ket · Casts
                                                      • ; mic · Make
                                                      • ~ sig · Hints
                                                      • = tis · Subject
                                                      • ? wut · Conditionals
                                                      • ! zap · Wild
                                                      • --, == Terminators
                                                      • Limbs and wings

                                                        • Limbs
                                                        • Wings
                                                        • Zuse

                                                          • 2d(1-5): To JSON, Wains
                                                          • 2d(6): From JSON
                                                          • 2d(7): From JSON (unit)
                                                          • 2e(2-3): Print & Parse JSON
                                                          • 2m: Ordered Maps
                                                        • Arvo

                                                          • Overview
                                                          • Ames

                                                            • Overview
                                                            • Cryptography
                                                            • API Reference
                                                            • Scry Reference
                                                            • Data Types
                                                            • Behn

                                                              • Overview
                                                              • API Reference
                                                              • Scry Reference
                                                              • Examples
                                                              • Clay

                                                                • Overview
                                                                • Architecture
                                                                • Using Clay
                                                                • Data Types
                                                                • Scry Reference
                                                                • API Reference
                                                                • Examples
                                                                • Marks

                                                                  • Overview
                                                                  • Writing Marks
                                                                  • Using Marks
                                                                  • Examples
                                                                • Dill

                                                                  • Overview
                                                                  • API Reference
                                                                  • Scry Reference
                                                                  • Data Types
                                                                  • Eyre

                                                                    • Overview
                                                                    • External API Reference
                                                                    • Internal API Reference
                                                                    • Scry Reference
                                                                    • Data Types
                                                                    • Guide
                                                                    • Gall

                                                                      • Overview
                                                                      • API Reference
                                                                      • Scry Reference
                                                                      • Data Types
                                                                      • Threads Reference
                                                                      • Iris

                                                                        • Overview
                                                                        • API Reference
                                                                        • Data Types
                                                                        • Example
                                                                        • Jael

                                                                          • Overview
                                                                          • API Reference
                                                                          • Scry Reference
                                                                          • Data Types
                                                                          • Examples
                                                                          • Khan

                                                                            • Overview
                                                                            • API Reference
                                                                            • Data Types
                                                                            • Example
                                                                            • Threads

                                                                              • Overview
                                                                              • HTTP API
                                                                              • Reference
                                                                              • Gall

                                                                                • Start Thread
                                                                                • Take Result
                                                                                • Take Facts
                                                                                • Stop Thread
                                                                                • Poke Thread
                                                                                • Examples

                                                                                  • Fetch JSON
                                                                                  • Child Thread
                                                                                  • Main-loop
                                                                                  • Poke Agent
                                                                                  • Scry
                                                                                  • Take Fact
                                                                                • Concepts

                                                                                  • Scries
                                                                                  • Subscriptions
                                                                                  • Tutorials

                                                                                    • Move Trace
                                                                                    • Reference

                                                                                      • Cryptography
                                                                                      • Filesystem Hierarchy
                                                                                    • Nock

                                                                                      • Nock Definition
                                                                                      • Explanation
                                                                                      • Example
                                                                                      • Implementations
                                                                                      • Vere

                                                                                        • C Runtime System
                                                                                        • Land of Nouns
                                                                                        • API overview by prefix
                                                                                        • C in Urbit
                                                                                        • Writing Jets
                                                                                        • Cryptography
                                                                                        • Azimuth

                                                                                          • Overview
                                                                                          • Urbit HD Wallet
                                                                                          • Azimuth Data Flow
                                                                                          • Azimuth.eth
                                                                                          • Ecliptic.eth
                                                                                          • Advanced Azimuth Tools
                                                                                          • Life and Rift
                                                                                          • Layer 2

                                                                                            • Layer 2 Overview
                                                                                            • Layer 2 Actions
                                                                                            • Transaction Format
                                                                                            • Rollers
                                                                                            • Roller HTTP RPC-API
                                                                                            • Custom Roller Tutorial
                                                                                          • Glossary

                                                                                            • Agent
                                                                                            • Ames
                                                                                            • API
                                                                                            • Aqua
                                                                                            • Arm
                                                                                            • Arvo
                                                                                            • Atom
                                                                                            • Aura
                                                                                            • Aural ASCII
                                                                                            • Azimuth
                                                                                            • Battery
                                                                                            • Behn
                                                                                            • Bowl
                                                                                            • Bridge
                                                                                            • Bunt
                                                                                            • Card
                                                                                            • Case
                                                                                            • Cask
                                                                                            • Cell
                                                                                            • Censures
                                                                                            • Claims
                                                                                            • Clay
                                                                                            • Cold atom
                                                                                            • Comet
                                                                                            • Commit
                                                                                            • Cons
                                                                                            • Context
                                                                                            • Cord
                                                                                            • Core
                                                                                            • Delegated Sending
                                                                                            • Desk
                                                                                            • Dill
                                                                                            • Document Proposal
                                                                                            • Dojo
                                                                                            • Door
                                                                                            • Double-boot
                                                                                            • Dry Gate
                                                                                            • Duct
                                                                                            • Ecliptic
                                                                                            • Entropy
                                                                                            • Event Log
                                                                                            • Eyre
                                                                                            • Face
                                                                                            • Fact
                                                                                            • Foo Bar Baz
                                                                                            • Galaxy
                                                                                            • Gall
                                                                                            • Garden
                                                                                            • Gate
                                                                                            • Generator
                                                                                            • Gift
                                                                                            • Glob
                                                                                            • HD Wallet
                                                                                            • Helm
                                                                                            • Hood
                                                                                            • Hoon
                                                                                            • Invite Tree
                                                                                            • Iris
                                                                                            • Jael
                                                                                            • Jet
                                                                                            • Kelvin versioning
                                                                                            • Kelvin versioning
                                                                                            • Keyfile
                                                                                            • Keywords
                                                                                            • Khan
                                                                                            • Kiln
                                                                                            • Landscape
                                                                                            • Leg
                                                                                            • List
                                                                                            • Loobean
                                                                                            • Lull
                                                                                            • Mark
                                                                                            • Metals
                                                                                            • Mold
                                                                                            • Monad
                                                                                            • Moon
                                                                                            • Move
                                                                                            • Nock
                                                                                            • Noun
                                                                                            • ~
                                                                                            • OTA Updates
                                                                                            • Path Prefix
                                                                                            • Path
                                                                                            • @p
                                                                                            • Payload
                                                                                            • Peek
                                                                                            • pH
                                                                                            • Pier
                                                                                            • Pill
                                                                                            • Planet
                                                                                            • Poke
                                                                                            • Proxies
                                                                                            • Scry
                                                                                            • Replay
                                                                                            • Factory Reset
                                                                                            • Roller
                                                                                            • Naive rollups
                                                                                            • Rune
                                                                                            • Runtime
                                                                                            • Sail
                                                                                            • Sample
                                                                                            • Scry
                                                                                            • Senate
                                                                                            • Ship
                                                                                            • Slam
                                                                                            • Spider
                                                                                            • Sponsor
                                                                                            • Star
                                                                                            • String
                                                                                            • Subject Oriented Programming
                                                                                            • Subject
                                                                                            • Subscription
                                                                                            • Tape
                                                                                            • Thread
                                                                                            • Trap
                                                                                            • Udon
                                                                                            • Upgrade Proposal
                                                                                            • Userspace
                                                                                            • Vane
                                                                                            • Vase
                                                                                            • Vere
                                                                                            • Voting
                                                                                            • Warm atom
                                                                                            • Wet Gate
                                                                                            • Wing
                                                                                            • Wire
                                                                                            • Wrapper
                                                                                            • ~zod
                                                                                            • Zuse
                                                                                            • Additional

                                                                                              • Cryptography
                                                                                              • Mips (Maps of Maps)
                                                                                              • Software Distribution

                                                                                                • Overview
                                                                                                • Docket File
                                                                                                • Glob
                                                                                              Reference/Additional

                                                                                              Mips (Maps of Maps)

                                                                                              A mip is a map of maps. These can be constructed manually by nesting ordinary maps, but the %garden desk contains a /lib/mip.hoon library which makes these a bit easier to deal with. You can copy the library into your own project. The various mip functions are documented below.

                                                                                              ++mip

                                                                                              Mip (map of maps) mold builder

                                                                                              A mip is a map of maps. An outer map maps keys to inner maps, which themselves map keys to values.

                                                                                              A (mip kex key value) is equivalent to (map kex (map key value)).

                                                                                              Accepts

                                                                                              kex is a mold, the type of the outer map's key.

                                                                                              key is a mold, the type of the key of the inner maps.

                                                                                              value is a mold, the type of the value of the inner maps.

                                                                                              Produces

                                                                                              A mold.

                                                                                              Source

                                                                                              |%
                                                                                              ++ mip :: map of maps
                                                                                              |$ [kex key value]
                                                                                              (map kex (map key value))

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > *(mip:libmip @ @ @)
                                                                                              {}
                                                                                              > (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              [n=[p=1 q=[n=[p=2 q=3] l=~ r=~]] l=~ r=~]

                                                                                              ++bi

                                                                                              Mip engine

                                                                                              This is the container door for all the mip functions.

                                                                                              Accepts

                                                                                              a is a mip.

                                                                                              Source

                                                                                              ++ bi :: mip engine
                                                                                              =| a=(map * (map))
                                                                                              |@

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > ~(. bi:libmip *(mip:libmip @ @ @))
                                                                                              < 8.bql
                                                                                              [ a=nlr([p=@ q=nlr([p=@ q=@])])
                                                                                              <2.gtk 17.zfg 35.yza 14.oai 54.ecl 77.swa 232.sje 51.qbt 123.ppa 46.hgz 1.pnw %140>
                                                                                              ]
                                                                                              >

                                                                                              ++del:bi

                                                                                              Delete item in mip

                                                                                              This takes two keys as its argument, b and c, and deletes c in the inner map that matches key b in the outer map . If this results in an empty inner map, then b is also deleted from the outer map.

                                                                                              Accepts

                                                                                              a is a mip, and is the +bi door's sample.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              Produces

                                                                                              A mip with c deleted from b, or b deleted from a if c ended up empty.

                                                                                              Source

                                                                                              ++ del
                                                                                              |* [b=* c=*]
                                                                                              =+ d=(~(gut by a) b ~)
                                                                                              =+ e=(~(del by d) c)
                                                                                              ?~ e
                                                                                              (~(del by a) b)
                                                                                              (~(put by a) b e)

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > =mymip (~(put bi:libmip mymip) 1 3 4)
                                                                                              > mymip
                                                                                              [n=[p=1 q=[n=[p=2 q=3] l=~ r=[n=[p=3 q=4] l=~ r=~]]] l=~ r=~]
                                                                                              > =mymip (~(del bi:libmip mymip) 1 2)
                                                                                              > mymip
                                                                                              [n=[p=1 q=[n=[p=3 q=4] l=~ r=~]] l=~ r=~]
                                                                                              > =mymip (~(del bi:libmip mymip) 1 3)
                                                                                              > mymip
                                                                                              ~

                                                                                              ++get:bi

                                                                                              Maybe get value in mip

                                                                                              Get the value of c in the map with key b in mip a as a unit. If there's no c in b or b in a, the unit is null.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              Produces

                                                                                              A (unit [type]), where [type] is the value type. The unit is null if there's no c in b or no b in a.

                                                                                              Source

                                                                                              ++ get
                                                                                              |* [b=* c=*]
                                                                                              => .(b `_?>(?=(^ a) p.n.a)`b, c `_?>(?=(^ a) ?>(?=(^ q.n.a) p.n.q.n.a))`c)
                                                                                              ^- (unit _?>(?=(^ a) ?>(?=(^ q.n.a) q.n.q.n.a)))
                                                                                              (~(get by (~(gut by a) b ~)) c)

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > (~(get bi:libmip mymip) 1 2)
                                                                                              [~ 3]
                                                                                              > (~(get bi:libmip mymip) 2 3)
                                                                                              ~

                                                                                              ++got:bi

                                                                                              Get value in mip or crash

                                                                                              Get the value of c in the map with key b in mip a. If there's no c in b or b in a, crash.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              Produces

                                                                                              A noun of the type of the values in the mip, or else crashes.

                                                                                              Source

                                                                                              ++ got
                                                                                              |* [b=* c=*]
                                                                                              (need (get b c))

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > (~(got bi:libmip mymip) 1 2)
                                                                                              3
                                                                                              > (~(got bi:libmip mymip) 2 3)
                                                                                              /lib/mip/hoon:<[25 5].[25 21]>
                                                                                              dojo: hoon expression failed

                                                                                              ++gut:bi

                                                                                              Get value in mip or default

                                                                                              Get the value of c in the map with key b in mip a. If there's no c in b or b in a, produce default value d.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              d is a default value, which is produced if the value cannot be found.

                                                                                              Produces

                                                                                              A noun, either the type of the value in the map or d.

                                                                                              Source

                                                                                              ++ gut
                                                                                              |* [b=* c=* d=*]
                                                                                              (~(gut by (~(gut by a) b ~)) c d)

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > (~(gut bi:libmip mymip) 1 2 42)
                                                                                              3
                                                                                              > (~(gut bi:libmip mymip) 2 3 42)
                                                                                              42

                                                                                              ++has:bi

                                                                                              Check if mip contains

                                                                                              Check if mip a contains c in b.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              Produces

                                                                                              A ? which is true if c in b exists, and false otherwise.

                                                                                              Source

                                                                                              ++ has
                                                                                              |* [b=* c=*]
                                                                                              !=(~ (get b c))

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > (~(has bi:libmip mymip) 1 2)
                                                                                              %.y
                                                                                              > (~(has bi:libmip mymip) 2 3)
                                                                                              %.n

                                                                                              ++key:bi

                                                                                              Get keys of inner map in mip

                                                                                              Get the set of keys of the inner map matching key b in the outer map. If b doesn't exist, an empty set is returned.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              Produces

                                                                                              A (set [type]) where [type] is the type of the keys in the inner map.

                                                                                              Source

                                                                                              ++ key
                                                                                              |* b=*
                                                                                              ~(key by (~(gut by a) b ~))

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > (~(key bi:libmip mymip) 1)
                                                                                              {2}
                                                                                              > (~(key bi:libmip mymip) 2)
                                                                                              {}

                                                                                              ++put:bi

                                                                                              Insert value in mip

                                                                                              Add value d with key c to the inner map with key b in the outer map. If b doesn't exist, an inner map is also added with that key. If c already exists, its value is replaced with d.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              b is a key matching the key type of the outer map.

                                                                                              c is a key matching the key type of the inner maps.

                                                                                              d is a noun matching the type of the values in the mip.

                                                                                              Produces

                                                                                              A new, modified mip.

                                                                                              Source

                                                                                              ++ put
                                                                                              |* [b=* c=* d=*]
                                                                                              %+ ~(put by a) b
                                                                                              %. [c d]
                                                                                              %~ put by
                                                                                              (~(gut by a) b ~)

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > =mymip (~(put bi:libmip mymip) 1 1 42)
                                                                                              > =mymip (~(put bi:libmip mymip) 2 12 99)
                                                                                              > ~(tap bi:libmip mymip)
                                                                                              ~[[x=2 y=12 v=99] [x=1 y=2 v=3] [x=1 y=1 v=42]]

                                                                                              ++tap:bi

                                                                                              Convert mip to list

                                                                                              The mip is flattened to a list of the triple [x y v], where x is a key in the outer map, y is a key in an inner map, and v is its value.

                                                                                              Accepts

                                                                                              a is a mip, and is the sample of the ++bi door.

                                                                                              Produces

                                                                                              A triple cell of [x y v], where:

                                                                                              • x is a key in the outer map.
                                                                                              • y is a key in an inner map.
                                                                                              • v is its value.

                                                                                              Source

                                                                                              ++ tap
                                                                                              ::NOTE naive turn-based implementation find-errors ):
                                                                                              =< $
                                                                                              =+ b=`_?>(?=(^ a) *(list [x=_p.n.a _?>(?=(^ q.n.a) [y=p v=q]:n.q.n.a)]))`~
                                                                                              |. ^+ b
                                                                                              ?~ a
                                                                                              b
                                                                                              $(a r.a, b (welp (turn ~(tap by q.n.a) (lead p.n.a)) $(a l.a)))
                                                                                              --

                                                                                              Examples

                                                                                              > =libmip -build-file /=garden=/lib/mip/hoon
                                                                                              > =mymip (~(put bi:libmip *(mip:libmip @ @ @)) 1 2 3)
                                                                                              > =mymip (~(put bi:libmip mymip) 1 1 42)
                                                                                              > =mymip (~(put bi:libmip mymip) 2 12 99)
                                                                                              > ~(tap bi:libmip mymip)
                                                                                              ~[[x=2 y=12 v=99] [x=1 y=2 v=3] [x=1 y=1 v=42]]

                                                                                              <-

                                                                                              Cryptography

                                                                                              Edit this page on GitHub

                                                                                              Last modified June 13, 2023