Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi,
I'm trying to create a program that removes duplicate entries from an array (vector) in Mathcad.
I have managed to write a program that converts all the duplicates into "null", but is there a way to get rid of the elements completely and get the "Result" array?
Thank you.
Solved! Go to Solution.
Always better to post the worksheet as well as we don't like retyping things.
change "null" to NaN and use filterNaN(array) at the end of your program (instead of just array).
As an alternative after replacing duplicates with "null" you could use trim(array, match("null",array)) at the end.
Always better to post the worksheet as well as we don't like retyping things.
change "null" to NaN and use filterNaN(array) at the end of your program (instead of just array).
As an alternative after replacing duplicates with "null" you could use trim(array, match("null",array)) at the end.
Quick and easy solution to my problem. Thank you!
Here's another implementation:
Success!
Luc
Clever way, like it!
It inspired me to the following variant:
Its so much smaller in real Mathcad:
Werner
I'm not sure your implementation works for ORIGIN=1.
You have an O+ in the index of R when assigning a new member, together with using last(R); that adds another (empty, or 0=zero) with every addition of a member.
OK.... I'm sure it does NOT work as intended for any value of ORIGIN other than 0.
Luc
Thanks for pointing that out, Luc!
You are perfectly right. As the "last" function already takes care of the ORIGIN, the "O+" part must be omitted (the same applies for the Prime version, of course.
Guess I confused it with this variant where "rows" is used instead of the "last" function:
Hi,
I tried your program but for some reason doesn't work. Please refer to attached.
Regards,
T.
The reason for the error you get is the equal sign ater the function definition.
Furthermore you have grabbed an erroneous version of the function. Its described in Lucs and my posts above. You have to delete the O+ as indicated - otherwise it would only work OK if ORIGIN=0.
Thanks Again!