Skip to content

Commit 22eae71

Browse files
authored
Merge pull request #85 from GaragePixel/develop
stdlib adds #21 - syntax - functors - foreach.wx
2 parents 13b157e + e7f0308 commit 22eae71

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Namespace std.syntax
3+
4+
#rem MiniLibrary: Arrays
5+
Since 025-07-16 (Aida 4)
6+
Author: iDkP from GaragePixel
7+
#end
8+
9+
#rem wonkeydoc @pro The ForEach function - A generic iteration utility with callback execution.
10+
@author iDkP from GaragePixel
11+
@since 2025-07-16
12+
A ForEach provides a functional approach to array iteration with custom callback processing.
13+
The ForEach function executes a provided callback for each element within a specified range,
14+
enabling functional programming patterns while maintaining Wonkey's type safety through generics.
15+
#end
16+
Function ForEach<T,B>:T[]( values:T[],
17+
callback:Void(index:B,value:T),
18+
from:B=0, atEnd:B=Null ) Where B Implements IShort Or
19+
B Implements ICompact
20+
If atEnd=Null atEnd=values.Length 'Auto
21+
22+
For Local index:B=from Until atEnd
23+
callback(index,values[index])
24+
End
25+
26+
Return values
27+
End

0 commit comments

Comments
 (0)