Skip to content

Commit

Permalink
add sys/structs/iterable.sup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup2point0 authored Nov 10, 2024
1 parent 546265c commit 0d6a190
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions source/ixtensions/sys/structs/iterable.sup
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.
</>
}
}


<//>

0 comments on commit 0d6a190

Please sign in to comment.