add +slam:wa and tests

This commit is contained in:
Ted Blackman 2019-08-01 11:21:24 -07:00
parent 82bf90df3f
commit 1c3ea0b188
3 changed files with 43 additions and 2 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a4a8e1daf0bfe86d5fc4ef7060b0c6a6c2678a344787926f14bb4b8cfabe8752
size 9549390
oid sha256:54dae6825ebdcd680241ebcee83fbd4263c8f3dd71adf0009700e79d99c3be2c
size 9627570

View File

@ -17290,6 +17290,14 @@
=+ new=(~(mint ut sut) %noun gen)
[new +>+<.$(mit (~(put by mit) [sut gen] new))]
::
++ slam :: ++slam, cached
|= [gat=vase sam=vase]
^- [vase worm]
=/ sut=type [%cell p.gat p.sam]
=/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=^ new=type +>+<.$ (play sut gen)
[[new (slum q.gat q.sam)] +>+<.$]
::
++ slap :: ++slap, cached
|= {vax/vase gen/hoon}
^- {vase worm}

View File

@ -0,0 +1,33 @@
/+ *test
|%
++ test-slam-wa ^- tang
::
;: weld
%+ expect-eq
!>(7)
-:(~(slam wa *worm) !>(add) !>([3 4]))
::
%+ expect-eq
!>(~[3 2 1])
-:(~(slam wa *worm) !>(flop) !>(~[1 2 3]))
::
=| =worm
=^ res1 worm (~(slam wa worm) !>(flop) !>(`(list @)`~[1 2 3]))
=/ worm1 worm
=^ res2 worm (~(slam wa worm) !>(flop) !>(`(list @)`~[4 5 6]))
::
;; weld
%+ expect-eq
res1
!>(`(list @)`~[3 2 1])
::
%+ expect-eq
res2
!>(`(list @)`~[6 5 4])
::
%+ expect-eq
worm
worm1
==
==
--