-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
112 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## | ||
## Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany | ||
## (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland | ||
## Copyright (C) 2002 The GAP Group | ||
## | ||
## This software is licensed under the GPL 2 or later, please refer | ||
## to the COPYRIGHT.md and LICENSE files for details. | ||
## | ||
|
||
############################################################################# | ||
## | ||
#V IdOfFilter | ||
## | ||
## <#GAPDoc Label="IdOfFilter"> | ||
## <ManSection> | ||
## <Func Name="IdOfFilter" Arg="filter"/> | ||
## <Func Name="IdOfFilterByName" Arg="name"/> | ||
## | ||
## <Description> | ||
## finds the id of the filter <A>filter</A>, or the id of the filter | ||
## with name <A>name</A> respectively. | ||
## The id of a filter is equal to the | ||
## position of this filter in the global FILTERS list. | ||
## <P/> | ||
## Note that not every <C>filter</C> for which <C>IsFilter(filter)</C> | ||
## returns <C>true</C> has an ID, only elementary filters do. | ||
## </Description> | ||
## </ManSection> | ||
## <#/GAPDoc> | ||
## | ||
## Note that the filter ID is stored in FLAG1_FILTER for most filters, | ||
## testers have the ID stored in FLAG2_FILTER, so the code below is | ||
## more efficient than just iterating over the FILTERS list. | ||
## | ||
## | ||
BIND_GLOBAL( "IdOfFilter", | ||
function(filter) | ||
local fid; | ||
atomic readonly FILTER_REGION do | ||
fid := FLAG1_FILTER(filter); | ||
if fid > 0 and FILTERS[fid] = filter then | ||
return fid; | ||
fi; | ||
fid := FLAG2_FILTER(filter); | ||
if fid > 0 and FILTERS[fid] = filter then | ||
return fid; | ||
fi; | ||
od; | ||
return fail; | ||
end); | ||
|
||
BIND_GLOBAL( "IdOfFilterByName", | ||
name -> PositionProperty(FILTERS, f -> NAME_FUNC(f) = name) ); | ||
|
||
############################################################################# | ||
## | ||
#V FilterByName | ||
## | ||
## <#GAPDoc Label="FilterByName"> | ||
## <ManSection> | ||
## <Func Name="FilterByName" Arg="name"/> | ||
## | ||
## <Description> | ||
## finds the filter with name <A>name</A> in the global FILTERS list. This | ||
## is useful to find filters that were created but not bound to a global | ||
## variable. | ||
## </Description> | ||
## </ManSection> | ||
## <#/GAPDoc> | ||
## | ||
BIND_GLOBAL( "FilterByName", | ||
name -> First(FILTERS, f -> NAME_FUNC(f) = name) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
gap> test := x -> List([IsFilter, IsCategory, IsRepresentation, IsAttribute, IsProperty, IsOperation], f -> f(x));; | ||
gap> test(IsFinite); | ||
[ true, false, false, false, true, true ] | ||
|
||
# | ||
gap> test(IsMagma); | ||
[ true, true, false, false, false, true ] | ||
|
||
# | ||
gap> test(IsCommutative); | ||
[ true, false, false, false, true, true ] | ||
|
||
# | ||
gap> test(Size); | ||
[ false, false, false, true, false, true ] | ||
|
||
# | ||
gap> test(Group); | ||
[ false, false, false, false, false, false ] | ||
|
||
# | ||
gap> test((1,2,3)); | ||
[ false, false, false, false, false, false ] | ||
|
||
# | ||
gap> test("hello, world"); | ||
[ false, false, false, false, false, false ] | ||
|
||
# | ||
gap> FilterByName("IsCommutative"); | ||
<Property "IsCommutative"> | ||
gap> CategoryByName("IsMagma"); | ||
<Category "IsMagma"> | ||
|
||
# | ||
gap> f := function() atomic readonly FILTER_REGION do return ForAll([1..Length(FILTERS)], id -> id = IdOfFilter(FILTERS[id])); od; end;; | ||
gap> f(); | ||
true |