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/Runes

                                                                                                                      Conditionals ? ('wut')

                                                                                                                      Hoon has the usual program control branches. It also has the usual logical operators: AND ?&, OR ?|, and NOT ?!. It also has a ?= rune that tests whether a value matches a given type. In the course of type inference, Hoon learns from ?= tests in the test condition of ?: ("wutcol") expressions.

                                                                                                                      Overview

                                                                                                                      All ? runes reduce to ?: and/or ?=.

                                                                                                                      If the condition of an ?: is a ?=, and the ?= is testing a leg of the subject, the compiler specializes the subject type for the branches of the ?:. Branch inference also works for expressions which expand to ?:.

                                                                                                                      The test does not have to be a single ?=; the compiler can analyze arbitrary boolean logic (?& ("wutpam"), ?| ("wutbar"), ?! ("wutzap")) with full short-circuiting. Equality tests (.= ("dottis")) are not analyzed.

                                                                                                                      If the compiler detects that the branch is degenerate (only one side is taken), it fails with an error.

                                                                                                                      Runes

                                                                                                                      ?> "wutgar"

                                                                                                                      [%wtgr p=hoon q=hoon]: positive assertion.

                                                                                                                      Expands to
                                                                                                                      ?.(p !! q)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 2-fixed.

                                                                                                                      Discussion

                                                                                                                      ?> is used to force a crash when some condition p doesn't yield 'yes', %.y.

                                                                                                                      It can be used for type inference, with the ?= rune, to specify the type of a value.

                                                                                                                      Examples
                                                                                                                      > ?>(=(3 3) %foo)
                                                                                                                      %foo
                                                                                                                      
                                                                                                                      > ?>(=(3 4) %foo)
                                                                                                                      ford: build failed
                                                                                                                      
                                                                                                                      > =a `*`123
                                                                                                                      
                                                                                                                      > `@`a
                                                                                                                      nest-fail
                                                                                                                      
                                                                                                                      > ?>(?=(@ a) `@`a)
                                                                                                                      123

                                                                                                                      ?| "wutbar"

                                                                                                                      [%wtbr p=(list hoon)]: logical OR.

                                                                                                                      Expands to

                                                                                                                      Pseudocode: a, b, c, ... as elements of p:

                                                                                                                      ?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
                                                                                                                      
                                                                                                                      Desugaring
                                                                                                                      |-
                                                                                                                      ?~  p
                                                                                                                        |
                                                                                                                      ?:  i.p
                                                                                                                        &
                                                                                                                      $(p t.p)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: running.

                                                                                                                      Irregular: |(foo bar baz) is ?|(foo bar baz).

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> |(=(6 42) =(42 42))
                                                                                                                      %.y
                                                                                                                      
                                                                                                                      ~zod:dojo> |(=(6 42) =(42 43))
                                                                                                                      %.n

                                                                                                                      ?: "wutcol"

                                                                                                                      [%wtcl p=hoon q=hoon r=hoon]: branch on a boolean test.

                                                                                                                      Produces

                                                                                                                      If p produces yes, %.y, then q. If p produces no, %.n, then r. If p is not a boolean, compiler yells at you.

                                                                                                                      Type inference

                                                                                                                      The subject types of q and r are constrained to match any pattern-matching algebra in p. The analysis, which is conservative, understands any combination of ?=, ?&, ?|, and ?!, and infers the type of the subject appropriately when compiling.

                                                                                                                      If test analysis reveals that either branch is never taken, or if p is not a boolean, compilation fails. An untaken branch is indicated with mint-lost.

                                                                                                                      Syntax

                                                                                                                      Regular: 3-fixed.

                                                                                                                      Discussion

                                                                                                                      Short-circuiting in boolean tests works as you'd expect and includes the expected inference. For instance, if you write ?&(a b), b is only executed if a is positive, and compiled with that assumption.

                                                                                                                      Note also that all other branching expressions reduce to ?:.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> ?:((gth 1 0) 3 4)
                                                                                                                      3
                                                                                                                      
                                                                                                                      ~zod:dojo> ?:  (gth 1 0)
                                                                                                                                   3
                                                                                                                                 4
                                                                                                                      3
                                                                                                                      
                                                                                                                      ~zod:dojo> ?:((gth 1 2) 3 4)
                                                                                                                      4
                                                                                                                      
                                                                                                                      ~zod:dojo> ?:  (gth 1 2)
                                                                                                                                   3
                                                                                                                                 4
                                                                                                                      4

                                                                                                                      ?. "wutdot"

                                                                                                                      [%wtdt p=hoon q=hoon r=hoon]: branch on a boolean test, inverted.

                                                                                                                      Expands to
                                                                                                                      ?:(p r q)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 3-fixed.

                                                                                                                      Discussion

                                                                                                                      ?. is just like ?:, but with its last two subexpressions reversed.

                                                                                                                      As is usual with inverted forms, use ?. when the yes-case expression is much taller and/or wider than the no-case expression.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> ?.((gth 1 2) 3 4)
                                                                                                                      3
                                                                                                                      
                                                                                                                      ~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
                                                                                                                      %yup
                                                                                                                      
                                                                                                                      ~zod:dojo> ?.  %.y
                                                                                                                                   'this false case is less heavy than the true case'
                                                                                                                                 ?:  =(2 3)
                                                                                                                                   'two not equal to 3'
                                                                                                                                 'but see how \'r is much heavier than \'q?'
                                                                                                                      'but see how \'r is much heavier than \'q?'

                                                                                                                      ?- "wuthep"

                                                                                                                      [%wthp p=wing q=(list (pair spec value))]: switch against a union, with no default.

                                                                                                                      Expands to

                                                                                                                      Pseudocode: a, b, c, ... as elements of q:

                                                                                                                      ?:  ?=(p.a p)  q.a
                                                                                                                      ?:  ?=(p.b p)  q.b
                                                                                                                      ?:  ?=(p.c p)  q.c
                                                                                                                      ...
                                                                                                                      ~|(%mint-lost !!)
                                                                                                                      
                                                                                                                      Desugaring
                                                                                                                      |-
                                                                                                                      ?.  q
                                                                                                                        ~|(%mint-lost !!)
                                                                                                                      ?:  ?=(p.i.q p)
                                                                                                                        q.i.q
                                                                                                                      $(q t.q)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 1-fixed, then jogging.

                                                                                                                      Discussion

                                                                                                                      The ?- rune is for a conditional expression in which the type of p determines which branch is taken. Usually the type of p is a union of other types. There is no default branch.

                                                                                                                      The compiler makes sure that your code neither misses a case of the union, nor includes a double case that isn't there. This is not special handling for ?-, just a consequence of the semantics of ?:, which ?- reduces to.

                                                                                                                      A missing case will throw the mint-lost error. An extra case will throw mint-vain.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> =cor  |=  vat=?(%a %b)
                                                                                                                                       ?-  vat
                                                                                                                                         %a  20
                                                                                                                                         %b  42
                                                                                                                                       ==
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %a)
                                                                                                                      20
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %b)
                                                                                                                      42
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %c)
                                                                                                                      ! nest-fail

                                                                                                                      ?^ "wutket"

                                                                                                                      [%wtkt p=wing q=hoon r=hoon]: branch on whether a wing of the subject is a cell.

                                                                                                                      Expands to
                                                                                                                      ?:(?=(^ p) q r)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 3-fixed.

                                                                                                                      Discussion

                                                                                                                      The type of the wing, p, must not be known to be either an atom or a cell, or else you'll get a mint-vain error at compile time. mint-vain means that one of the ?^ branches, q or r, is never taken.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> ?^(0 1 2)
                                                                                                                      ! mint-vain
                                                                                                                      ! exit
                                                                                                                      
                                                                                                                      ~zod:dojo> ?^(`*`0 1 2)
                                                                                                                      2
                                                                                                                      
                                                                                                                      ~zod:dojo> ?^(`*`[1 2] 3 4)
                                                                                                                      3

                                                                                                                      ?< "wutgal"

                                                                                                                      [%wtgl p=hoon q=hoon]: negative assertion.

                                                                                                                      Expands to
                                                                                                                      ?:(p !! q)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 2-fixed.

                                                                                                                      Discussion

                                                                                                                      ?< is used to force a crash when some condition p doesn't yield 'no', %.n.

                                                                                                                      It can be used for type inference with the ?= rune, much like the ?> rune.

                                                                                                                      Examples
                                                                                                                      > ?<(=(3 4) %foo)
                                                                                                                      %foo
                                                                                                                      
                                                                                                                      > ?<(=(3 3) %foo)
                                                                                                                      ford: build failed
                                                                                                                      
                                                                                                                      > =a `*`[12 14]
                                                                                                                      
                                                                                                                      > `^`a
                                                                                                                      nest-fail
                                                                                                                      
                                                                                                                      > ?<(?=(@ a) `^`a)
                                                                                                                      [12 14]

                                                                                                                      ?+ "wutlus"

                                                                                                                      [%wtls p=wing q=hoon r=(list (pair spec hoon))]: switch against a union, with a default.

                                                                                                                      Expands to

                                                                                                                      Pseudocode: a, b, c, ... as elements of r:

                                                                                                                      ?:  ?=(p.a p)  q.a
                                                                                                                      ?:  ?=(p.b p)  q.b
                                                                                                                      ?:  ?=(p.c p)  q.c
                                                                                                                      ...
                                                                                                                      q
                                                                                                                      
                                                                                                                      Desugaring
                                                                                                                      |-
                                                                                                                      ?.  r
                                                                                                                        q
                                                                                                                      ?:  ?=(p.i.r p)
                                                                                                                        q.i.r
                                                                                                                      $(r t.r)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 2-fixed, then jogging.

                                                                                                                      Discussion

                                                                                                                      The ?+ rune is for a conditional expression in which the type of p determines which branch is taken. Usually the type of p is a union of other types. If p's type doesn't match the case for any given branch, the default expression, q, is evaluated.

                                                                                                                      If there is a case that is never taken you'll get a mint-vain error.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> =cor  |=  vat=@tas
                                                                                                                                       ?+  vat  240
                                                                                                                                         %a  20
                                                                                                                                         %b  42
                                                                                                                                       ==
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %a)
                                                                                                                      20
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %b)
                                                                                                                      42
                                                                                                                      
                                                                                                                      ~zod:dojo> (cor %c)
                                                                                                                      240

                                                                                                                      ?& "wutpam"

                                                                                                                      [%wtpm p=(list hoon)]: logical AND.

                                                                                                                      Expands to

                                                                                                                      Pseudocode: a, b, c, ... as elements of p:

                                                                                                                      ?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
                                                                                                                      
                                                                                                                      Desugaring
                                                                                                                      |-
                                                                                                                      ?~  p
                                                                                                                        &
                                                                                                                      ?.  i.p
                                                                                                                        |
                                                                                                                      $(p t.p)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: running.

                                                                                                                      Irregular: &(foo bar baz) is ?&(foo bar baz).

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> &(=(6 6) =(42 42))
                                                                                                                      %.y
                                                                                                                      
                                                                                                                      ~zod:dojo> &(=(6 7) =(42 43))
                                                                                                                      %.n

                                                                                                                      ?~ "wutsig"

                                                                                                                      [%wtsg p=wing q=hoon r=hoon]: branch on whether a wing of the subject is null.

                                                                                                                      Expands to
                                                                                                                      ?:(?=($~ p) q r)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 3-fixed.

                                                                                                                      Discussion

                                                                                                                      It's bad style to use ?~ to test for any zero atom. Use it only for a true null, ~.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> =foo ""
                                                                                                                      
                                                                                                                      ~zod:dojo> ?~(foo 1 2)
                                                                                                                      1

                                                                                                                      ?= "wuttis"

                                                                                                                      [%wtts p=spec q=wing]: test pattern match.

                                                                                                                      Produces

                                                                                                                      %.y (yes) if the noun at q is in the type of p; %.n (no) otherwise.

                                                                                                                      Syntax

                                                                                                                      Regular: 2-fixed.

                                                                                                                      Discussion

                                                                                                                      ?= is not as powerful as it might seem. For instance, it can't generate a loop -- you cannot (and should not) use it to test whether a * is a (list @). Nor can it validate atomic auras.

                                                                                                                      Patterns should be as weak as possible. Unpack one layer of union at a time. Don't confirm things the type system knows.

                                                                                                                      For example, when matching from a tagged union for the type [%foo p=@ q=[@ @]], the appropriate pattern is [%foo *]. You have one question, which is whether the head of the noun is %foo.

                                                                                                                      A common error is find.$, meaning p is not a type.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> =bar [%foo %bar %baz]
                                                                                                                      ~zod:dojo> ?=([%foo *] bar)
                                                                                                                      %.y

                                                                                                                      ?@ "wutpat"

                                                                                                                      [%wtpt p=wing q=hoon r=hoon]: branch on whether a wing of the subject is an atom.

                                                                                                                      Expands to
                                                                                                                      ?:(?=(@ p) q r)
                                                                                                                      
                                                                                                                      Syntax

                                                                                                                      Regular: 3-fixed.

                                                                                                                      Discussion

                                                                                                                      The type of the wing, p, must not be known to be either an atom or a cell, or else you'll get a mint-vain error at compile time. mint-vain means that one of the ?@ branches, q or r, is never taken.

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> ?@(0 1 2)
                                                                                                                      ! mint-vain
                                                                                                                      ! exit
                                                                                                                      
                                                                                                                      ~zod:dojo> ?@(`*`0 1 2)
                                                                                                                      1
                                                                                                                      
                                                                                                                      ~zod:dojo> ?@(`*`[1 2] 3 4)
                                                                                                                      4

                                                                                                                      ?! "wutzap"

                                                                                                                      [%wtzp p=hoon]: logical NOT.

                                                                                                                      Expands to
                                                                                                                      .=(| p)
                                                                                                                      

                                                                                                                      Produces the logical NOT of p.

                                                                                                                      Syntax

                                                                                                                      Regular: 1-fixed.

                                                                                                                      Irregular: !foo is ?!(foo).

                                                                                                                      Examples
                                                                                                                      ~zod:dojo> ?!(.=(1 2))
                                                                                                                      %.y
                                                                                                                      
                                                                                                                      ~zod:dojo> !&
                                                                                                                      %.n
                                                                                                                      
                                                                                                                      ~zod:dojo> !|
                                                                                                                      %.y
                                                                                                                      
                                                                                                                      ~zod:dojo> !(gth 5 6)
                                                                                                                      %.y

                                                                                                                      <-

                                                                                                                      Change Subject = ('tis')

                                                                                                                      Cores | ('bar')

                                                                                                                      ->