From 2b475a8695f1a36b14d16e38fbe38a5bbfc7050c Mon Sep 17 00:00:00 2001 From: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com> Date: Sat, 31 Aug 2024 12:31:48 +0100 Subject: [PATCH] Add new function `MeetBlist` (#5778) --- doc/ref/blist.xml | 1 + lib/list.g | 29 +++++++++++++++++++++++++++++ tst/testinstall/kernel/blister.tst | 10 +++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/ref/blist.xml b/doc/ref/blist.xml index 79f780b687..f0e0210455 100644 --- a/doc/ref/blist.xml +++ b/doc/ref/blist.xml @@ -56,6 +56,7 @@ In function names we call boolean lists blists for brevity. <#Include Label="UniteBlistList"> <#Include Label="IntersectBlist"> <#Include Label="SubtractBlist"> +<#Include Label="MeetBlist"> <#Include Label="FlipBlist"> <#Include Label="SetAllBlist"> <#Include Label="ClearAllBlist"> diff --git a/lib/list.g b/lib/list.g index 33866ac617..e132b2ac6f 100644 --- a/lib/list.g +++ b/lib/list.g @@ -881,6 +881,35 @@ DeclareSynonym( "IntersectBlist", INTER_BLIST ); ## DeclareSynonym( "SubtractBlist", SUBTR_BLIST ); +############################################################################# +## +#F MeetBlist( , ) +## +## <#GAPDoc Label="MeetBlist"> +## +## +## +## +## Returns true if there is a position at which both blist1 +## and blist2 contain true, and false otherwise. +## It is equivalent to, but faster than +## SizeBlist(IntersectionBlist(blist1, blist2)) <> 0. +## An error is thrown if the lists do not have the same length. +## blist1 := [ true, true, true, true ];; +## gap> blist2 := [ true, false, true, false ];; +## gap> MeetBlist( blist1, blist2 ); +## true +## gap> FlipBlist( blist1 ); +## gap> MeetBlist( blist1, blist2 ); +## false +## ]]> +## +## +## <#/GAPDoc> +## +DeclareSynonym( "MeetBlist", MEET_BLIST ); + ############################################################################# ## #F FlipBlist( ) diff --git a/tst/testinstall/kernel/blister.tst b/tst/testinstall/kernel/blister.tst index 8d9a978cc8..6c3c17d308 100644 --- a/tst/testinstall/kernel/blister.tst +++ b/tst/testinstall/kernel/blister.tst @@ -304,17 +304,17 @@ gap> x; [ false, false, true, false ] # FuncMEET_BLIST -gap> MEET_BLIST(fail, fail); +gap> MeetBlist(fail, fail); Error, MEET_BLIST: must be a boolean list (not the value 'fail') -gap> MEET_BLIST([true,false], fail); +gap> MeetBlist([true,false], fail); Error, MEET_BLIST: must be a boolean list (not the value 'fail') -gap> MEET_BLIST([true,false,true], [true,false]); +gap> MeetBlist([true,false,true], [true,false]); Error, MEET_BLIST: must have the same length as (lengths are\ 3 and 2) gap> x:= [false,true,true,false];; -gap> MEET_BLIST(x, [true,true,false,false]); +gap> MeetBlist(x, [true,true,false,false]); true -gap> MEET_BLIST(x, [true,false,false,false]); +gap> MeetBlist(x, [true,false,false,false]); false # FuncFLIP_BLIST