Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
1218daf2
Verified
Commit
1218daf2
authored
Mar 31, 2020
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add special instances for values of type Int and String to Data.Set
parent
f9cf290d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
src/libraries/OS-Independent/Data/Set.dcl
src/libraries/OS-Independent/Data/Set.dcl
+13
-0
src/libraries/OS-Independent/Data/Set.icl
src/libraries/OS-Independent/Data/Set.icl
+1
-1
No files found.
src/libraries/OS-Independent/Data/Set.dcl
View file @
1218daf2
...
...
@@ -140,6 +140,7 @@ size s :== case s of
* member x s <==> isMember x (toList s)
*/
member
::
!
a
!(
Set
a
)
->
Bool
|
<
a
special
a
=
Int
;
a
=
String
/**
* Checks if an element is not in the set.
...
...
@@ -158,6 +159,7 @@ notMember x t :== not (member x t)
isSubsetOf
t1
t2
:==
(
size
t1
<=
size
t2
)
&&
(
isSubsetOfX
t1
t2
)
isSubsetOfX
::
!(
Set
a
)
!(
Set
a
)
->
Bool
|
<
a
special
a
=
Int
;
a
=
String
/**
* Is t1 a proper subset of t2?
...
...
@@ -197,6 +199,7 @@ singleton :: !u:a -> w:(Set u:a), [w <= u]
* integrity xs` // Data structure integrity
*/
insert
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* Delete an element from a set.
...
...
@@ -209,6 +212,7 @@ insert :: !a !.(Set a) -> Set a | < a
* integrity xs` // Data structure integrity
*/
delete
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* The minimal element of a set.
...
...
@@ -311,6 +315,7 @@ maxView :: !.(Set a) -> .(Maybe (!a, !Set a))
* elems = toList xs ++ toList ys
*/
union
::
!
u
:(
Set
a
)
!
u
:(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* The union of a list of sets.
...
...
@@ -330,6 +335,7 @@ unions ts :== foldl union newSet ts
* (xs`,ys`) = (toList xs, toList ys)
*/
difference
::
!(
Set
a
)
!(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* The intersection of two sets.
...
...
@@ -345,12 +351,14 @@ difference :: !(Set a) !(Set a) -> Set a | < a
* (xs`,ys`) = (toList xs, toList ys)
*/
intersection
::
!(
Set
a
)
!(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* The intersection of a list of sets.
* Elements of the result come from the first set
*/
intersections
::
![
Set
a
]
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* Filter all elements that satisfy the predicate.
...
...
@@ -360,6 +368,7 @@ intersections :: ![Set a] -> Set a | < a
* =.= sort (removeDup ('StdList'.filter (pred p) (toList xs)))
*/
filter
::
!(
a
->
Bool
)
!(
Set
a
)
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* Partition the set into two sets, one with all elements that satisfy the
...
...
@@ -381,6 +390,7 @@ filter :: !(a -> Bool) !(Set a) -> Set a | < a
* xs` = true` ++ false`
*/
partition
::
!(
a
->
Bool
)
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
special
a
=
Int
;
a
=
String
/**
* Split a set in elements less and elements greater than a certain pivot.
...
...
@@ -404,6 +414,7 @@ partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a) | < a
* xs` = lt` ++ gt`
*/
split
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
special
a
=
Int
;
a
=
String
/**
* Performs a 'split' but also returns whether the pivot element was found in
...
...
@@ -425,6 +436,7 @@ split :: !a !(Set a) -> (!Set a, !Set a) | < a
* xs` = lt` ++ gt`
*/
splitMember
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Bool
,
!
Set
a
)
|
<
a
special
a
=
Int
;
a
=
String
/**
* Convert the set to an ascending list of elements.
...
...
@@ -447,6 +459,7 @@ toAscList t :== 'Data.Foldable'.foldr` (\a as -> [a:as]) [] t
* @complexity O(n*log n)
*/
fromList
::
![
a
]
->
Set
a
|
<
a
special
a
=
Int
;
a
=
String
/**
* Map a function to all elements in a set.
...
...
src/libraries/OS-Independent/Data/Set.icl
View file @
1218daf2
implementation
module
Data
.
Set
import
StdClass
,
StdMisc
,
StdBool
,
StdFunc
,
StdInt
,
StdTuple
import
StdClass
,
StdMisc
,
StdBool
,
StdFunc
,
StdInt
,
Std
String
,
Std
Tuple
import
Data
.
Maybe
,
Data
.
GenEq
,
Data
.
GenLexOrd
,
Data
.
Monoid
from
Data
.
Foldable
import
class
Foldable
(..)
import
Data
.
Func
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment