Urbit Docs
  • What is Urbit?
  • Get on Urbit
  • Build on Urbit
    • Contents
    • Environment Setup
    • Hoon School
      • 1. Hoon Syntax
      • 2. Azimuth (Urbit ID)
      • 3. Gates (Functions)
      • 4. Molds (Types)
      • 5. Cores
      • 6. Trees and Addressing
      • 7. Libraries
      • 8. Testing Code
      • 9. Text Processing I
      • 10. Cores and Doors
      • 11. Data Structures
      • 12. Type Checking
      • 13. Conditional Logic
      • 14. Subject-Oriented Programming
      • 15. Text Processing II
      • 16. Functional Programming
      • 17. Text Processing III
      • 18. Generic and Variant Cores
      • 19. Mathematics
    • App School I
      • 1. Arvo
      • 2. The Agent Core
      • 3. Imports and Aliases
      • 4. Lifecycle
      • 5. Cards
      • 6. Pokes
      • 7. Structures and Marks
      • 8. Subscriptions
      • 9. Vanes
      • 10. Scries
      • 11. Failure
      • 12. Next Steps
      • Appendix: Types
    • App School II (Full-Stack)
      • 1. Types
      • 2. Agent
      • 3. JSON
      • 4. Marks
      • 5. Eyre
      • 6. React app setup
      • 7. React app logic
      • 8. Desk and glob
      • 9. Summary
    • Core Academy
      • 1. Evaluating Nock
      • 2. Building Hoon
      • 3. The Core Stack
      • 4. Arvo I: The Main Sequence
      • 5. Arvo II: The Boot Sequence
      • 6. Vere I: u3 and the Serf
      • 7. Vere II: The Loom
      • 8. Vanes I: Behn, Dill, Kahn, Lick
      • 9. Vanes II: Ames
      • 10. Vanes III: Eyre, Iris
      • 11. Vanes IV: Clay
      • 12. Vanes V: Gall and Userspace
      • 13. Vanes VI: Khan, Lick
      • 14. Vanes VII: Jael, Azimuth
    • Runtime
      • U3
      • Conn.c Guide
      • How to Write a Jet
      • API Overview by Prefix
      • C in Urbit
      • Cryptography
      • Land of Nouns
    • Tools
      • Useful Links
      • JS Libraries
        • HTTP API
      • Docs App
        • File Format
        • Index File
        • Suggested Structure
    • Userspace
      • Command-Line App Tutorial
      • Remote Scry
      • Unit Tests
      • Software Distribution
        • Software Distribution Guide
        • Docket File
        • Glob
      • Examples
        • Building a CLI App
        • Debugging Wrapper
        • Host a Website
        • Serving a JS Game
        • Ship Monitoring
        • Styled Text
  • Urbit ID
    • What is Urbit ID?
    • Azimuth Data Flow
    • Life and Rift
    • Urbit HD Wallet
    • Advanced Azimuth Tools
    • Custom Roller Tutorial
    • Azimuth.eth Reference
    • Ecliptic.eth Reference
    • Layer 2
      • L2 Actions
      • L2 Rollers
      • L2 Roller HTTP RPC-API
      • L2 Transaction Format
  • Urbit OS
    • What is Urbit OS?
    • Base
      • Hood
      • Threads
        • Basics Tutorial
          • Bind
          • Fundamentals
          • Input
          • Output
          • Summary
        • HTTP API Guide
        • Spider API Reference
        • Strandio Reference
        • Examples
          • Child Thread
          • Fetch JSON
          • Gall
            • Poke Thread
            • Start Thread
            • Stop Thread
            • Take Facts
            • Take Result
          • Main-loop
          • Poke Agent
          • Scry
          • Take Fact
    • Kernel
      • Arvo
        • Cryptography
        • Move Trace
        • Scries
        • Subscriptions
      • Ames
        • Ames API Reference
        • Ames Cryptography
        • Ames Data Types
        • Ames Scry Reference
      • Behn
        • Behn API Reference
        • Behn Examples
        • Behn Scry Reference
      • Clay
        • Clay API Reference
        • Clay Architecture
        • Clay Data Types
        • Clay Examples
        • Clay Scry Reference
        • Filesystem Hierarchy
        • Marks
          • Mark Examples
          • Using Marks
          • Writing Marks
        • Using Clay
      • Dill
        • Dill API Reference
        • Dill Data Types
        • Dill Scry Reference
      • Eyre
        • EAuth
        • Eyre Data Types
        • Eyre External API
        • Eyre Internal API
        • Eyre Scry Reference
        • Low-Level Eyre Guide
        • Noun channels
      • Gall
        • Gall API Reference
        • Gall Data Types
        • Gall Scry Reference
      • Iris
        • Iris API Reference
        • Iris Data Types
        • Iris Example
      • Jael
        • Jael API Reference
        • Jael Data Types
        • Jael Examples
        • Jael Scry Reference
      • Khan
        • Khan API Reference
        • Khan Data Types
        • Khan Example
      • Lick
        • Lick API Reference
        • Lick Guide
        • Lick Examples
        • Lick Scry Reference
  • Hoon
    • Why Hoon?
    • Advanced Types
    • Arvo
    • Auras
    • Basic Types
    • Cheat Sheet
    • Cryptography
    • Examples
      • ABC Blocks
      • Competitive Programming
      • Emirp
      • Gleichniszahlenreihe
      • Islands
      • Luhn Number
      • Minimum Path Sum
      • Phone Letters
      • Restore IP
      • Rhonda Numbers
      • Roman Numerals
      • Solitaire Cipher
      • Water Towers
    • Generators
    • Hoon Errors
    • Hoon Style Guide
    • Implementing an Aura
    • Irregular forms
    • JSON
    • Limbs and wings
      • Limbs
      • Wings
    • Mips (Maps of Maps)
    • Parsing Text
    • Runes
      • | bar · Cores
      • $ buc · Structures
      • % cen · Calls
      • : col · Cells
      • . dot · Nock
      • / fas · Imports
      • ^ ket · Casts
      • + lus · Arms
      • ; mic · Make
      • ~ sig · Hints
      • = tis · Subject
      • ? wut · Conditionals
      • ! zap · Wild
      • Constants (Atoms and Strings)
      • --, == · Terminators
    • Sail (HTML)
    • Serialization
    • Sets
    • Standard Library
      • 1a: Basic Arithmetic
      • 1b: Tree Addressing
      • 1c: Molds and Mold-Builders
      • 2a: Unit Logic
      • 2b: List Logic
      • 2c: Bit Arithmetic
      • 2d: Bit Logic
      • 2e: Insecure Hashing
      • 2f: Noun Ordering
      • 2g: Unsigned Powers
      • 2h: Set Logic
      • 2i: Map Logic
      • 2j: Jar and Jug Logic
      • 2k: Queue Logic
      • 2l: Container from Container
      • 2m: Container from Noun
      • 2n: Functional Hacks
      • 2o: Normalizing Containers
      • 2p: Serialization
      • 2q: Molds and Mold-Builders
      • 3a: Modular and Signed Ints
      • 3b: Floating Point
      • 3c: Urbit Time
      • 3d: SHA Hash Family
      • 3e: AES encryption (Removed)
      • 3f: Scrambling
      • 3g: Molds and Mold-Builders
      • 4a: Exotic Bases
      • 4b: Text Processing
      • 4c: Tank Printer
      • 4d: Parsing (Tracing)
      • 4e: Parsing (Combinators)
      • 4f: Parsing (Rule-Builders)
      • 4g: Parsing (Outside Caller)
      • 4h: Parsing (ASCII Glyphs)
      • 4i: Parsing (Useful Idioms)
      • 4j: Parsing (Bases and Base Digits)
      • 4k: Atom Printing
      • 4l: Atom Parsing
      • 4m: Formatting Functions
      • 4n: Virtualization
      • 4o: Molds
      • 5a: Compiler Utilities
      • 5b: Macro Expansion
      • 5c: Compiler Backend & Prettyprinter
      • 5d: Parser
      • 5e: Molds and mold builders
      • 5f: Profiling support
    • Strings
    • The Engine Pattern
    • Udon (Markdown-esque)
    • Vases
    • Zuse
      • 2d(1-5): To JSON, Wains
      • 2d(6): From JSON
      • 2d(7): From JSON (unit)
      • 2e(2-3): Print & Parse JSON
      • 2m: Ordered Maps
  • Nock
    • What is Nock?
    • Decrement
    • Definition
    • Fast Hints and Jets
    • Implementations
    • Specification
  • User Manual
    • Contents
    • Running Urbit
      • Cloud Hosting
      • Home Servers
      • Runtime Reference
      • Self-hosting S3 Storage with MinIO
    • Urbit ID
      • Bridge Troubleshooting
      • Creating an Invite Pool
      • Get an Urbit ID
      • Guide to Factory Resets
      • HD Wallet (Master Ticket)
      • Layer 2 for planets
      • Layer 2 for stars
      • Proxies
      • Using Bridge
    • Urbit OS
      • Basics
      • Configuring S3 Storage
      • Dojo Tools
      • Filesystem
      • Shell
      • Ship Troubleshooting
      • Star and Galaxy Operations
      • Updates
