title: How do I implement the filter function in Swift
body: <p>To gain a better understanding of Swift, I've extended <code>SequenceType</code> to add my own versions of <code>map</code>, <code>reduce</code> and <code>forEach</code> functions. However, the <code>filter</code> function is different in that it returns an array of <code>Self.Generator.Element</code>. Here's what I have so far:</p>
  
  <pre><code>extension SequenceType {
      public func myFilter(@noescape includeElement: (Self.Generator.Element) throws -&gt; Bool) rethrows -&gt; [Self.Generator.Element] {
          var array = [Self.Generator.Element]()
          for element in self {
              do {
                  if try includeElement (element) {
                      array.append(element)
                  }
              }
          }
          return array
      }
  }
  </code></pre>
  
  <p>The statement <code>var array = [Self.Generator.Element]()</code> produces an "Invalid use of () to call a value of non-function type [Self.Generator.Element.Type]" error. My question is how do I create/add to/return an array of <code>Self.Generator.Element</code>?</p>