Filter: Difference between revisions

9 bytes removed ,  1 month ago
m (→‎{{header|Sidef}}: updated code)
 
(5 intermediate revisions by 2 users not shown)
Line 1,566:
auto array := new int[]{1,2,3,4,5};
 
var evens := array.filterBy::(n => n.mod:(2) == 0).toArray();
 
evens.forEach:(printingLn)
}</syntaxhighlight>
Using strong typed collections and extensions:
Line 1,581:
 
array
.filterBy::(int n => n.mod:(2) == 0)
.forEach::(int i){ console.printLine(i) }
}</syntaxhighlight>
{{out}}
Line 2,388:
 
=={{header|langur}}==
Using the filter() function filters by a function or regex and returns ana arraylist of values.
 
<syntaxhighlight lang="langur">val .arrlist = series 7
{{works with|langur|0.11}}
<syntaxhighlight lang="langur">val .arr = series 7
 
writeln " array list: ", .arrlist
writeln "filtered: ", filter ffn{div 2}, .arr</syntaxhighlight>list
</syntaxhighlight>
 
{{out}}
<pre> array list: [1, 2, 3, 4, 5, 6, 7]
filtered: [2, 4, 6]</pre>
 
890

edits