[swift-users] difference between two Ranges

Седых Александр se-a at mail.ru
Wed Sep 20 14:58:11 CDT 2017


Hello.
I try to get difference between two ranges. For instance I have to know how many meters from me to target who have own size (or range).

let range =  0 ... 5
let meFromPoint =  0 ... 10
 
let setRange =  Set ( range )
let setMeFromPoint =  Set ( meFromPoint )
 
let diff =  setMeFromPoint . subtracting ( setRange ). count // result 5
I found that operation Set(0...veryBigInt) may be slow.
Is exist some native way to get difference between two Ranges?


-- 
Седых Александр
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170920/cc5fcedb/attachment-0001.html>


More information about the swift-users mailing list