Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distinct, distinct_by built-ins for sequence #113

Open
wants to merge 1 commit into
base: 2.3-gae
Choose a base branch
from

Conversation

clyoudu
Copy link

@clyoudu clyoudu commented Aug 23, 2024

Add distinct, distinct_by built-ins for sequence which sub variable rules same as sort/sort_by.

Why?

  • Data array with simple element type(string, number, boolean, date) often require deduplication,but there is no built-in for sequence deduplication. At present, it can only be achieved through cumbersome way such as the following:
<!-- sort first -->
<#assign checkImportList = checkImport?split("\n")?sort>
<!-- compare with prev item -->
<#list checkImportList as check>
    <#if check != "">
        <#if check?index <= 0 || check != checkImportList[check?index - 1]>
${check}
        </#if>
    </#if>
</#list>

and original order of elements discarded

  • Sometimes data array with hash type require deduplication too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant