Created
October 8, 2018 10:24
-
-
Save kern-me/aa46d23c1905e58ffe9c9b2dee25a4e7 to your computer and use it in GitHub Desktop.
Applescript : Find the Largest Number in a List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on highest_number(values_list) | |
set the high_amount to "" | |
repeat with i from 1 to the count of the values_list | |
set this_item to item i of the values_list | |
set the item_class to the class of this_item | |
if the item_class is in {integer, real} then | |
if the high_amount is "" then | |
set the high_amount to this_item | |
else if this_item is greater than the high_amount then | |
set the high_amount to item i of the values_list | |
end if | |
else if the item_class is list then | |
set the high_value to highest_number(this_item) | |
if the the high_value is greater than the high_amount then | |
set the high_amount to the high_value | |
end if | |
end if | |
end repeat | |
return the high_amount | |
end highest_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment