set theListOfRecords to {{name:“foo”}, {name:“bar”}}
I can extract the same property from each record in the list:
set theNames to {}
repeat with theItem in theListOfRecords
set theNames to theNames & the name of theItem
end repeat
theNames
which seems like an awful lot of code for such a simple operation. It would be great if there were a one line equivalent of this, perhaps something like:
get the name of every item of theListOfRecords
but this doesn’t work. I would like to be able to perform the same operation on every item in a list and end up with a list of the results. Is there a concise way to do this sort of functional programming in AppleScript?
Dealing with records isn’t as elegant as we would like. You can’t just say “name of every item of [some record]”. Using conditionals, handlers, exit repeat, etc. while walking the record is the only way to really process it.
That’s not functional programming, which is a very different beast. But anyway, no; that sort of query only works on application object models, not on AppleScript lists and records. There’s no really concise way of doing this. Various ways your basic iteration approach could be finessed; alternative tools or techniques that may work better for certain situations; sometimes though you just gotta do a bit of legwork. Whatever; write the code, shove it in a subroutine, and ignore the details thereafter.