Projecteuler.net Problem 2 using collection pipeline Pattern
updated my code to use a deferent approach and apply collection pipeline
update my code

I use collection pipeline refactoring for more information about the
topics look
https://martinfowler.com/articles/refactoring-pipelines.html
I use stride function instead of filter to generate even Integer array

Sidenote: I don't know if I will save a couple of computing cycles—all I want to make my code more Swifty.
func isPerfectSquare(_ x:Int ) -&gt; Bool {
    let i = Int(sqrt(Double(x)))
    return  (i * i == x)
}

var result  =  (Array(stride(from: 0`enter code here`, to: 100, by: 2)).filter{(isPerfectSquare(5 * $0 * $0  + 4) || isPerfectSquare(5 * $0 * $0  - 4))}).reduce(into: 0){$0 += $1}
print(result)