1 Reply Latest reply on Nov 30, 2010 3:09 PM by philmodjunk

    Recursive function help

    BobSchwenkler

      Title

      Recursive function help

      Post

      Hi,

      I haven't gotten into recursive functions really at all, which seems like would be the best solution for the issue at hand, so I thought I'd ask here and probably end up with less hair pulling and a cleaner function.

      I've used List() to draw vendor IDs from all of our distributed items. I end up with a list of ID numbers, carriage return separated, some of which are duplicates. I simply want to sort through this list and eliminate duplicates. What's a good way to do this?

      Thanks!

        • 1. Re: Recursive function help
          philmodjunk

          You could actually do this with the value List Items function rather than a recursive function.

          As a recursive function:

          //UniqueItems ( ValueList1 ; ValueList2 )

          // ValueList1 unfiltered value list
          // ValueList2 Filtered value list

          Let ( Item = GetValue ( ValueList1 ; 1 ) ;

                    Case ( IsEmpty ( ValueList1 ) ; ValueList2 ;
                             UniqueItems ( RightValues ( ValueList1 ; ValueCount ( ValueList1 ) - 1 ) ;
                                                    If ( IsEmpty ( FilterValues ( ValueList2 ; Item ) ) ; List ( Item ; ValueList2 ) ; ValueList2 )
                                                  ) // Unique values
                             ) // case
                 ) // Let

          Your initial call to this function use your list as the first parameter and an empty string as the second parameter.