# List manipulation to select elements

I have a list of data with the following structure:

data = {{1,1, result1}, ..., {i, j, resultij}, ..., {30,30, result3030}}


Namely the first and second elements range from 1 to 30. I would like to make another data list data2 constructed from data such that the first and second elements range instead from 1 to 10, such that:

data2 = {{1,1, result1}, ..., {i, j, resultij}, ..., {10,10, result1010}}


Any help would be appreciated!

• Do you mean you want to select 100 results out of 900?
– A.G.
Commented Nov 9, 2017 at 13:45
• Select[] seems appropriate here. Commented Nov 9, 2017 at 14:31

This would work:

Last@FoldList[Select, list, {#[[1]] <= 10 &, #[[2]] <= 10 &}]

(* {{1, 1, result[1, 1]}, {1, 2, result[1, 2]}, {1, 3, result[1, 3]}, {1,
4, result[1, 4]}, {1, 5, result[1, 5]}, {1, 6, result[1, 6]}, {1, 7,
result[1, 7]}, {1, 8, result[1, 8]}, {1, 9, result[1, 9]}, {1, 10,
result[1, 10]}, {2, 1, result[2, 1]}, {2, 2, result[2, 2]}, {2, 3,
result[2, 3]}, {2, 4, result[2, 4]}, {2, 5, result[2, 5]}, {2, 6,
result[2, 6]}, {2, 7, result[2, 7]}, {2, 8, result[2, 8]}, {2, 9,
result[2, 9]}, {2, 10, result[2, 10]}, {3, 1, result[3, 1]}, {3, 2,
result[3, 2]}, {3, 3, result[3, 3]}, {3, 4, result[3, 4]}, {3, 5,
result[3, 5]}, {3, 6, result[3, 6]}, {3, 7, result[3, 7]}, {3, 8,
result[3, 8]}, {3, 9, result[3, 9]}, {3, 10, result[3, 10]}, {4, 1,
result[4, 1]}, {4, 2, result[4, 2]}, {4, 3, result[4, 3]}, {4, 4,
result[4, 4]}, {4, 5, result[4, 5]}, {4, 6, result[4, 6]}, {4, 7,
result[4, 7]}, {4, 8, result[4, 8]}, {4, 9, result[4, 9]}, {4, 10,
result[4, 10]}, {5, 1, result[5, 1]}, {5, 2, result[5, 2]}, {5, 3,
result[5, 3]}, {5, 4, result[5, 4]}, {5, 5, result[5, 5]}, {5, 6,
result[5, 6]}, {5, 7, result[5, 7]}, {5, 8, result[5, 8]}, {5, 9,
result[5, 9]}, {5, 10, result[5, 10]}, {6, 1, result[6, 1]}, {6, 2,
result[6, 2]}, {6, 3, result[6, 3]}, {6, 4, result[6, 4]}, {6, 5,
result[6, 5]}, {6, 6, result[6, 6]}, {6, 7, result[6, 7]}, {6, 8,
result[6, 8]}, {6, 9, result[6, 9]}, {6, 10, result[6, 10]}, {7, 1,
result[7, 1]}, {7, 2, result[7, 2]}, {7, 3, result[7, 3]}, {7, 4,
result[7, 4]}, {7, 5, result[7, 5]}, {7, 6, result[7, 6]}, {7, 7,
result[7, 7]}, {7, 8, result[7, 8]}, {7, 9, result[7, 9]}, {7, 10,
result[7, 10]}, {8, 1, result[8, 1]}, {8, 2, result[8, 2]}, {8, 3,
result[8, 3]}, {8, 4, result[8, 4]}, {8, 5, result[8, 5]}, {8, 6,
result[8, 6]}, {8, 7, result[8, 7]}, {8, 8, result[8, 8]}, {8, 9,
result[8, 9]}, {8, 10, result[8, 10]}, {9, 1, result[9, 1]}, {9, 2,
result[9, 2]}, {9, 3, result[9, 3]}, {9, 4, result[9, 4]}, {9, 5,
result[9, 5]}, {9, 6, result[9, 6]}, {9, 7, result[9, 7]}, {9, 8,
result[9, 8]}, {9, 9, result[9, 9]}, {9, 10, result[9, 10]}, {10, 1,
result[10, 1]}, {10, 2, result[10, 2]}, {10, 3, result[10, 3]}, {10, 4,
result[10, 4]}, {10, 5, result[10, 5]}, {10, 6, result[10, 6]}, {10, 7,
result[10, 7]}, {10, 8, result[10, 8]}, {10, 9, result[10, 9]}, {10, 10,
result[10, 10]}} *)