filter?

Pete pete at mollysrevenge.com
Wed Jun 22 21:30:34 EDT 2011


I have a feeling this is probably going to get a lot of responses related to
the most efficient way to do this!  I have no idea how efficient this would
be but I'll start the ball rolling with this code.

repeat with x=1 to the number of lines in tlist1
  if line x of tlist1 is not among the lines of tlist 2 then
    < you found a unique tlist1 value >
  end if
end repeat
repeat with x=1 to the number of lines in tlist2
  if line x of tlist2 is not among the lines of tlist1 then
    < you found a unique tlist2 value >
  end if
end repeat

Another thought I had involves using an array as follows:

repeat with x=1 to the number of lines in tlist1
  add 1 to array[line x of tlist1]
end repeat
repeat with x=1 to the number of lines in tlist2
  add 1 to array[line x of tlist2]
end repeat
repeat for each key myKey in array
  if array[myKey]=1 then
    < you found a unique value >
  end if
end repeat

Depending on how many entries you expect in each list and how long each
entry is, the array solution could chew up a huge amount of memory.

These are both pretty simplistic solutions which probably means they
wouldn't be the fastest.  I have no idea how fast either of them might be
and I know there are definitely some efficiencies to be had by using either
repeat with vs repeat for but I can't remember which is the faster.


Pete
Molly's Revenge <http://www.mollysrevenge.com>




On Wed, Jun 22, 2011 at 5:38 PM, Nicolas Cueto <niconiko at gmail.com> wrote:

> Hi again.
>
> Given 2 lists of cr-delimited values (tList1, tList2), what's the fastest
> way of getting the unique value(s)?
>
> Ex, "1,2,3,4" & "1,2,3,4,5" = "5"
> (but cr instead of comma)
>
> Thanks.
>
> --
> Nicolas Cueto (iPhone)
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>



More information about the Use-livecode mailing list