Powered by GitBook

GitHub

  • Urbit ID
  • Urbit OS
  • Runtime

Resources

  • YouTube
  • Whitepaper
  • Awesome Urbit

Contact

  • X
  • Email
  • Gather
On this page
  • +co
  • ++rear:co
  • ++rent:co
  • ++rend:co
  • ++a-co:co
  • ++c-co:co
  • ++d-co:co
  • ++r-co:co
  • ++s-co:co
  • ++v-co:co
  • ++w-co:co
  • ++x-co:co
  • ++y-co:co
  • ++z-co:co
  • ++em-co:co
  • ++ed-co:co
  • ++ox-co:co
  • ++ro-co:co
Edit on GitHub
  1. Hoon
  2. Standard Library

4k: Atom Printing

+co

Literal rendering engine

++co contains three parts:

  • A door that contains arms that operate on the sample coin lot.

  • A core of rendering idioms.

  • A core of additional formatting functions used internally.

Accepts

lot is a coin.

Source

The arm begins with the door:

++  co
  !:
  ~%  %co  ..co  ~
  =<  |_  lot=coin

Then after that the rendering idiom core begins with:

=|  rep=tape
=<  |%

And finally the third core:

|%

++rear:co

Prepend & render as tape

Renders a coin lot as a tape prepended to the sample tape rom.

