AppleScript - gregorymorrison/euler1 GitHub Wiki

AppleScript, introduced in 1993, is the native scripting environment on the Mac. It's a clear descendant of Hypertalk, and is analogous to VBA on Windows in that it ships with a hosted environment, it can communicate directly with many applications, and can be compiled as a standalone application. I've always been somewhat horrified by the syntax of AppleScript, as it's THE most verbose language I have ever seen. It's designed to be a natural-language coding environment, but the syntax is SO baroque that I can never remember any of it without cracking open the manual each time. It is the logical extreme of friendliness - ridiculously easy to read while ridiculously hard to write. That said, it took me maybe 15 minutes to crank out this version of Euler1:

-- Euler1 in AppleScript

on Euler1(size)
     set retval to 0 as integer
     repeat with i from 1 to size
         if i mod 3 = 0 or i mod 5 = 0 then
             set retval to retval + i
         end if
     end repeat
     return retval
end Euler1

Euler1(999)

Obviously, I wasn't able to run this on Linux, as was my goal for this project. AppleScript ships with its own IDE. Just paste it into the IDE and click the big Run button.