Merge pull request #6039 from tadad/da/apt-in

This commit is contained in:
Zach Alberico 2022-11-10 07:53:23 -08:00 committed by GitHub
commit 31bb93846c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -1247,10 +1247,10 @@
=| [l=(unit) r=(unit)] =| [l=(unit) r=(unit)]
|. ^- ? |. ^- ?
?~ a & ?~ a &
?& ?~(l & (gor n.a u.l)) ?& ?~(l & &((gor n.a u.l) !=(n.a u.l)))
?~(r & (gor u.r n.a)) ?~(r & &((gor u.r n.a) !=(u.r n.a)))
?~(l.a & ?&((mor n.a n.l.a) $(a l.a, l `n.a))) ?~(l.a & ?&((mor n.a n.l.a) !=(n.a n.l.a) $(a l.a, l `n.a)))
?~(r.a & ?&((mor n.a n.r.a) $(a r.a, r `n.a))) ?~(r.a & ?&((mor n.a n.r.a) !=(n.a n.r.a) $(a r.a, r `n.a)))
== ==
:: ::
++ bif :: splits a by b ++ bif :: splits a by b

View File

@ -106,6 +106,10 @@
:: Doesn't follow horizontal & vertical ordering :: Doesn't follow horizontal & vertical ordering
:: ::
=/ unbalanced-e=(set @) [1 [3 ~ ~] [2 ~ ~]] =/ unbalanced-e=(set @) [1 [3 ~ ~] [2 ~ ~]]
:: Duplicate elements
::
=/ has-dupes=(set @) [1 [1 ~ ~] ~]
::
;: weld ;: weld
%+ expect-eq %+ expect-eq
!> [%b-a %.y] !> [%b-a %.y]
@ -125,6 +129,9 @@
%+ expect-eq %+ expect-eq
!> [%u-e %.n] !> [%u-e %.n]
!> [%u-e ~(apt in unbalanced-e)] !> [%u-e ~(apt in unbalanced-e)]
%+ expect-eq
!> [%h-d %.n]
!> [%h-d ~(apt in has-dupes)]
== ==
:: ::
:: Test splits a in b :: Test splits a in b

View File

@ -13,15 +13,21 @@ _in_apt(u3_noun a, u3_weak l, u3_weak r)
u3_noun n_a, l_a, r_a; u3_noun n_a, l_a, r_a;
u3x_trel(a, &n_a, &l_a, &r_a); u3x_trel(a, &n_a, &l_a, &r_a);
if ( (u3_none != l) && (c3n == u3qc_gor(n_a, l)) ) { if ( (u3_none != l) &&
( (c3y == u3r_sing(n_a, l)) || (c3n == u3qc_gor(n_a, l)) )) {
return c3n; return c3n;
} }
if ( (u3_none != r) && (c3n == u3qc_gor(r, n_a)) ) { if ( (u3_none != r) &&
( (c3y == u3r_sing(r, n_a)) || (c3n == u3qc_gor(r, n_a)) )) {
return c3n; return c3n;
} }
if ( u3_nul != l_a ) { if ( u3_nul != l_a ) {
if ( c3y == u3r_sing(n_a, u3h(l_a)) ) {
return c3n;
}
if ( c3n == u3qc_mor(n_a, u3h(l_a)) ) { if ( c3n == u3qc_mor(n_a, u3h(l_a)) ) {
return c3n; return c3n;
} }
@ -32,6 +38,10 @@ _in_apt(u3_noun a, u3_weak l, u3_weak r)
} }
if ( u3_nul != r_a ) { if ( u3_nul != r_a ) {
if ( c3y == u3r_sing(n_a, u3h(r_a)) ) {
return c3n;
}
if ( c3n == u3qc_mor(n_a, u3h(r_a)) ) { if ( c3n == u3qc_mor(n_a, u3h(r_a)) ) {
return c3n; return c3n;
} }