Accepts

lot is a coin, and is the sample of ++co.

rom is a tape.

Produces

A tape.

Source

++  rear  |=(rom=tape rend(rep rom))

Examples

> (~(rear co %$ %ux 200) "--ha")
"0xc8--ha"

++rent:co

Render as knot

Renders a coin lot as a knot.

Accepts

lot is a coin, and is the sample of ++co.

Produces

A knot.

Source

++  rent  ~+  `@ta`(rap 3 rend)

Examples

> ~(rent co %$ %ux 200)
~.0xc8

> `@t`~(rent co %$ %ux 200)
'0xc8'

++rend:co

Render as tape

Renders a coin lot as a tape.

Accepts

lot is a coin, and is the sample of ++co.

Produces

A tape.

Source

++  rend
  ^-  tape
  ~+
  ?:  ?=(%blob -.lot)
    ['~' '0' ((v-co 1) (jam p.lot))]
  ?:  ?=(%many -.lot)
    :-  '.'
    |-  ^-  tape
    ?~   p.lot
      ['_' '_' rep]
    ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))]
  =+  [yed=(end 3 p.p.lot) hay=(cut 3 [1 1] p.p.lot)]
  |-  ^-  tape
  ?+    yed  (z-co q.p.lot)
      %c   ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)]
      %d
    ?+    hay  (z-co q.p.lot)
        %a
      =+  yod=(yore q.p.lot)
      =?  rep  ?=(^ f.t.yod)  ['.' (s-co f.t.yod)]
      =?  rep  !&(?=(~ f) =(0 h) =(0 m) =(0 s)):t.yod
        =.  rep  ['.' (y-co s.t.yod)]
        =.  rep  ['.' (y-co m.t.yod)]
        ['.' '.' (y-co h.t.yod)]
      =.  rep  ['.' (a-co d.t.yod)]
      =.  rep  ['.' (a-co m.yod)]
      =?  rep  !a.yod  ['-' rep]
      ['~' (a-co y.yod)]
    ::
        %r
      =+  yug=(yell q.p.lot)
      =?  rep  ?=(^ f.yug)  ['.' (s-co f.yug)]
      :-  '~'
      ?:  &(=(0 d.yug) =(0 m.yug) =(0 h.yug) =(0 s.yug))
        ['s' '0' rep]
      =?  rep  !=(0 s.yug)  ['.' 's' (a-co s.yug)]
      =?  rep  !=(0 m.yug)  ['.' 'm' (a-co m.yug)]
      =?  rep  !=(0 h.yug)  ['.' 'h' (a-co h.yug)]
      =?  rep  !=(0 d.yug)  ['.' 'd' (a-co d.yug)]
      +.rep
    ==
  ::
      %f
    ?:  =(& q.p.lot)
      ['.' 'y' rep]
    ?:(=(| q.p.lot) ['.' 'n' rep] (z-co q.p.lot))
  ::
      %n   ['~' rep]
      %i
    ?+  hay  (z-co q.p.lot)
      %f  ((ro-co [3 10 4] |=(a=@ ~(d ne a))) q.p.lot)
      %s  ((ro-co [4 16 8] |=(a=@ ~(x ne a))) q.p.lot)
    ==
  ::
      %p
    =+  sxz=(fein:ob q.p.lot)
    =+  dyx=(met 3 sxz)
    :-  '~'
    ?:  (lte dyx 1)
      (weld (trip (tod:po sxz)) rep)
    =+  dyy=(met 4 sxz)
    =|  imp=@ud
    |-  ^-  tape
    ?:  =(imp dyy)
      rep
    %=  $
      imp  +(imp)
      rep  =/  log  (cut 4 [imp 1] sxz)
           ;:  weld
             (trip (tos:po (rsh 3 log)))
             (trip (tod:po (end 3 log)))
             ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-")
             rep
    ==     ==
  ::
      %q
    :+  '.'  '~'
    =;  res=(pair ? tape)
      (weld q.res rep)
    %+  roll
      =*  val  q.p.lot
      ?:(=(0 val) ~[0] (rip 3 val))
    |=  [q=@ s=? r=tape]
    :-  !s
    %+  weld
     (trip (?:(s tod:po tos:po) q))
    ?.(&(s !=(r "")) r ['-' r])
  ::
      %r
    ?+  hay  (z-co q.p.lot)
      %d  ['.' '~' (r-co (rlyd q.p.lot))]
      %h  ['.' '~' '~' (r-co (rlyh q.p.lot))]
      %q  ['.' '~' '~' '~' (r-co (rlyq q.p.lot))]
      %s  ['.' (r-co (rlys q.p.lot))]
    ==
  ::
      %u
    ?:  ?=(%c hay)
      %+  welp  ['0' 'c' (reap (pad:fa q.p.lot) '1')]
      (c-co (enc:fa q.p.lot))
    ::
    =;  gam=(pair tape tape)
      (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam))
    ?+  hay  [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)]
      %b  [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)]
      %i  [['0' 'i' ~] ((d-co 1) q.p.lot)]
      %x  [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)]
      %v  [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)]
      %w  [['0' 'w' ~] ((ox-co [64 5] |=(a=@ ~(w ne a))) q.p.lot)]
    ==
  ::
      %s
    %+  weld
      ?:((syn:si q.p.lot) "--" "-")
    $(yed 'u', q.p.lot (abs:si q.p.lot))
  ::
      %t
    ?:  =('a' hay)
      ?:  =('s' (cut 3 [2 1] p.p.lot))
        (weld (rip 3 q.p.lot) rep)
      ['~' '.' (weld (rip 3 q.p.lot) rep)]
    ['~' '~' (weld (rip 3 (wood q.p.lot)) rep)]
  ==

