• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to compare two lists without looping? Possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to compare two lists without looping? Possible?


  • Subject: Re: how to compare two lists without looping? Possible?
  • From: demski <email@hidden>
  • Date: Fri, 10 Feb 2006 09:47:50 +0100

Hey Stan,
interesting approach, indeed!
BTW, what means 'duck typed'?

gruss, demski

Die Anderen · digitale mediendienstleistungen
Bellealliancestraße 58 b  ·  20259 Hamburg

fon: 040 41 26 61 81
fax: 040 41 26 61 83
email@hidden

Deutsche Handelsvertretung der Bogtrykkeri Rosendahls / Esbjerg


Am 10.02.2006 um 03:37 schrieb Stan Cleveland:

On 2/9/06, email@hidden wrote:

You wouldn't have to do a loop if you have two files to compare.
Instead of making two list, try making two text files.  One file with
the numbers you want, the other with the numbers you have (being the
bigger of the two).

On 2/9/06, email@hidden wrote:

The only way I can think of requires a loop, though not complex.


How about recursion combined with offset of a string in a string? (Yes, I
know it's silly, but hey...it works.)


set found to {"192.168.1.11", "192.168.1.66"}
set mustHave to {"192.168.1.11", "192.168.1.66", ¬
    "192.168.1.34", "192.168.1.44"}

-- convert lists to return-delimited text
set oldTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
-- add null string at end to get needed trailing return
set foundTxt to (found & {""}) as text
set needTxt to (mustHave & {""}) as text
set AppleScript's text item delimiters to oldTids
set missing to {}
set {foundTxt, missing} to checkNext(foundTxt, needTxt, missing)
return missing

on checkNext(foundTxt, needTxt, missing)
    set pos to offset of return in needTxt
    if (text 1 thru pos of needTxt) is not in foundTxt then
        set end of missing to (text 1 thru (pos - 1) of needTxt)
    end if
    try
        set needTxt to text (pos + 1) thru -1 of needTxt
    on error number -1728
        return {foundTxt, missing}
    end try
    set {foundTxt, missing} to checkNext(foundTxt, needTxt, missing)
end checkNext


Stan Cleveland Color Technology Inc. Portland, Oregon

"Here the recursion is 'duck typed' as a loop, ala Ruby--sort of."


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
40unter-anderem.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: how to compare two lists without looping? Possible? (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: Font issue in quark
  • Next by Date: How to escape paragraph return and enter to InDesign
  • Previous by thread: Re: how to compare two lists without looping? Possible?
  • Next by thread: Re: how to compare two lists without looping? Possible?
  • Index(es):
    • Date
    • Thread