-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
546265c
commit 0d6a190
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<doc> | ||
Activates the builtin `iterable`/`Iterable` abstract struct from which iterable collection-like structs should derive. | ||
</doc> | ||
|
||
<spec[code] { | ||
| version = 6.0 | ||
| flavour = cynax | ||
| default-deactive = true | ||
}> | ||
|
||
|
||
activate "/generic" with Generic | ||
|
||
|
||
active create Struct[ | ||
| abstract | ||
| generics = create Generic('T')[optional, covariant] | ||
] | ||
'Iterable', 'iterable' | ||
{ | ||
<doc> | ||
A collection of objects that can be iterated over. | ||
|
||
A generic type can be optionally provided to indicate a monotyped collection. | ||
</doc> | ||
|
||
create Function[Boolean] | ||
self.'for-all'( | ||
Parameter 'callback' [ | ||
Function[in = (Object,) | out = Boolean | ||
] | ||
] = ( | ||
Object '.obj' => switch Boolean(.obj) | ||
) | ||
) | ||
{ | ||
<doc> | ||
Return `true` if `obj.callback()` returns truthy for every `obj` in the iterable. | ||
</> | ||
} | ||
} | ||
|
||
|
||
<//> |