• 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 do I make words list from two lists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I make words list from two lists?


  • Subject: Re: How do I make words list from two lists?
  • From: Nigel Garvey via AppleScript-Users <email@hidden>
  • Date: Sun, 22 Sep 2019 22:35:07 +0100

Shane Stanley wrote on Sun, 22 Sep 2019 23:53:26 +1000:

>set alist to {"T", "h", "e", "q", "u", "i", "c", "k", "b", "r", "o",
"w", "n", "f", "o", "x"}
>set bList to {1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4}
>
>set string_list to {}
>set lastStart to 1
>repeat with n from 2 to count bList
>       if item n of bList > item (n - 1) of bList then
>               set end of string_list to (items lastStart thru (n - 1) of
> alist) as
text
>               set lastStart to n
>       end if
>end repeat
>set end of string_list to (items lastStart thru -1 of alist) as text
>
>return string_list

Of course, one should make sure the TIDs are to "" during the coercions.
 ;)

Alternatively, the letter list could be coerced to text and the
substrings extracted directly from it:

  set alist to {"T", "h", "e", "q", "u", "i", "c", "k", "b", "r", "o", "w",
"n", "f", "o", "x"}
  set bList to {1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4}

  set astid to AppleScript's text item delimiters
  set AppleScript's text item delimiters to ""
  set aText to alist as text
  set AppleScript's text item delimiters to astid

  set string_list to {}
  set lastStart to 1
  repeat with n from 2 to count bList
    if item n of bList > item (n - 1) of bList then
      set end of string_list to (text lastStart thru (n - 1) of aText)
      set lastStart to n
    end if
  end repeat
  set end of string_list to (text lastStart thru -1 of aText)

  return string_list


NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: How do I make words list from two lists?
      • From: Shane Stanley via AppleScript-Users <email@hidden>
  • Prev by Date: Re: How do I make words list from two lists?
  • Next by Date: Re: How do I make words list from two lists?
  • Previous by thread: Re: How do I make words list from two lists?
  • Next by thread: Re: How do I make words list from two lists?
  • Index(es):
    • Date
    • Thread