Try this: 
     
      ? z = vecsort(matreduce([v[3] | v <- S])~, 2, 4)[1, 1]; z 
      %21 = -1 
      ? PP = [v | v <- S, v[3] == z]; PP 
      %22 = [[1, 0, -1]~, [4, -1, -1]~, [7, -3, -1]~, [3, -1, -1]~, [8,
      -3, -1]~, [2, -1, -1]~, [9, -3, -1]~, [7, -2, -1]~, [4, -2, -1]~,
      [6, -2, -1]~, [5, -2, -1]~] 
     
    
    On
      2024-02-09 17:35, Gareth Ma wrote:
       
      Note your code depends on max(L) - min(L),
        which is probably not what
         
        you want?
         
         
       
      I think so, since I don't know whih z-coordinate contains maximal
      count of vectors.
       
       
      You can replace your C with matreduce(L).
         
         
       
      This is example input:
       
       
      S=[[12, -4, -3]~, [1, 0, -1]~, [6, -2, -2]~, [11, -4, -3]~, [0, 0,
      1]~, [15, -5, -3]~, [4, -1, -1]~, [9, -3, -2]~, [14, -5, -3]~, [7,
      -3, -1]~, [2, -1, 0]~, [3, -1, -1]~, [8, -3, -2]~, [13, -5, -3]~,
      [8, -3, -1]~, [3, -1, 0]~, [2, -1, -1]~, [9, -3, -1]~, [7, -2,
      -1]~, [12, -4, -2]~, [17, -6, -3]~, [4, -2, -1]~, [1, 0, 0]~, [6,
      -2, -1]~, [11, -4, -2]~, [16, -6, -3]~, [10, -4, -2]~, [5, -2,
      -1]~]
       
       
      What I want is this (PP=[v|v<-S,v[3]==mx];):
       
       
      PP=[[1, 0, -1]~, [4, -1, -1]~, [7, -3, -1]~, [3, -1, -1]~, [8, -3,
      -1]~, [2, -1, -1]~, [9, -3, -1]~, [7, -2, -1]~, [4, -2, -1]~, [6,
      -2, -1]~, [5, -2, -1]~]
       
       
      How can "matreduce(S)" help?
       
       
      matreduce(S)=[[0, 0, 1]~, 1; [1, 0, -1]~, 1; [1, 0, 0]~, 1; [2,
      -1, -1]~, 1; [2, -1, 0]~, 1; [3, -1, -1]~, 1; [3, -1, 0]~, 1; [4,
      -2, -1]~, 1; [4, -1, -1]~, 1; [5, -2, -1]~, 1; [6, -2, -2]~, 1;
      [6, -2, -1]~, 1; [7, -3, -1]~, 1; [7, -2, -1]~, 1; [8, -3, -2]~,
      1; [8, -3, -1]~, 1; [9, -3, -2]~, 1; [9, -3, -1]~, 1; [10, -4,
      -2]~, 1; [11, -4, -3]~, 1; [11, -4, -2]~, 1; [12, -4, -3]~, 1;
      [12, -4, -2]~, 1; [13, -5, -3]~, 1; [14, -5, -3]~, 1; [15, -5,
      -3]~, 1; [16, -6, -3]~, 1; [17, -6, -3]~, 1]
       
       
       
      Regards,
       
       
      Hermann.
       
       
     
     
  
  
 |