Script Editor crash a couple of times not sure if its my code thought.
But here its… doing some reference with NSArray.
use framework "Foundation"
use scripting additions
(*
https://developer.apple.com/documentation/foundation/nsarray?language=objc
*)
-- Foundation > NSArray
property theList : {"Adam", "Karin", "Eve", "Shane", "Eve", "Karin", "Karin", "Bob"}
property compList : {"Shane", "Bob", "Steve", "Carl"}
-- Creates and returns an array containing the objects in another given array.
set theArray to current application's NSArray's arrayWithArray:theList
---------------
-- Instance Method: containsObject --> BOOL
-- Returns a Boolean value that indicates whether a given object is present in the array.
set theContainsObject to theArray's containsObject:"Shane"
---------------
-- Instance Property: count --> NSUInteger (Describes an unsigned integer.)
-- The number of objects in the array.
set theCount to theArray's |count|()
---------------
-- Instance Property: firstObject --> NSString
-- The first object in the array.
set theFirstItem to theArray's firstObject()
---------------
-- Instance Property: lastObject --> NSString
-- The last object in the array.
set theLastItem to theArray's lastObject()
---------------
-- Instance Method: objectAtIndex --> NSString
-- Returns the object located at the specified index.
set theObjectAtIndex to theArray's objectAtIndex:1 --> Index start at 0
---------------
-- Instance Method: objectAtIndexedSubscript --> NSString
-- Returns the object at the specified index.
set theObjectAtIndexedSubscript to theArray's objectAtIndexedSubscript:2 --> Index start at 0
---------------
-- Initializes an allocated NSIndexSet object.
set theIndexSet to current application's NSIndexSet's alloc()'s init()
-- Returns an array containing the objects in the array at the indexes specified by a given index set.
set theObjectsAtIndexes to theArray's objectsAtIndexes:(theIndexSet's initWithIndexesInRange:{1, 2})
---------------
-- Instance Method: indexOfObject --> NSUInteger
-- Returns the lowest index whose corresponding array value is equal to a given object.
set theIndexOfObject to theArray's indexOfObject:"Karin" --> index start at 0
---------------
-- Instance Method: indexOfObject:inRange: --> NSUInteger
-- Returns the lowest index within a specified range whose corresponding array value is equal to a given object .
set theIndexOfObjectInRange to theArray's indexOfObject:"Karin" inRange:{2, 4}
---------------
-- Instance Method: indexOfObjectIdenticalTo --> NSUInteger
-- Returns the lowest index whose corresponding array value is identical to a given object.
set theIndexOfObjectIdenticalTo to theArray's indexOfObjectIdenticalTo:"Eve" --> index start at 0
---------------
-- Instance Method: firstObjectCommonWithArray --> String
-- Returns the first object contained in the receiving array that’s equal to an object in another given array.
set theArrayComp to current application's NSArray's arrayWithArray:compList
set theFirstObjectCommonWithArray to theArray's firstObjectCommonWithArray:theArrayComp
-- ############
-- The results
-- ############
return {theContainsObject as text, theCount as text, theFirstItem as text, theLastItem as text, theObjectAtIndex as text, theObjectAtIndexedSubscript as text, theObjectsAtIndexes as list, theIndexOfObject as text, theIndexOfObjectInRange as text, theIndexOfObjectIdenticalTo as text, theFirstObjectCommonWithArray as text}