With apologies to Quinn, here's some details about what I want the code to do.
I was testing it with an array of 10,000 random integers between 1 and 10 (which is why I'm concerned that the main computation should run only once.)
In this test case, the struct is initialized with the array of integers as data. It then creates the dictionary frequencies, with the integers 1 to 10 as its keys. The values are counts of how often each key appears in data. That's the part that should only run once, so I didn't set it up as a computed property.
The function frequency(of:) takes a set of arbitrary integers elements as input, and returns a dictionary with the same structure as frequencies, but with elements as the keys. So some of the values in that dictionary may be zero. I used a set as input so that there'd be no duplicate keys from the outset, since I believe the uniqueKeysWithValues: Dictionary initializer will crash if there are.
The main difference between the frequency(of:) function and the struct initializer is that the initializer finds its own keys within the data array.
The app I'm working on is intended to calculate frequencies and distributions of letters, words, etc. in multi-megabyte text files, so it's handy to set things up generically. It's also more fun.