Examples

> ~(rend co %$ %ux 200)
"0xc8"

> ~(rend co %many ~[[%$ ux+200] [%$ p+40]])
"._0xc8_~~tem__"

> ~(rend co %$ %p 32.819)
"~lasmev"

> ~(rend co %$ %ux 18)
"0x12"

> ~(rend co [%$ p=[p=%if q=0x7f00.0001]])
".127.0.0.1"

> ~(rend co %many ~[[%$ %ud 20] [%$ %uw 133] [%$ %tas 'sam']])
"._20_0w25_sam__"

> ~(rend co %blob [1 1])
"~0ph"

++a-co:co

Render decimal

Render dat as a decimal integer without separators.

Accepts

dat is an atom.

Produces

A tape

Source

++  a-co  |=(dat=@ ((d-co 1) dat))

Examples

> (a-co:co 123.456.789)
"123456789"

++c-co:co

Render base58check

Renders the given atom as a base58check tape.

Accepts

An atom.

Produces

A tape.

Source

++  c-co  (em-co [58 1] |=([? b=@ c=tape] [~(c ne b) c]))

Examples

> (enc:fa 0xdead.beef)
0xdead.beef.938b.8b0c

> (c-co:co 0xdead.beef.938b.8b0c)
"eFGDJSVvRHd"

++d-co:co

Render decimal with min length

Render hol as a decimal integer without separators and with a minimum length of min. If hol has less than min digits, leading zeros will be added to make up the difference.

Accepts

min is an atom.

hol is an atom.

Produces

A tape.

Source

++  d-co  |=(min=@ (em-co [10 min] |=([? b=@ c=tape] [~(d ne b) c])))

