Skip to content

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