Skip to content

Commit fa5d33b

Browse files
committed
std: Add a module for procedural concepts, such as looping
1 parent de64a5d commit fa5d33b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

std/proc/loop/loops

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
Procedural :: module {
4+
// Function: forEach
5+
// Executes a function on each element of the array
6+
//
7+
// Parameters:
8+
// array - The array to iterate over
9+
// fx - A function to call for each element in the array
10+
//
11+
// Returns:
12+
// (Unit) - Represents the absence of a meaningful return value
13+
//
14+
// Notes:
15+
// This function is intended for cases where `fx` performs side effects,
16+
// like printing, logging, or mutating external state.
17+
forEach :: (arr, func) = pic_nat_foreach(arr, func)
18+
19+
20+
21+
// Function: forever
22+
// Executes a function forever
23+
//
24+
// Parameters:
25+
// fx - A function to call
26+
//
27+
// Returns:
28+
// (Unit) - Represents the absence of a meaningful return value
29+
forever :: (func) = pic_nat_forever(func)
30+
}
31+

0 commit comments

Comments
 (0)