Filter: Difference between revisions
Content added Content deleted
Line 1,134: | Line 1,134: | ||
Idiomatic approach in Dy is to use non-strict iterators (which can be combined without intermedate data structures) and translate the result to an array if needed: |
Idiomatic approach in Dy is to use non-strict iterators (which can be combined without intermedate data structures) and translate the result to an array if needed: |
||
<lang Dyalect> |
<lang Dyalect>var xs = [1..20] |
||
⚫ | |||
for x in this when pred(x) { |
|||
yield x |
|||
} |
|||
} |
|||
func Iterator.Select(proj) { |
|||
for x in this { |
|||
yield proj(x) |
|||
} |
|||
} |
|||
var xs = [1..20] |
|||
⚫ | |||
print(arr.ToArray())</lang> |
print(arr.ToArray())</lang> |
||