Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Software
CoPaR
Commits
fb7a40c2
Commit
fb7a40c2
authored
Mar 08, 2019
by
Hans-Peter Deifel
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SumBag: Implement membership tests
This is not strictly required by copar but allows for easier testing.
parent
58691da0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
src/Data/SumBag.hs
src/Data/SumBag.hs
+9
-1
No files found.
src/Data/SumBag.hs
View file @
fb7a40c2
...
...
@@ -7,9 +7,10 @@ module Data.SumBag
,
sum
,
insert
,
delete
,
elem
)
where
import
Prelude
hiding
(
sum
,
min
)
import
Prelude
hiding
(
sum
,
min
,
elem
)
import
qualified
Data.List.NonEmpty
as
NE
type
SumBag
a
=
Tree
a
...
...
@@ -57,6 +58,13 @@ insert a (Node _ e left right)
|
a
>
value
e
=
balance1
e
left
(
insert
a
right
)
|
otherwise
=
node
(
addOnce
e
)
left
right
elem
::
(
Ord
a
)
=>
a
->
SumBag
a
->
Bool
elem
_
Leaf
=
False
elem
a
(
Node
_
e
left
right
)
|
a
<
value
e
=
elem
a
left
|
a
>
value
e
=
elem
a
right
|
otherwise
=
True
delete
::
(
Ord
a
,
Monoid
a
)
=>
a
->
SumBag
a
->
SumBag
a
delete
_
Leaf
=
Leaf
delete
a
(
Node
_
e
left
right
)
...
...
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