21.5 IsBound and Unbind for Lists

  • IsBound( list[n] )

    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> l := [ , 2, 3, , 5, , 7, , , , 11 ];;
    gap> IsBound( l[7] );
    true
    gap> IsBound( l[4] );
    false
    gap> IsBound( l[101] );
    false
    

  • Unbind( list[n] )

    Unbind deletes the element at the position n in the mutable list list. That is, after execution of Unbind, list no longer has an assigned value at the position n. Thus Unbind can be used to produce holes in a list. Note that it is not an error to unbind a nonexisting list element. list must evaluate to a list, otherwise an error is signalled.

    gap> l := [ , 2, 3, 5, , 7, , , , 11 ];;
    gap> Unbind( l[3] ); l;
    [ , 2,, 5,, 7,,,, 11 ]
    gap> Unbind( l[4] ); l;
    [ , 2,,,, 7,,,, 11 ]
    

    Note that IsBound and Unbind are special in that they do not evaluate their argument, otherwise IsBound would always signal an error when it is supposed to return false and there would be no way to tell Unbind which component to remove.

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000