An AppleScript program: set {count1, count2, count3, count4} to {0, 0, 0, 0} set A to {"a", "b", "c", "a"} (* Test various ways of counting the number of occurrences of "a" in the list A *) (* Supposedly "the contents of" is needed to extract the actual value of "item i of A", but apparently not so here *) repeat with i from 1 to the length of A if (item i of A) = "a" then set count1 to count1 + 1 if (the contents of item i of A) = "a" then set count2 to count2 + 1 end repeat (* Supposedly "repeat with x in A" sets x to "item 1 of A", "item 2 of A" ... but the behaviour is different; here "the contents of" is obligatory to match the "a" *) repeat with x in A if x = "a" then set count3 to count3 + 1 if (the contents of x) = "a" then set count4 to count4 + 1 end repeat get {count1, count2, count3, count4} Result: {2, 2, 0, 2}
https://media.mathstodon.xyz/media_attachments/files/111/595/810/973/669/378/original/f82e328b0b255f72.png