I've made program where a certain set of numbers is stored to a list. In the list, there are numbers that are repeated 2,3 or even 4 times. How can I eliminate these duplicates so that I only have one of each number in my list?
You could try a For( loop
For(A,2,dim(∟X For(B,1,A-1 If ∟X(B)=∟X(A Then 0→LX(A B-1→B End End End
I think that will work. Other than that, as far as I know, there is no command to do that.
You could do what Mr Dino said, or something like
SortA(L1 L1(1→L2(1 1→I For(A,2,dim(L1 If L1(A)≠L2(I Then I+1→I L1(A→L2(I End End
Not sure if that'll work, but what it does is it copies all unique values to L2 (eliminating duplicates), or at least it should.
Projects: BexIDE (hold), Hadean.NET, Legend of Zelda: Link to the Future
This is probably slower, but it is smaller in case you need to save on memory XD (larger than Mr. Dino's, but his assumes 0 isn't in the list):
0L₁→L₂ For(A,1,dim(L1 L2+(1=cumSum(cumSum(L₁=L₁(A→L₂ End SortD(L₂,L₁ sum(L₂>0→dim(L₁
I will try to find a better method, and yes, there are two cumSum( commands in a row :)
47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2
I got one also:
dim(L1)-sum(0 xor imag(L1→dim(L1
I think it is a tad larger than Xeda's, but it doesn't use For( and uses no additional lists. It also uses xor :)
Edit: I should note that this may be skimpy on very large numbers. Anything over E25 will probably fail. You could try and change 25 to a larger number in the program, but it somehow produces overflow errors at a certain point that I didn't bother checking for.