if I have a list of elements
FV:= [[ 1, 2, 4 ], [ 2, 4 ], [ 3, 1, 2, 4 ], [ 5, 3, 1, 2, 4 ], [ 15, 16, 18 ],
[ 16, 18 ], [ 17, 15, 16, 18 ],[ 19, 17, 15, 16, 18 ], [ 29, 30, 32 ],
[ 30, 32 ], [ 31, 29, 30, 32 ], [ 33, 31, 29, 30, 32 ], [ 43, 44, 46 ],
[ 44, 46 ], [ 45, 43, 44, 46 ], [ 47, 45, 43, 44, 46 ], [ 57, 58, 60 ],
[ 58, 60 ], [ 59, 57, 58, 60 ],[ 61, 59, 57, 58, 60 ], [ 74, 75, 76, 77 ],
[ 75, 76, 77 ], [ 76, 77 ], [ 81, 82, 83, 84 ], [ 82, 83, 84 ],[ 83, 84 ],
[ 88, 89, 90, 91 ], [ 89, 90, 91 ], [ 90, 91 ], [ 95, 96, 97, 98 ],
[ 96, 97, 98 ], [ 97, 98 ],[ 102, 103, 104, 105 ], [ 103, 104, 105 ],
[ 104, 105 ]]
and I want to select only those elements that are of length $2$ in this list, I am trying to use Filtered function like this
gap> Filtered(FV,n->Length(FV[n]=2));
but it doesn't work. How should I use this function operation to find the right answer as I want.
Filtered(FX, u -> Length(u)=2);. I have not GAP at hand to check right now, but it should work. – Jean-Claude Arbaut Aug 22 '14 at 19:09Filtered(FV,n->Length(FV[n]=2))is not going to work because of the misplaced bracket: instead ofLength(FV[n]=2)one should useLength(FV[n])=2. OtherwiseFV[n]=2results intrueorfalseand thenLengthcan not be applied to a boolean, so you will have a "no method found" error. – Olexandr Konovalov Aug 23 '14 at 19:45