如何使用freemarker删除数组中的重复元素?

mar*_*arg 3 html freemarker netsuite

我已经编写了在 C 中查找重复元素的代码,但现在我坚持在 freemarker 中实现相同的代码有人可以帮忙吗?

int n, a[10], b[10], count = 0, c, d;

   printf("Enter number of elements in array\n");
   scanf("%d",&n);

   printf("Enter %d integers\n", n);
   for(c=0;c<n;c++)
      scanf("%d",&a[c]);

   for(c=0;c<n;c++)
   {
      for(d=0;d<count;d++)
      {
         if(a[c]==b[d])
            break;
      }
      if(d==count)
      {
         b[count] = a[c];
         count++;
      }
   }

   printf("Array obtained after removing duplicate elements\n");         
   for(c=0;c<count;c++)
      printf("%d\n",b[c]);
Run Code Online (Sandbox Code Playgroud)

bkn*_*hts 7

您可以使用自由标记序列。可能效率不高,但我已经用它来对发票等接近最大尺寸的行进行分组。

<#assign seen_style = []>
<#list record.item?sort_by("custcol_stylesort")  as lineitem>
   <#assign groupId = lineitem.item>
   <#if seen_style?seq_contains(groupId)> <!-- no if body is intentional; skips seen style -->
   <#else>
     <#assign seen_style = seen_style + [groupId]>
     <p>Do something with ${groupId}</p>
   </#if>
</#list>
Run Code Online (Sandbox Code Playgroud)