Urbit
  • Introduction
  • Development

    • Getting Started
    • Environment Setup
    • Grants Program
    • Project Repositories
    • Precepts
    • System Overview

      • Arvo
      • Hoon
      • Nock
      • Vere
      • Azimuth
      • Cryptography
      • Arvo

        • Overview
        • Reference

          • Cryptography
          • Filesystem Hierarchy
          • Ames

            • Overview
            • Cryptography
            • API Reference
            • Behn

              • Overview
              • API Reference
              • Clay

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

                  • Overview
                  • API Reference
                  • Eyre

                    • Overview
                    • External API Reference
                    • Internal API Reference
                    • Scry Reference
                    • Data Types
                    • Examples
                    • Ford

                      • Overview
                      • Gall

                        • Overview
                        • Iris

                          • API Reference
                          • Jael

                            • API Reference
                            • Concepts

                              • Subscriptions
                              • Tutorials

                                • Move Trace
                              • Userspace

                                • Overview
                                • Gall

                                  • Overview
                                  • Tutorial
                                  • API Reference
                                  • Graph Store

                                    • Graph Store Overview
                                    • Data Structure Overview
                                    • Validator Walkthrough
                                    • Advanced Info
                                    • Threads

                                      • Overview
                                      • HTTP API
                                      • Reference
                                      • Basics

                                        • Fundamentals
                                        • Bind
                                        • Input
                                        • Output
                                        • Summary
                                        • Gall

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

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

                                            • Overview
                                            • API Reference

                                              • Graph Store
                                          • Hoon

                                            • Overview
                                            • Hoon School

                                              • 1.1 Setup
                                              • 1.1.1 Walkthrough: List of Numbers
                                              • 1.2 Nouns
                                              • 1.3 Hoon Syntax
                                              • 1.3.1 Walkthrough: Conditionals
                                              • 1.4 Gates (Hoon Functions)
                                              • 1.4.1 Walkthrough: Recursion
                                              • 1.5 Lists
                                              • 1.5.1 Walkthrough: Fibonacci Sequence
                                              • 1.6 The Subject and Its Legs
                                              • 1.6.1 Walkthrough: Ackermann Function
                                              • 1.7 Arms and Cores
                                              • 1.7.1 Walkthrough: Caesar Cipher
                                              • 1.8 Doors
                                              • 1.8.1 Bank Account
                                              • 1.9 Generators
                                              • 2.1 Atoms, Auras, and Simple Cell Types
                                              • 2.2 Type Checking and Type Inference
                                              • 2.3 Structures and Complex Types
                                              • 2.3.1 Walkthrough: Libraries
                                              • 2.3.2 Molds
                                              • 2.4 Standard Library: Trees, Sets, and Maps
                                              • 2.5 Type Polymorphism
                                              • 2.5.1 Walkthrough: Iron Polymorphism and Wet Polymorphism
                                              • 2.5.2 Walkthrough: Lead Polymorphism
                                              • 2.6 Behn
                                              • 2.7 Gall
                                              • 2.7.1 Gall Walkthrough: Egg Timer
                                              • Guides

                                                • CLI apps
                                                • Parsing
                                                • Writing Aqua Tests
                                                • Reference

                                                  • Cheat Sheet
                                                  • Irregular forms
                                                  • Hoon Errors
                                                  • Hoon Style Guide
                                                  • Basic Types
                                                  • Advanced Types
                                                  • Auras
                                                  • Runes

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

                                                      • Limbs
                                                      • Wings
                                                      • Standard library

                                                        • Table of Contents
                                                        • 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: Caching Compiler
                                                        • 5f: Molds and Mold-Builders
                                                        • 5g: profiling support
                                                    • 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
                                                          • Life and Rift
                                                          • Advanced Azimuth Tools
                                                          • Glossary

                                                            • Ames
                                                            • Aqua
                                                            • Arm
                                                            • Arvo
                                                            • Atom
                                                            • Azimuth
                                                            • Battery
                                                            • Behn
                                                            • Breach
                                                            • Bridge
                                                            • Censures
                                                            • Ceremony
                                                            • chat
                                                            • Claims
                                                            • Clay
                                                            • Comet
                                                            • Core
                                                            • Delegated Sending
                                                            • Desk
                                                            • Dill
                                                            • Document Proposal
                                                            • Dojo
                                                            • Door
                                                            • Ecliptic
                                                            • Event Log
                                                            • Eyre
                                                            • Ford
                                                            • Galaxy
                                                            • Gall
                                                            • Gate
                                                            • HD Wallet
                                                            • Hoon
                                                            • Invite Tree
                                                            • Iris
                                                            • Jael
                                                            • Jaque
                                                            • Keyfile
                                                            • Landscape
                                                            • Mark
                                                            • Moon
                                                            • Nock
                                                            • Noun
                                                            • OTA Updates
                                                            • Payload
                                                            • pH
                                                            • Pier
                                                            • Pill
                                                            • Planet
                                                            • Proxies
                                                            • Replay
                                                            • Sail/Udon
                                                            • Senate
                                                            • Ship
                                                            • ship.arvo.network
                                                            • Star
                                                            • |sync
                                                            • Trap
                                                            • Upgrade Proposal
                                                            • Vane
                                                            • Vere
                                                            • Voting
                                                            • Wallet-Generator
                                                            Urbit
                                                            • Introduction
                                                            • Development

                                                              • Getting Started
                                                              • Environment Setup
                                                              • Grants Program
                                                              • Project Repositories
                                                              • Precepts
                                                              • System Overview

                                                                • Arvo
                                                                • Hoon
                                                                • Nock
                                                                • Vere
                                                                • Azimuth
                                                                • Cryptography
                                                                • Arvo

                                                                  • Overview
                                                                  • Reference

                                                                    • Cryptography
                                                                    • Filesystem Hierarchy
                                                                    • Ames

                                                                      • Overview
                                                                      • Cryptography
                                                                      • API Reference
                                                                      • Behn

                                                                        • Overview
                                                                        • API Reference
                                                                        • Clay

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

                                                                            • Overview
                                                                            • API Reference
                                                                            • Eyre

                                                                              • Overview
                                                                              • External API Reference
                                                                              • Internal API Reference
                                                                              • Scry Reference
                                                                              • Data Types
                                                                              • Examples
                                                                              • Ford

                                                                                • Overview
                                                                                • Gall

                                                                                  • Overview
                                                                                  • Iris

                                                                                    • API Reference
                                                                                    • Jael

                                                                                      • API Reference
                                                                                      • Concepts

                                                                                        • Subscriptions
                                                                                        • Tutorials

                                                                                          • Move Trace
                                                                                        • Userspace

                                                                                          • Overview
                                                                                          • Gall

                                                                                            • Overview
                                                                                            • Tutorial
                                                                                            • API Reference
                                                                                            • Graph Store

                                                                                              • Graph Store Overview
                                                                                              • Data Structure Overview
                                                                                              • Validator Walkthrough
                                                                                              • Advanced Info
                                                                                              • Threads

                                                                                                • Overview
                                                                                                • HTTP API
                                                                                                • Reference
                                                                                                • Basics

                                                                                                  • Fundamentals
                                                                                                  • Bind
                                                                                                  • Input
                                                                                                  • Output
                                                                                                  • Summary
                                                                                                  • Gall

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

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

                                                                                                      • Overview
                                                                                                      • API Reference

                                                                                                        • Graph Store
                                                                                                    • Hoon

                                                                                                      • Overview
                                                                                                      • Hoon School

                                                                                                        • 1.1 Setup
                                                                                                        • 1.1.1 Walkthrough: List of Numbers
                                                                                                        • 1.2 Nouns
                                                                                                        • 1.3 Hoon Syntax
                                                                                                        • 1.3.1 Walkthrough: Conditionals
                                                                                                        • 1.4 Gates (Hoon Functions)
                                                                                                        • 1.4.1 Walkthrough: Recursion
                                                                                                        • 1.5 Lists
                                                                                                        • 1.5.1 Walkthrough: Fibonacci Sequence
                                                                                                        • 1.6 The Subject and Its Legs
                                                                                                        • 1.6.1 Walkthrough: Ackermann Function
                                                                                                        • 1.7 Arms and Cores
                                                                                                        • 1.7.1 Walkthrough: Caesar Cipher
                                                                                                        • 1.8 Doors
                                                                                                        • 1.8.1 Bank Account
                                                                                                        • 1.9 Generators
                                                                                                        • 2.1 Atoms, Auras, and Simple Cell Types
                                                                                                        • 2.2 Type Checking and Type Inference
                                                                                                        • 2.3 Structures and Complex Types
                                                                                                        • 2.3.1 Walkthrough: Libraries
                                                                                                        • 2.3.2 Molds
                                                                                                        • 2.4 Standard Library: Trees, Sets, and Maps
                                                                                                        • 2.5 Type Polymorphism
                                                                                                        • 2.5.1 Walkthrough: Iron Polymorphism and Wet Polymorphism
                                                                                                        • 2.5.2 Walkthrough: Lead Polymorphism
                                                                                                        • 2.6 Behn
                                                                                                        • 2.7 Gall
                                                                                                        • 2.7.1 Gall Walkthrough: Egg Timer
                                                                                                        • Guides

                                                                                                          • CLI apps
                                                                                                          • Parsing
                                                                                                          • Writing Aqua Tests
                                                                                                          • Reference

                                                                                                            • Cheat Sheet
                                                                                                            • Irregular forms
                                                                                                            • Hoon Errors
                                                                                                            • Hoon Style Guide
                                                                                                            • Basic Types
                                                                                                            • Advanced Types
                                                                                                            • Auras
                                                                                                            • Runes

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

                                                                                                                • Limbs
                                                                                                                • Wings
                                                                                                                • Standard library

                                                                                                                  • Table of Contents
                                                                                                                  • 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: Caching Compiler
                                                                                                                  • 5f: Molds and Mold-Builders
                                                                                                                  • 5g: profiling support
                                                                                                              • 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
                                                                                                                    • Life and Rift
                                                                                                                    • Advanced Azimuth Tools
                                                                                                                    • Glossary

                                                                                                                      • Ames
                                                                                                                      • Aqua
                                                                                                                      • Arm
                                                                                                                      • Arvo
                                                                                                                      • Atom
                                                                                                                      • Azimuth
                                                                                                                      • Battery
                                                                                                                      • Behn
                                                                                                                      • Breach
                                                                                                                      • Bridge
                                                                                                                      • Censures
                                                                                                                      • Ceremony
                                                                                                                      • chat
                                                                                                                      • Claims
                                                                                                                      • Clay
                                                                                                                      • Comet
                                                                                                                      • Core
                                                                                                                      • Delegated Sending
                                                                                                                      • Desk
                                                                                                                      • Dill
                                                                                                                      • Document Proposal
                                                                                                                      • Dojo
                                                                                                                      • Door
                                                                                                                      • Ecliptic
                                                                                                                      • Event Log
                                                                                                                      • Eyre
                                                                                                                      • Ford
                                                                                                                      • Galaxy
                                                                                                                      • Gall
                                                                                                                      • Gate
                                                                                                                      • HD Wallet
                                                                                                                      • Hoon
                                                                                                                      • Invite Tree
                                                                                                                      • Iris
                                                                                                                      • Jael
                                                                                                                      • Jaque
                                                                                                                      • Keyfile
                                                                                                                      • Landscape
                                                                                                                      • Mark
                                                                                                                      • Moon
                                                                                                                      • Nock
                                                                                                                      • Noun
                                                                                                                      • OTA Updates
                                                                                                                      • Payload
                                                                                                                      • pH
                                                                                                                      • Pier
                                                                                                                      • Pill
                                                                                                                      • Planet
                                                                                                                      • Proxies
                                                                                                                      • Replay
                                                                                                                      • Sail/Udon
                                                                                                                      • Senate
                                                                                                                      • Ship
                                                                                                                      • ship.arvo.network
                                                                                                                      • Star
                                                                                                                      • |sync
                                                                                                                      • Trap
                                                                                                                      • Upgrade Proposal
                                                                                                                      • Vane
                                                                                                                      • Vere
                                                                                                                      • Voting
                                                                                                                      • Wallet-Generator
                                                                                                                      Urbit/Documentation/Hoon/Reference/Standard library

                                                                                                                      2i: Map Logic

                                                                                                                      ++by

                                                                                                                      Map operations

                                                                                                                      Container arm for map operation arms. A map is a set of key-value pairs. The contained arms inherit its sample map, a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      Source

                                                                                                                      ++  by
                                                                                                                            ~/  %by
                                                                                                                            =|  a=(tree (pair))
                                                                                                                            =*  node  ?>(?=(^ a) n.a)
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > ~(. by (my [%a 1] [%b 2] ~))
                                                                                                                          < 27.zjr
                                                                                                                          {   a
                                                                                                                            ?(
                                                                                                                              { n/{?(p/$a p/$b) q/@ud}
                                                                                                                                l/nlr({p/?($b $a) q/@ud})
                                                                                                                                r/nlr({p/?($b $a) q/@ud})
                                                                                                                              }
                                                                                                                              $~
                                                                                                                            )
                                                                                                                            <119.wim 31.ohr 1.jmk $143>
                                                                                                                          }

                                                                                                                      ++all:by

                                                                                                                      Logical AND

                                                                                                                      Computes the logical AND on the results of slamming every element in map a with gate b.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate.

                                                                                                                      Produces

                                                                                                                      A flag.

                                                                                                                      Source

                                                                                                                      ++  all                                               ::  logical AND
                                                                                                                          ~/  %all
                                                                                                                          |*  b=$-(* ?)
                                                                                                                          |-  ^-  ?
                                                                                                                          ?~  a
                                                                                                                            &
                                                                                                                          ?&((b n.a) $(a l.a) $(a r.a))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > (~(all by b) |=(a=* ?@(a & |)))
                                                                                                                          %.n
                                                                                                                      
                                                                                                                          > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
                                                                                                                          > (~(all by a) |=(a=@ (lte a 6)))
                                                                                                                          %.y
                                                                                                                      
                                                                                                                          > (~(all by a) |=(a=@ (lte a 4)))
                                                                                                                          %.n

                                                                                                                      ++any:by

                                                                                                                      Logical OR

                                                                                                                      Computes the logical OR on the results of slamming every element with gate b.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate.

                                                                                                                      Produces

                                                                                                                      A flag.

                                                                                                                      Source

                                                                                                                      ++  any                                               ::  logical OR
                                                                                                                          ~/  %any
                                                                                                                          |*  b=$-(* ?)
                                                                                                                          |-  ^-  ?
                                                                                                                          ?~  a
                                                                                                                            |
                                                                                                                          ?|((b q.n.a) $(a l.a) $(a r.a))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > (~(any by b) |=(a=* ?@(a & |)))
                                                                                                                          %.y
                                                                                                                      
                                                                                                                          > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
                                                                                                                          > (~(any by a) |=(a=@ (lte a 4)))
                                                                                                                          %.y

                                                                                                                      ++apt:by

                                                                                                                      Check correctness

                                                                                                                      Computes whether a has a correct horizontal order and a correct vertical order, producing a flag.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      Produces

                                                                                                                      A flag.

                                                                                                                      Source

                                                                                                                      ++  apt                                               ::  check correctness
                                                                                                                          =<  $
                                                                                                                          ~/  %apt
                                                                                                                          =|  [l=(unit) r=(unit)]
                                                                                                                          |.  ^-  ?
                                                                                                                          ?~  a   &
                                                                                                                          ?&  ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l)))
                                                                                                                              ?~(r & &((gor u.r p.n.a) !=(u.r p.n.a)))
                                                                                                                              ?~  l.a   &
                                                                                                                              &((mor p.n.a p.n.l.a) !=(p.n.a p.n.l.a) $(a l.a, l `p.n.a))
                                                                                                                              ?~  r.a   &
                                                                                                                              &((mor p.n.a p.n.r.a) !=(p.n.a p.n.r.a) $(a r.a, r `p.n.a))
                                                                                                                          ==
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =a (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > ~(apt by a)
                                                                                                                          %.y
                                                                                                                      
                                                                                                                          > =s (my [[1 2] [3 4] ~])
                                                                                                                          > =z ?~  s  ~  s(p.n 10)
                                                                                                                          > z
                                                                                                                          [n=[p=10 q=2] l={} r={[p=3 q=4]}]
                                                                                                                      
                                                                                                                          > ~(apt by z)
                                                                                                                          %.n

                                                                                                                      Discussion

                                                                                                                      See section 2f for more information on noun ordering.

                                                                                                                      ++bif:by

                                                                                                                      Bifurcate

                                                                                                                      Splits map a into two maps l and r, with the head at b discarded.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a noun.

                                                                                                                      c is a noun.

                                                                                                                      Produces

                                                                                                                      A cell of two maps.

                                                                                                                      Source

                                                                                                                      ++  bif                                               ::  splits a by b
                                                                                                                          ~/  %bif
                                                                                                                          |*  [b=* c=*]
                                                                                                                          ^+  [l=a r=a]
                                                                                                                          =<  +
                                                                                                                          |-  ^+  a
                                                                                                                          ?~  a
                                                                                                                            [[b c] ~ ~]
                                                                                                                          ?:  =(b p.n.a)
                                                                                                                            ?:  =(c q.n.a)
                                                                                                                              a
                                                                                                                            a(n [b c])
                                                                                                                          ?:  (gor b p.n.a)
                                                                                                                            =+  d=$(a l.a)
                                                                                                                            ?>  ?=(^ d)
                                                                                                                            d(r a(l r.d))
                                                                                                                          =+  d=$(a r.a)
                                                                                                                          ?>  ?=(^ d)
                                                                                                                          d(l a(r l.d))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =a (my [['a' 1] ['b' 2] ['c' 3] ~])
                                                                                                                      
                                                                                                                          > (~(bif by a) ['b' 2])
                                                                                                                          [l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]

                                                                                                                      ++del:by

                                                                                                                      Delete

                                                                                                                      Produces map a with the element located at key b removed.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  del                                               ::  delete at key b
                                                                                                                          ~/  %del
                                                                                                                          |*  b=*
                                                                                                                          |-  ^+  a
                                                                                                                          ?~  a
                                                                                                                            ~
                                                                                                                          ?.  =(b p.n.a)
                                                                                                                            ?:  (gor b p.n.a)
                                                                                                                              a(l $(a l.a))
                                                                                                                            a(r $(a r.a))
                                                                                                                          |-  ^-  [$?(~ _a)]
                                                                                                                          ?~  l.a  r.a
                                                                                                                          ?~  r.a  l.a
                                                                                                                          ?:  (mor p.n.l.a p.n.r.a)
                                                                                                                            l.a(r $(l.a r.l.a))
                                                                                                                          r.a(l $(r.a l.r.a))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > (~(del by b) 'a')
                                                                                                                          [n=[p='b' q=[2 3]] l=~ r=~]

                                                                                                                      ++dig:by

                                                                                                                      Address of key

                                                                                                                      Produce the address of key b within map a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      Produces

                                                                                                                      A unit.

                                                                                                                      Source

                                                                                                                      ++  dig                                               ::  axis of b 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))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                              > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                              > (~(dig by b) 'b')
                                                                                                                              [~ u=2]

                                                                                                                      ++gas:by

                                                                                                                      Concatenate

                                                                                                                      Insert a list of key-value pairs b into map a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a list of cells of key-value nouns p and q.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  gas                                               ::  concatenate
                                                                                                                          ~/  %gas
                                                                                                                          |*  b=(list [p=* q=*])
                                                                                                                          =>  .(b `(list _?>(?=(^ a) n.a))`b)
                                                                                                                          |-  ^+  a
                                                                                                                          ?~  b
                                                                                                                            a
                                                                                                                          $(b t.b, a (put p.i.b q.i.b))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =a (my [['a' 1] ['b' 2] ~])
                                                                                                                          > =b [['c' 3] ['d' 4] ~]
                                                                                                                      
                                                                                                                          > (~(gas by a) b)
                                                                                                                          [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]

                                                                                                                      ++get:by

                                                                                                                      Grab unit value

                                                                                                                      Produce the unit value of the value located at key b within map a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      Produces

                                                                                                                      A unit.

                                                                                                                      Source

                                                                                                                      ++  get                                               ::  grab value by key
                                                                                                                          ~/  %get
                                                                                                                          |*  b=*
                                                                                                                          =>  .(b `_?>(?=(^ a) p.n.a)`b)
                                                                                                                          |-  ^-  (unit _?>(?=(^ a) q.n.a))
                                                                                                                          ?~  a
                                                                                                                            ~
                                                                                                                          ?:  =(b p.n.a)
                                                                                                                            (some q.n.a)
                                                                                                                          ?:  (gor b p.n.a)
                                                                                                                            $(a l.a)
                                                                                                                          $(a r.a)
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > (~(get by b) 'b')
                                                                                                                          [~ u=[2 3]]
                                                                                                                      
                                                                                                                      
                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > (~(get by m) 'a')
                                                                                                                          [~ u=1]

                                                                                                                      ++got:by

                                                                                                                      Assert

                                                                                                                      Produce the value located at key b within map a. Crash if key b does not exist.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      Produces

                                                                                                                      A noun.

                                                                                                                      Source

                                                                                                                      ++  got                                               ::  need value by key
                                                                                                                          |*  b=*
                                                                                                                          (need (get b))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > m
                                                                                                                          [n=[p='b' q=2] l={[p='a' q=1]} r={}]
                                                                                                                      
                                                                                                                          > (~(got by m) 'a')
                                                                                                                          1
                                                                                                                      
                                                                                                                          > (~(got by m) 'c')
                                                                                                                          ! exit

                                                                                                                      ++gut:by

                                                                                                                      Grab value with default

                                                                                                                      Produce the value located at key b within map a. Use default value c if key does not exist.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      c is a noun.

                                                                                                                      Produces

                                                                                                                      A noun.

                                                                                                                      Source

                                                                                                                      ++  gut                                               ::  fall value by key
                                                                                                                            |*  [b=* c=*]
                                                                                                                            (fall (get b) c)
                                                                                                                      
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > m
                                                                                                                          [n=[p='b' q=2] l={[p='a' q=1]} r={}]
                                                                                                                      
                                                                                                                          > (~(gut by m) 'a' 0)
                                                                                                                          1
                                                                                                                      
                                                                                                                          > (~(gut by m) 'c' 0)
                                                                                                                          0

                                                                                                                      ++has:by

                                                                                                                      Key existence check

                                                                                                                      Checks whether map a contains an element with key b, producing a flag.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a key as a noun.

                                                                                                                      Produces

                                                                                                                      A flag.

                                                                                                                      Source

                                                                                                                      ++  has                                               ::  key existence check
                                                                                                                          ~/  %has
                                                                                                                          |*  b=*
                                                                                                                          !=(~ (get b))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =b (my [['a' 1] ['b' [2 3]] ~])
                                                                                                                          > (~(has by b) 'b')
                                                                                                                          %.y
                                                                                                                      
                                                                                                                          > (~(has by b) 'c')
                                                                                                                          %.n

                                                                                                                      ++int:by

                                                                                                                      Intersection

                                                                                                                      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.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a map.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  int                                               ::  intersection
                                                                                                                          ~/  %int
                                                                                                                          =+  b=a
                                                                                                                          |@
                                                                                                                          ++  $
                                                                                                                            |-  ^+  a
                                                                                                                            ?~  b
                                                                                                                              ~
                                                                                                                            ?~  a
                                                                                                                              ~
                                                                                                                            ?:  (mor p.n.a p.n.b)
                                                                                                                              ?:  =(p.n.b p.n.a)
                                                                                                                                b(l $(a l.a, b l.b), r $(a r.a, b r.b))
                                                                                                                              ?:  (gor p.n.b p.n.a)
                                                                                                                                %-  uni(a $(a l.a, r.b ~))  $(b r.b)
                                                                                                                              %-  uni(a $(a r.a, l.b ~))  $(b l.b)
                                                                                                                            ?:  =(p.n.a p.n.b)
                                                                                                                              b(l $(b l.b, a l.a), r $(b r.b, a r.a))
                                                                                                                            ?:  (gor p.n.a p.n.b)
                                                                                                                              %-  uni(a $(b l.b, r.a ~))  $(a r.a)
                                                                                                                            %-  uni(a $(b r.b, l.a ~))  $(a l.a)
                                                                                                                          --
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =n (my [['a' 1] ['c' 3] ~])
                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                      
                                                                                                                          > (~(int by m) n)
                                                                                                                          [n=[p='a' q=1] l=~ r=~]
                                                                                                                      
                                                                                                                          > =p (my [['a' 2] ['b' 2] ~])
                                                                                                                          > p
                                                                                                                          [n=[p='b' q=2] l={[p='a' q=2]} r={}]
                                                                                                                          > (~(int by p) n)
                                                                                                                          [n=[p='a' q=1] l=~ r=~]
                                                                                                                      
                                                                                                                          > =q (my [['a' 2] ['c' 2] ~])
                                                                                                                          > q
                                                                                                                          [n=[p='c' q=2] l={[p='a' q=2]} r={}]
                                                                                                                          > (~(int by p) q)
                                                                                                                          [n=[p='a' q=2] l=~ r=~]
                                                                                                                      
                                                                                                                          > =o (my [['c' 3] ['d' 4] ~])
                                                                                                                          > (~(int by m) o)
                                                                                                                          ~

                                                                                                                      ++key:by

                                                                                                                      Set of keys

                                                                                                                      Produces a set of all keys in map a that is prepended to set b, which is empty by default.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a set.

                                                                                                                      Produces

                                                                                                                      A set.

                                                                                                                      Source

                                                                                                                      ++  key
                                                                                                                        =+  b=`(set _?>(?=(^ a) p.n.a))`~
                                                                                                                        |-  ^+  b
                                                                                                                        ?~  a   b
                                                                                                                        $(a r.a, b $(a l.a, b (~(put in b) p.n.a)))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                        > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                        [n=[p='b' q=2] l={[p='a' q=1]} r={}]
                                                                                                                      
                                                                                                                        > ~(key by m)
                                                                                                                        {'b' 'a'}

                                                                                                                      ++mar:by

                                                                                                                      Assert and add

                                                                                                                      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.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a unit.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Assert and Add

                                                                                                                      ++  mar                                               ::  add with validation
                                                                                                                          |*  [b=* c=(unit *)]
                                                                                                                          ?~  c
                                                                                                                            (del b)
                                                                                                                          (put b u.c)
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > (~(mar by m) 'c' (some 3))
                                                                                                                          [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
                                                                                                                      
                                                                                                                          > (~(mar by m) 'c' ~)
                                                                                                                          [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
                                                                                                                      
                                                                                                                          > (~(mar by m) 'b' ~)
                                                                                                                          [n=[p='a' q=1] l=~ r=~]

                                                                                                                      ++put:by

                                                                                                                      Add key-value pair

                                                                                                                      Produces a with the addition of the key-value pair of b and c.

                                                                                                                      Accepts

                                                                                                                      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.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  put                                               ::  adds key-value pair
                                                                                                                          ~/  %put
                                                                                                                          |*  [b=* c=*]
                                                                                                                          |-  ^+  a
                                                                                                                          ?~  a
                                                                                                                            [[b c] ~ ~]
                                                                                                                          ?:  =(b p.n.a)
                                                                                                                            ?:  =(c q.n.a)
                                                                                                                              a
                                                                                                                            a(n [b c])
                                                                                                                          ?:  (gor b p.n.a)
                                                                                                                            =+  d=$(a l.a)
                                                                                                                            ?>  ?=(^ d)
                                                                                                                            ?:  (mor p.n.a p.n.d)
                                                                                                                              a(l d)
                                                                                                                            d(r a(l r.d))
                                                                                                                          =+  d=$(a r.a)
                                                                                                                          ?>  ?=(^ d)
                                                                                                                          ?:  (mor p.n.a p.n.d)
                                                                                                                            a(r d)
                                                                                                                          d(l a(r l.d))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > (~(put by ~) 'c' 3)
                                                                                                                          [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
                                                                                                                      
                                                                                                                          > (~(put by m) "zod" 26)
                                                                                                                          ! nest-fail
                                                                                                                          ! exit
                                                                                                                      
                                                                                                                          > (~(put by m) 'a' 2)
                                                                                                                          [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
                                                                                                                      
                                                                                                                          > (put:by m 'a' 2)
                                                                                                                          {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}

                                                                                                                      ++rep:by

                                                                                                                      Replace by product

                                                                                                                      Accumulate elements of map a using gate b, producing a noun.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate.

                                                                                                                      Produces

                                                                                                                      A noun.

                                                                                                                      Source

                                                                                                                      ++  rep                                               ::  reduce to product
                                                                                                                          ~/  %rep
                                                                                                                          |*  b=_=>(~ |=([* *] +<+))
                                                                                                                          |-
                                                                                                                          ?~  a  +<+.b
                                                                                                                          $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > (~(rep by m) |=(a=(pair * *) p.a))
                                                                                                                          q=[97 1]

                                                                                                                      ++rib:by

                                                                                                                      Replace values with accumulator

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a noun.

                                                                                                                      c is a wet gate.

                                                                                                                      A cell of nouns.

                                                                                                                      Source

                                                                                                                      ++  rib                                               ::  transform + product
                                                                                                                          |*  [b=* c=gate]
                                                                                                                          |-  ^+  [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 a(l +.e, r +.f)]
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          > (~(rib by m) [1 2] (con by m))
                                                                                                                      
                                                                                                                          > (~(rep by m) [1 2] |=(a=(pair * *) p.a))

                                                                                                                      ++run:by

                                                                                                                      Transform values

                                                                                                                      Iterates over every value in map a using gate b, producing a map.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  run                                               ::  apply gate to values
                                                                                                                          ~/  %run
                                                                                                                          |*  b=gate
                                                                                                                          |-
                                                                                                                          ?~  a  a
                                                                                                                          [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                      
                                                                                                                          > ^+(m (~(run by m) dec))
                                                                                                                          [n=[p='b' q=1] l={[p='a' q=0]} r={}]
                                                                                                                      
                                                                                                                          > `(map @tas @t)`(~(run by m) (cury scot %ux))
                                                                                                                          {[p=%a q='0x1'] [p=%b q='0x2']}

                                                                                                                      ++rut:by

                                                                                                                      Transform nodes

                                                                                                                      Applies a gate b to nodes in map a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  rut                                               ::  apply gate to nodes
                                                                                                                          |*  b=gate
                                                                                                                          |-
                                                                                                                          ?~  a  a
                                                                                                                          [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])

                                                                                                                      ++tap:by

                                                                                                                      Listify pairs

                                                                                                                      Produces the list of all elements in map a that is prepended to list b, which is empty by default.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a list.

                                                                                                                      Produces

                                                                                                                      A list.

                                                                                                                      Source

                                                                                                                      ++  tap                                               ::  listify pairs
                                                                                                                          =<  $
                                                                                                                          ~/  %tap
                                                                                                                          =+  b=`(list _?>(?=(^ a) n.a))`~
                                                                                                                          |.  ^+  b
                                                                                                                          ?~  a
                                                                                                                            b
                                                                                                                          $(a r.a, b [n.a $(a l.a)])
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                          [n=[p='b' q=2] l={[p='a' q=1]} r={}]
                                                                                                                          > `*`m
                                                                                                                          [[98 2] [[97 1] 0 0] 0]
                                                                                                                      
                                                                                                                          > ~(tap by m)
                                                                                                                          ~[[p='b' q=2] [p='a' q=1]]
                                                                                                                          > `*`~(tap by m)
                                                                                                                          [[98 2] [97 1] 0]

                                                                                                                      ++uni:by

                                                                                                                      Union

                                                                                                                      Produces a map of the union between the keys of a and b. If b shares a key with a, the tuple from b is preserved.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a map.

                                                                                                                      Produces

                                                                                                                      A map.

                                                                                                                      Source

                                                                                                                      ++  uni                                               ::  union, merge
                                                                                                                          ~/  %uni
                                                                                                                          =+  b=a
                                                                                                                          |@
                                                                                                                          ++  $
                                                                                                                            |-  ^+  a
                                                                                                                            ?~  b
                                                                                                                              a
                                                                                                                            ?~  a
                                                                                                                              b
                                                                                                                            ?:  =(p.n.b p.n.a)
                                                                                                                              b(l $(a l.a, b l.b), r $(a r.a, b r.b))
                                                                                                                            ?:  (mor p.n.a p.n.b)
                                                                                                                              ?:  (gor p.n.b p.n.a)
                                                                                                                                $(l.a $(a l.a, r.b ~), b r.b)
                                                                                                                              $(r.a $(a r.a, l.b ~), b l.b)
                                                                                                                            ?:  (gor p.n.a p.n.b)
                                                                                                                              $(l.b $(b l.b, r.a ~), a r.a)
                                                                                                                            $(r.b $(b r.b, l.a ~), a l.a)
                                                                                                                          --
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                      
                                                                                                                          > =o (my [['c' 3] ['d' 4] ~])
                                                                                                                      
                                                                                                                          > (~(uni by m) o)
                                                                                                                          [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
                                                                                                                      
                                                                                                                          > (~(uni by m) ~)
                                                                                                                          {[p='a' q=1] [p='b' q=2]}
                                                                                                                      
                                                                                                                          > n
                                                                                                                          {[p='a' q=1] [p='c' q=3]}
                                                                                                                          > (~(uni by o) n)
                                                                                                                          {[p='d' q=4] [p='a' q=1] [p='c' q=3]}

                                                                                                                      ++urn:by

                                                                                                                      Turn (with key)

                                                                                                                      Iterates over every value in map a using gate b, which accepts both the key and the value of each element as its sample.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a wet gate that accepts two nouns.

                                                                                                                      Produces

                                                                                                                      A noun.

                                                                                                                      Source

                                                                                                                      ++  urn                                               ::  apply gate to nodes
                                                                                                                          ~/  %urn
                                                                                                                          |*  b=$-([* *] *)
                                                                                                                          |-
                                                                                                                          ?~  a  ~
                                                                                                                          a(n n.a(q (b p.n.a q.n.a)), l $(a l.a), r $(a r.a))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > m
                                                                                                                          {[p='a' q=1] [p='b' q=2]}
                                                                                                                      
                                                                                                                          > (~(urn by m) |=(a=(pair * *) q.a))
                                                                                                                          {[p='a' q=1] [p='b' q=2]}
                                                                                                                      
                                                                                                                          > (~(urn by m) |=(a=(pair * *) 7))
                                                                                                                          {[p='a' q=7] [p='b' q=7]}
                                                                                                                      
                                                                                                                          > (~(urn by m) |=(a=(pair * *) p.a))
                                                                                                                          {[p='a' q=97] [p='b' q=98]}

                                                                                                                      ++wyt:by

                                                                                                                      Depth

                                                                                                                      Produce the depth of the tree map a.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      Produces

                                                                                                                      An atom.

                                                                                                                      Source

                                                                                                                      ++  wyt                                               ::  depth of map
                                                                                                                          =<  $
                                                                                                                          ~%  %wyt  +  ~
                                                                                                                          |.  ^-  @
                                                                                                                          ?~(a 0 +((add $(a l.a) $(a r.a))))
                                                                                                                      

                                                                                                                      Examples

                                                                                                                          > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                      
                                                                                                                          > =o (my [['c' 3] ['d' 4] ~])
                                                                                                                      
                                                                                                                          > ~(wyt by m)
                                                                                                                          2
                                                                                                                      
                                                                                                                          > ~(wyt by o)
                                                                                                                          2
                                                                                                                      
                                                                                                                          > ~(wyt by (~(uni by m) o))
                                                                                                                          4

                                                                                                                      ++val:by

                                                                                                                      List of values

                                                                                                                      Produces a list of all values in map a that is prepended to list b, which is empty by default.

                                                                                                                      Accepts

                                                                                                                      a is a map.

                                                                                                                      b is a list.

                                                                                                                      Produces

                                                                                                                      A list.

                                                                                                                      Source

                                                                                                                      ++  val
                                                                                                                        =+  b=`(list _?>(?=(^ a) q.n.a))`~
                                                                                                                        |-  ^+  b
                                                                                                                        ?~  a   b
                                                                                                                        $(a r.a, b [q.n.a $(a l.a)])
                                                                                                                      

                                                                                                                      Examples

                                                                                                                        > =m (my [['a' 1] ['b' 2] ~])
                                                                                                                        [n=[p='b' q=2] l={[p='a' q=1]} r={}]
                                                                                                                      
                                                                                                                        > ~(val by m)
                                                                                                                        ~[1 2]

                                                                                                                      <-

                                                                                                                      2h: Set Logic

                                                                                                                      2j: Jar and Jug Logic

                                                                                                                      ->