Examples

> ((d-co:co 1) 123.456)
"123456"

> ((d-co:co 9) 123.456)
"000123456"

++r-co:co

Render floating point

Render decimal float a as a tape.

Accepts

a is a ++dn.

Produces

A tape.

Source

++  r-co
  |=  a=dn
  ?:  ?=([%i *] a)  (weld ?:(s.a "inf" "-inf") rep)
  ?:  ?=([%n *] a)  (weld "nan" rep)
  =;  rep  ?:(s.a rep ['-' rep])
  =/  f  ((d-co 1) a.a)
  =^  e  e.a
    =/  e=@s  (sun:si (lent f))
    =/  sci  :(sum:si e.a e -1)
    ?:  (syn:si (dif:si e.a --3))  [--1 sci]  :: 12000 -> 12e3 e>+2
    ?:  !(syn:si (dif:si sci -2))  [--1 sci]  :: 0.001 -> 1e-3 e<-2
    [(sum:si sci --1) --0] :: 1.234e2 -> '.'@3 -> 123 .4
  =?  rep  !=(--0 e.a)
    :(weld ?:((syn:si e.a) "e" "e-") ((d-co 1) (abs:si e.a)))
  (weld (ed-co e f) rep)

Examples

> `tape`(r-co:co (rlys .3.14))
"3.14"

> `tape`(r-co:co (rlys .1.681557e-39))
"1.681557e-39"

++s-co:co

Render hex list

Render esc, a list of atoms, as hex with a dot before each value. Values less than two bytes in length will be padded with zeros.

Accepts

esc is a (list @).

Produces

A tape.

Source

++  s-co
  |=  esc=(list @)  ^-  tape
  ?~  esc  rep
  ['.' =>(.(rep $(esc t.esc)) ((x-co 4) i.esc))]

Examples

> `tape`(s-co:co ~[0xdead 0xbeef 0xcafe])
".dead.beef.cafe"

> `tape`(s-co:co ~[0xa 0xb 0xc])
".000a.000b.000c"

> `tape`(s-co:co ~[0xdead.beef])
".deadbeef"

++v-co:co

Render base-32 with minimum length

Render hol as base-32 with a minimum length of min. If hol is shorter than min it will be padded with zeros.

Accepts

min is a @ud.

hol is an atom.

Produces

A tape.

Source

++  v-co  |=(min=@ (em-co [32 min] |=([? b=@ c=tape] [~(v ne b) c])))

Examples

> `tape`((v-co:co 1) 0v2l7.eiug3.0mbd9)
"2l7eiug30mbd9"

> `tape`((v-co:co 20) 0v2l7.eiug3.0mbd9)
"00000002l7eiug30mbd9"

++w-co:co

Render base-64 with minimum length

Render hol as base-64 with a minimum length of min. If hol is horter than min it will be padded with zeros.

Accepts

min is a @ud.

hol is an atom.

Produces

A tape.

Source

++  w-co  |=(min=@ (em-co [64 min] |=([? b=@ c=tape] [~(w ne b) c])))

Examples

> `tape`((w-co:co 1) 0w2.OtBSR.pPVeT)
"2OtBSRpPVeT"

> `tape`((w-co:co 20) 0w2.OtBSR.pPVeT)
"0000000002OtBSRpPVeT"

++x-co:co

Render hex with minimum length

Render hol as hex with a minimum length of min. If hol is horter than min it will be padded with zeros.

Accepts

min is a @ud.

hol is an atom.

Produces

A tape.

Source

++  x-co  |=(min=@ (em-co [16 min] |=([? b=@ c=tape] [~(x ne b) c])))

Examples

> `tape`((x-co:co 1) 0xdead.beef)
"deadbeef"

> `tape`((x-co:co 20) 0xdead.beef)
"000000000000deadbeef"

++y-co:co

Render decimal with at least two digits

Render dat as a decimal with a minimum of two digits. If dat is less than two digits it will be padded with zeros.

Accepts

dat is an atom.

Produces

A tape.

Source

++  y-co  |=(dat=@ ((d-co 2) dat))

Examples

> (y-co:co 0)
"00"

> (y-co:co 1)
"01"

> (y-co:co 123)
"123"

> (y-co:co 123.456)
"123456"

++z-co:co

Render '0x'-prefixed hex

Render dat as hex with a 0x prefix.

Accepts

dat is an atom.

Produces

A tape.

Source

++  z-co  |=(dat=@ `tape`['0' 'x' ((x-co 1) dat)])

Examples

