2020-09-28 02:41:51 +03:00
|
|
|
interface Set2
|
|
|
|
exposes [ empty, isEmpty, len, add, drop, map ]
|
2019-12-04 01:46:12 +03:00
|
|
|
imports []
|
|
|
|
|
2020-08-04 01:50:50 +03:00
|
|
|
|
|
|
|
## An empty set.
|
|
|
|
empty : Set *
|
|
|
|
|
2019-12-04 01:46:12 +03:00
|
|
|
## Check
|
|
|
|
|
2020-08-04 01:50:50 +03:00
|
|
|
isEmpty : Set * -> Bool
|
|
|
|
|
2021-01-01 00:02:08 +03:00
|
|
|
len : Set * -> Nat
|
2020-08-04 01:50:50 +03:00
|
|
|
|
2020-09-28 02:41:51 +03:00
|
|
|
# TODO: removed `'` from signature because parser does not support it yet
|
|
|
|
# Original signature: `add : Set 'elem, 'elem -> Set 'elem`
|
|
|
|
add : Set elem, elem -> Set elem
|
2020-08-04 01:50:50 +03:00
|
|
|
|
2020-08-09 04:10:02 +03:00
|
|
|
## Drops the given element from the set.
|
2020-09-28 02:41:51 +03:00
|
|
|
# TODO: removed `'` from signature because parser does not support it yet
|
|
|
|
# Original signature: `drop : Set 'elem, 'elem -> Set 'elem`
|
|
|
|
drop : Set elem, elem -> Set elem
|
2019-12-16 01:19:16 +03:00
|
|
|
|
2020-08-04 01:50:50 +03:00
|
|
|
## Convert each element in the set to something new, by calling a conversion
|
|
|
|
## function on each of them. Then return a new set of the converted values.
|
2019-12-16 01:19:16 +03:00
|
|
|
##
|
2020-08-04 01:50:50 +03:00
|
|
|
## >>> Set.map {: -1, 1, 3 :} Num.negate
|
2019-12-16 01:19:16 +03:00
|
|
|
##
|
2020-08-04 01:50:50 +03:00
|
|
|
## >>> Set.map {: "", "a", "bc" :} Str.isEmpty
|
2019-12-16 01:19:16 +03:00
|
|
|
##
|
|
|
|
## `map` functions like this are common in Roc, and they all work similarly.
|
|
|
|
## See for example #Result.map, #List.map, and #Map.map.
|
2020-09-28 02:41:51 +03:00
|
|
|
# TODO: removed `'` from signature because parser does not support it yet
|
|
|
|
# Original signature: `map : Set 'elem, ('before -> 'after) -> Set 'after`
|
|
|
|
map : Set elem, (before -> after) -> Set after
|