Apply a callback to an array: Difference between revisions

Add WDTE example.
(→‎{{header|APL}}: Added APL implementation.)
(Add WDTE example.)
Line 3,137:
5</pre>
 
=={{header|WDTE}}==
<lang WDTE>let a => import 'arrays';
let s => import 'stream';
 
let example => [3; 5; 2];
 
let double => a.stream example
-> s.map (* 2)
-> s.collect
;</lang>
 
In WDTE, mapping can be accomplished using the <code>stream</code> module. Streams are essentially lazy iterators. The <code>arrays</code> module provides a function for creating a stream from an array, and then the <code>stream</code> module's functions can be used to perform a map operation. <code>collect</code> runs the iteration, collecting the elements yielded in a new array.
 
=={{header|Wren}}==