> (z-co:co 123)
"0x7b"

> (z-co:co 0xdead.beef)
"0xdeadbeef"

> (z-co:co 0)
"0x0"

++em-co:co

Render in numeric base

In base bas, format min digits of hol with par. This is used internally by other rendering functions.

  • hol is processed least-significant digit first.

  • All available digits in hol will be processed, but min digits can exceed the number available in hol

  • par handles all accumulated output on each call, and can edit it, prepend or append digits, etc.

  • Until hol is exhausted, par's sample is [| digit output], subsequently, it's [& 0 output].

Accepts

[bas=@ min=@], where bas is the numeric base and min is the minimum length.

par is a gate of $-([? @ tape] tape).

hol is an atom.

Produces

A tape.

Source

++  em-co
  |=  [[bas=@ min=@] par=$-([? @ tape] tape)]
  |=  hol=@
  ^-  tape
  ?:  &(=(0 hol) =(0 min))
    rep
  =/  [dar=@ rad=@]  (dvr hol bas)
  %=  $
    min  ?:(=(0 min) 0 (dec min))
    hol  dar
    rep  (par =(0 dar) rad rep)
  ==

Examples

> ((em-co:co [16 10] |=([? b=@ c=tape] [~(x ne b) c])) 0xbeef)
"000000beef"

++ed-co:co

Format with decimal place

Format int by specifying its size with exp, which may be negative. This is used internally by other rendering functions.

Accepts

exp is a @s.

int is a tape.

Produces

A tape.

Source

++  ed-co
  |=  [exp=@s int=tape]  ^-  tape
  =/  [pos=? dig=@u]  [=(--1 (cmp:si exp --0)) (abs:si exp)]
  ?.  pos
    (into (weld (reap +(dig) '0') int) 1 '.')
  =/  len  (lent int)
  ?:  (lth dig len)  (into int dig '.')
  (weld int (reap (sub dig len) '0'))

Examples

> (ed-co:co --3 "100")
"100"

> (ed-co:co --5 "100")
"10000"

> (ed-co:co -1 "100")
"0.0100"

> (ed-co:co -5 "100")
"0.00000100"

++ox-co:co

Format dot-separated digits in numeric base

In base bas, format each digit of hol with gate dug, with '.' separators every gop digits. This is used internally by other rendering functions.

  • hol is processed least-significant digit first.

  • dug handles individual digits, output is prepended.

  • Every segment but the last is zero-padded to gop.

Accepts

[bas=@ gop=@] where bas is the numeric base and gop is dot separator frequency.

dug is a gate of $-(@ @).

hol is an atom.

Produces

A tape.

Source

++  ox-co
  |=  [[bas=@ gop=@] dug=$-(@ @)]
  %+  em-co
    [(pow bas gop) 0]
  |=  [top=? seg=@ res=tape]
  %+  weld
    ?:(top ~ `tape`['.' ~])
  %.  seg
  %+  em-co(rep res)
    [bas ?:(top 0 gop)]
  |=([? b=@ c=tape] [(dug b) c])

Examples

> ((ox-co:co [2 4] |=(a=@ ~(d ne a))) 0b1011.1101)
"1011.1101"

> ((ox-co:co [2 1] |=(a=@ ~(d ne a))) 0b1011.1101)
"1.0.1.1.1.1.0.1"

> ((ox-co:co [2 100] |=(a=@ ~(d ne a))) 0b1011.1101)
"10111101"

++ro-co:co

Format dot-prefixed bloqs in numeric base

In base bas, for buz bloqs 0 to dop, format at least one digit of hol, prefixed with .. This is used internally for @i address rendering functions.

Accepts

[buz=@ bas=@ dop=@] where buz is the bloq size, bas is the numeric base, and dop is the number of bloqs.

dug is a gate of $-(@ @).

hol is an atom.

Produces

A tape.

Source

++  ro-co
  |=  [[buz=@ bas=@ dop=@] dug=$-(@ @)]
  |=  hol=@
  ^-  tape
  ?:  =(0 dop)
    rep
  :-  '.'
  =/  pod  (dec dop)
  %.  (cut buz [pod 1] hol)
  %+  em-co(rep $(dop pod))
    [bas 1]
  |=([? b=@ c=tape] [(dug b) c])

Examples

> ((ro-co:co [3 10 4] |=(a=@ ~(d ne a))) .127.0.0.1)
".127.0.0.1"

Previous4j: Parsing (Bases and Base Digits)Next4l: Atom Parsing

Last updated 1 day ago