glsl vertex comparison

Is it possible to compare one vertex to another, within the fragment shader of a glsl Mat?
I understand this is not possible within the vertex shader, but the vertex buffer struct that is passed into the fragment shader is an array (of some sort).
This does not throw an error
int vListlength = vVert.worldSpace.length;

but this does not work
for (float i = 1.0; i < vVert.worldSpace.length; i++){
v = vVert.worldSpace[i];} // throws error saying implicit conversion from vec4 to int

Ultimately, I want to be able to loop through the verts, compare them to neighboring verts, and discard (this works in the frag shader) them based on distance conditions.
I’m assuming that the vVert is a buffer, not an array, and can’t be iterated through.
Is that correct? Is there a way to do this inside the shader?
Will probably do it with chops if I can’t make this work, which will be slower for sure.
Thomas

You can do this in a geometry shader. You’ll have access to all the verts from your triangle, and you can choose to emit or not emit a primitive based on your conditions.

Thanks Malcolm!
That definitely does work, meaning that you can loop through the points as an array.
However I still could not successfully compare one point to another, although comparisons of points to a fixed position works. I think this is because the outgoing Vertex struct is a buffer, not an array. As in
vVerts.worldSpace = vVert[i].worldSpace;

this line seems curious because vVerts is not an array (as opposed to vVert), so it must be a vertex buffer.
Anyway, could not successfully cull points based on the [i] iterator, but could by comparing distance. That seems to indicate that the loop does not affect the output struct.

In any case, I solved my problem in a different way, by converting the vertex buffer to a point color cloud image (xyz to rgb), and sampled that with texture() to compare the points in space. It worked well enough.

below is my Geo Code.

layout(points) in;
layout(points, max_vertices = 1) out;

uniform float uDistThresh;
uniform vec3 uSpherePos;

in Vertex {
vec4 color;
vec4 worldSpace;
vec4 camSpace;
}vVert[];

out Vertex{
vec4 color;
vec4 worldSpace;
vec4 camSpace;
}vVerts;

void main() {
int numParts = gl_in.length(),j, k;
for(int i = numParts-1; i >= 0 ; i–)
{
j = max(0, i-1);
if ( length( gl_in[i].gl_Position.xyz - gl_in[j].gl_Position.xyz) < uDistThresh) //
{
vVerts.color = vVert[i].color;
vVerts.worldSpace = vVert[i].worldSpace;
vVerts.camSpace = vVert[i].camSpace;
gl_Position = gl_in[i].gl_Position;
EmitVertex();
EndPrimitive();
}
}
}

The vVerts isn’t a vertex buffer. It’s an output variable that you fill with values, and when EmitVertex() is called any values in that variable is used to create a vertex.