It would be nice also to compute complexity of functions:
let arrayOfArrays: [[Int]] = ...
// computed complexity: O(n * n log n)
func sortSubarrays(array: [[Int]]) {
// also we know complexity of foreach ( O(n) )
array.forEach(sort(array:)) // we know complexity of sort(array:)
}
It isn’t possible for all algorithms, due to the halting problem. Maybe there are some cases where it can be done, but I’m not sure if it’s worth investing time in to it.