That’s going to be quite slow, like O(n^2), since it copies the dictionary 
every time it adds a key to it.
It also seems more complicated than the simple for-loop implementation; but 
then, I’m not a functional-language programmer.

// here’s how I’d do it; not tested in a playground
var dict2 = [Key:Value](minCapacity: dict1.count)
for (k,v) in dict1 {
        let (k1,v1) = xform(k,v)
        dict2[k1] = v1
}

—Jens
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to