I have a question regarding holes in the lists. Assume that I have the following code:
gap> l:=[2,3,,5];
[ 2, 3,, 5 ]
gap> for i in [1..Size(l)] do
> Print(l[i],"\n");
> od;
2
3
Error, List Element: <list>[3] must have an assigned value in
Print( l[i], "\n" ); at *stdin*:13 called from
<function "unknown">( <arguments> )
called from read-eval loop at *stdin*:14
you can 'return;' after assigning a value
Is there some function to find if the i-th element of a list is hole or not before trying to access it? I am looking for something like this:
gap> for i in [1..Size(l)] do
> if IS_HOLE(l[i])=true then Print("Hole \n); else Print(l[i],"\n"); fi;
> od;
I've read the manual, but still have no clue how to deal with this. Can anybody suggest some solution to this problem, please?
I've checked again the documentation and finally found the answer to my question. Thanks @mike_pierce for the hint. I had to use IsBound function, which returns false for the 'hole' element. Here is the edited code from my example:
gap> l:=[2,3,,5];;
gap> for i in [1..Size(l)] do
> if IsBound(l[i])=false then Print("Hole \n"); else Print(l[i],"\n"); fi;
> od;
2
3
Hole
5