45.9 IsBound

IsBound( rec.name )
IsBound( list[n] )

In the first form IsBound returns true if the record rec has a component with the name name, which must be an ident and false otherwise. rec must evaluate to a record, otherwise an error is signalled.

In the second form IsBound returns true if the list list has a element at the position n, and false otherwise. list must evaluate to a list, otherwise an error is signalled.

    gap> r := rec( a := 1, b := 2 );;
    gap> IsBound( r.a );
    true
    gap> IsBound( r.c );
    false
    gap> l := [  , 2, 3,  , 5,  , 7,  ,  ,   , 11 ];;
    gap> IsBound( l[7] );
    true
    gap> IsBound( l[4] );
    false
    gap> IsBound( l[101] );
    false 

Note that IsBound is special in that it does not evaluate its argument, otherwise it would always signal an error when it is supposed to return false.

Previous Up Top Next
Index

GAP 3.4.4
April 1997