Merge pull request #824 from urbit/vat-q

Add @q, phonetic data representation
This commit is contained in:
Fang 2018-11-13 11:07:25 -08:00 committed by GitHub
commit 113f82b6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 0 deletions

View File

@ -5299,6 +5299,7 @@
++ dem (bass 10 (most gon dit)) :: decimal to atom ++ dem (bass 10 (most gon dit)) :: decimal to atom
++ dit (cook |=(a/@ (sub a '0')) (shim '0' '9')) :: decimal digit ++ dit (cook |=(a/@ (sub a '0')) (shim '0' '9')) :: decimal digit
++ dog ;~(plug dot gay) :: . number separator ++ dog ;~(plug dot gay) :: . number separator
++ dof ;~(plug hep gay) :: - @q separator
++ doh ;~(plug ;~(plug hep hep) gay) :: -- phon separator ++ doh ;~(plug ;~(plug hep hep) gay) :: -- phon separator
++ dun (cold ~ ;~(plug hep hep)) :: -- (stop) to ~ ++ dun (cold ~ ;~(plug hep hep)) :: -- (stop) to ~
++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~ ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
@ -5486,6 +5487,11 @@
haf:ab :: star haf:ab :: star
tiq:ab :: galaxy tiq:ab :: galaxy
== ==
++ feq %+ cook |=(a=(list @) (rep 4 (flop a)))
;~ plug
;~(pose hif:ab tiq:ab)
(star ;~(pfix dof hif:ab))
==
++ fim (sear den:fa (bass 58 (plus fem:ab))) ++ fim (sear den:fa (bass 58 (plus fem:ab)))
++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab))))) ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab)))))
++ lip =+ tod=(ape ted:ab) ++ lip =+ tod=(ape ted:ab)
@ -5604,6 +5610,20 @@
rep rep
== ==
== ==
::
$q
=* val q.p.lot
:+ '.' '~'
=- =.(rep (weld - rep) rep)
%- tail
%+ roll ?:(=(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) ?+ hay (z-co q.p.lot)
@ -5902,6 +5922,7 @@
(stag %if lip:ag) (stag %if lip:ag)
royl royl
(stag %f ;~(pose (cold & (just 'y')) (cold | (just 'n')))) (stag %f ;~(pose (cold & (just 'y')) (cold | (just 'n'))))
(stag %q ;~(pfix sig feq:ag))
== ==
-- --
:: ::

42
tests/sys/hoon/auras.hoon Normal file
View File

@ -0,0 +1,42 @@
/+ *test
|%
++ test-parse-q
;: weld
%+ expect-eq
!> .~zod
!> `@q`0x0
::
%+ expect-eq
!> .~marbud
!> `@q`0x102
::
%+ expect-eq
!> .~nec-marbud
!> `@q`0x1.0102
::
%+ expect-eq
!> .~marnec-marnec-marnec-marnec-marbud
!> `@q`0x101.0101.0101.0101.0102
::
==
::
++ test-render-q
;: weld
%+ expect-eq
!> '.~zod'
!> (scot %q 0x0)
::
%+ expect-eq
!> '.~marbud'
!> (scot %q 0x102)
::
%+ expect-eq
!> '.~nec-marbud'
!> (scot %q 0x1.0102)
::
%+ expect-eq
!> '.~marnec-marnec-marnec-marnec-marbud'
!> (scot %q 0x101.0101.0101.0101.0102)
::
==
--