How to remove duplicate elements in a array using freemarker?

自闭症网瘾萝莉.ら 提交于 2020-05-29 08:06:43

问题


I had written the code for finding duplicate elements in C but now I am stuck at implementing the same code in freemarker Can anyone help?

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]);

回答1:


You can use freemarker sequences. Probably not super efficient but I've used this to group close to max size lines on invoices and such.

<#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>


来源:https://stackoverflow.com/questions/51738960/how-to-remove-duplicate-elements-in-a-array-using-freemarker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!