Apply a callback to an array: Difference between revisions
Content added Content deleted
m (Fixed XBS example) |
|||
Line 965: | Line 965: | ||
=={{header|Dyalect}}== |
=={{header|Dyalect}}== |
||
<lang Dyalect>func Array. |
<lang Dyalect>func Array.Select(pred) { |
||
for x in this when pred(x) { |
for x in this when pred(x) { |
||
yield x |
yield x |
||
Line 972: | Line 972: | ||
var arr = [1, 2, 3, 4, 5] |
var arr = [1, 2, 3, 4, 5] |
||
var squares = arr. |
var squares = arr.Select(x => x * x) |
||
print(squares)</lang> |
print(squares)</lang> |