| American Citizen on Fri, 03 Nov 2023 00:28:11 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| asking for a new GP-Pari command |
To all: Recently I had to remove duplicate entries from a vector.Can GP-Pari create a command which will work with both lists and vectors to output duplicate entries?
I am aware that vecsort has flag=8 in vecsort(V,,8) and listsort has flag = 1 in listsort(L,1) to remove duplicates, but I need to find them, not erase them.
Suppose v = [1,2,3,4,5,3,6]Then I would like a GP-Pari command called "duplicates(v)" to produce the following output.
duplicates(v) = [3]
I tried the naive approach of
% u = Set(v);
%usz = matsize(u)[2];
%vsz = matsize(v)[2];
% if ( usz != vsz, {do work to find the duplicate entries in the object} );
This would be a great help since my current approach is quite cumbersome.
Randall