Will be helpful to have a build-in fuction to remove duplicates from a list
Example
List {A, B, C, A, B }
Result list {C}
Hi Emnanuel,
For a function that you want to remove duplicates, I would expect the following to happen:
Remove duplicates from List {A, B, C, A, B }
Result list {A, B, C}
The behavior I describe is already available as ListDistinct client and server side:https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/System_Actions#ListDistinct
Regards,
Daniel
Hello!..I understand what Emmanuel is looking for is to list those elements that aren't duplicated.
Some sort of list unique elements.
I think there isn't any built function for that, as far as i know.Regards.
Hi Moises,
Might be, but you are assuming what you write, maybe you are right maybe not.
The example doesn't match with the title.
Either one can be wrong, that is why I asked the question. Emmanuel should clarify this.
Hello Daniel.
I have been using the function you mentioned and found it useful on certain occasions. Only in this idea it is a bit different as the result is not the same.
I don't know if the idea is well expressed but in this one the duplicates are removed leaving only the unique elements.
Regards
I agree with Emmanuel, this is a kind of pattern frequently used that can be achieved more easily with the proposed idea.
You guys are making me curious,
what needs to be removed is everything that occurs more than 1 time, right ? Even if there are for example 3 'A' values, 'A' gets removed ?
When would this type of function be needed, what real life problems do we solve with this ? There is clearly a need as there are already 12 upvotes, but I can't really imagine.
@Dorine Boudry exactly my thoughts, I never needed this during the years I was a developer.
In my life as a developer I have had to use this logic several times, using aggregate and SQL can be solved in a more elegant way. But when you are integrating solutions in REST/API only using lists.
The last situation was the following
We had to join two lists and we had to remove the ones that are repeated as the case I mentioned in the first comment.
Mathematically we can say that this is the operation
Ok,
thanks for clarifying.
So, i understand the mathematical / theoretical question, but from a functional point of view, can you give examples when we would typically be interested in the delta of 2 lists. I have never come across it in 24 years.
It feels to me like something that is only needed in very specific occasions, so I wouldn't see the point of adding it to a general set of list operations.
Out of curiosity, have you come across it in an Outsystems project, and if so, how did you do it, just traversing both lists ?
Dorine
Yes, the problem was encountered during an Outsystems project.
The specific scenario is that we had similar sets and subsets of data being compared, and we needed to get only those that are not repeated in set and subset.
To solve the problem I had to iterate the lists. But since we know that an iteration should be avoided if possible I came up with the idea.
Similarly, the ListDistinct function can be performed by iterating instead, I thought we could have a similar function for this scenario as well.
Hi,
So what you are looking for is an implementation of a XOR opperation (Exclusive OR) applied to lists. This is the kind of use cases that fall under the extensability capabilities of OutSystems because it's not trivial and unless you really needed, there's no point in having it there. Most databases support that opperation and you can implement it in your OS stack if you need to apply to lists. And once it's implemented, put it in the forge and reuse it whenever needed. And there is several implementations out there if you need some clues how to do it.
Cheers