Project Euler #2 (Even Fibonacci numbers) in Swift
The following is similar to Flambino's approach, but creates a Swift
SequenceType so that you can use the Swift library functions
filter() and reduce() to iterate over
the elements:

struct FibonacciSequence : SequenceType {
    let upperBound : Int

    func generate() -&gt; GeneratorOf&lt;Int&gt; {
        var current = 1
        var next = 1
        return GeneratorOf&lt;Int&gt;() {
            if current &gt; self.upperBound {
                return nil
            }
            let result = current
            current = next
            next += result
            return result
        };
    }
}

let fibseq = lazy(FibonacciSequence(upperBound: 4_000_000))
let sum = reduce(fibseq.filter { $0 % 2 == 0 }, 0) { $0 + $1 }


See here for more information about sequences and generators. 
This nice application made me actually understand how you can create your own sequences.

lazy() creates a LazySequence, whose filter() method returns the elements "on demand", e.g. as needed in the summation. The 
filter() function would return an array of all even Fibonacci numbers
before starting the summation. (Kudos to @jtbandes for his suggestion). 



Update: Due to major changes in the Swift programming language,
the above code does not compile anymore with the current Swift 2.1/Xcode 7. Here is an updated version fore anybody's convenience:

struct FibonacciSequence : SequenceType {
    let upperBound : Int

    func generate() -&gt; AnyGenerator&lt;Int&gt; {
        var current = 1
        var next = 1
        return anyGenerator {
            if current &gt; self.upperBound {
                return nil
            }
            let result = current
            current = next
            next += result
            return result
        };
    }
}

let fibseq = FibonacciSequence(upperBound: 4_000_000).lazy
let sum = fibseq.filter { $0 % 2 == 0 }.reduce(0) { $0 + $1 }