Discovered this lib on github while searching for some facsimile of higher-order-functions for AS.
https://github.com/hhas/applescript-stdlib
The ‘List’ lib has map/reduce/filter which is a mainstay of my Kotlin coding when dealing with collections.
If I run ‘List.unittest.scpt’ I get the error:
Can't get script "List"
List is referenced by:
use script "List" -- the script being tested
I copied all libraries into ~/Library/Script Libraries/
If I change the use script call to
use List : script "List"
I get an Apple system error telling me the code is from an unknown developer and can’t be used.
If anyone has this working, please let me know how you did it.
Alternatively, if there’s another lib that has map/reduce/filter list funcs, please post it here.
TIA
I’ve had this installed for some time and it works for me.
What OS version are you on?
→ Mac OS: 14.6.1 (23G93)
→ Script Debugger 8.0.8 (8A80)
→ SD Notary 2 2.0 (102)
→ FastScripts 3.2.7 (1767)
Downloaded files are usually given a quarantine attribute (com.apple.quarantine
), which is why Gatekeeper is giving you “unknown developer” for the unsigned libraries. Saving copies from SD or using the xattr
command can clear the attribute. For example, the following will clear all extended attributes of the unzipped folder and its contents (see the xattr
man page for more information):
xattr -cr /Users/you/path/to/applescript-stdlib-master
1 Like
Stdlib has taught me a lot.
First of all, I read the source code, and the library itself is written using reserved words described in the library’s own SDEF, and it continues to put a huge load on editing programs such as Script Editor and Script Debugger that I have never seen before. It is very heavy. What kind of machine did he use to write this?
In addition, there is a large number of descriptive techniques that have never been seen before, which are very difficult to decipher. This writing technique puts a heavy burden on the AppleScript processing system, and even if you try to write some Script using the AppleScript Libraries, it will not work properly. It crashes. Because of this, it does not feel practical at all.
As a result, I was able to gain the know-how of a bad examples, on the other hand, that I do not use my own reserved words when describing the internal processing of the AppleScript Libraries, but only use it in places where I interact with the outside. I wouldn’t have noticed it if it wasn’t for his mistakes.
In addition, the larger the AppleScript, the more it is required to write in a way that does not put a burden on the processing system, so we realized that it is important to keep it as simple as possible and not to cram too many elements into one line.
After running the xattr command I was able to succesfully run the ‘List.unittest’ script.
I then created my own test script for the List map func, which I extracted from the List.Unittest script of applescript-stdlib-master. I added the HalveNumber func.
use script "TestTools"
use script "List" -- the script being tested
--
to test_mapList()
script DoubleNumber
to mapItem(aValue)
return aValue * 2
end mapItem
end script
script HalveNumber
to mapItem(aValue)
return aValue / 2
end mapItem
end script
set x to (map list {1, 2, 3} using DoubleNumber)
set y to (map list {1, 2, 3} using HalveNumber)
log x
log y
end test_mapList
on run
test_mapList()
end run
results
(*2, 4, 6*)
(*0.5, 1.0, 1.5*)
It works
Thanks