-
Notifications
You must be signed in to change notification settings - Fork 25
Red Black Tree #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Red Black Tree #136
Changes from 36 commits
7f21e72
4d6a53a
c017c3c
ef1d14f
8bcd905
27ff11e
dae76bc
e5d206f
ce31a6d
5b3cd88
eb36254
274f324
8584322
9aa2f4a
7bb419d
bb826df
a3f0b7b
c44f26c
b9eb957
88ee81d
6727f66
e462f83
9ade649
2904ee7
9dc0c0c
7469061
c4675a9
cd894b1
8f31eb6
ec465d9
394a919
dd86d99
5450ed1
f9ccbf0
b447f1e
2549f93
da11171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,3 +48,4 @@ pub module Int64 | |
| pub let one = 1L | ||
| pub let ofInt (n : Int) = n.toInt64 | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,144 @@ | ||||||
| {# This file is part of DBL, released under MIT license. | ||||||
| # See LICENSE for details. | ||||||
| #} | ||||||
|
|
||||||
| import List | ||||||
|
|
||||||
MinionJakub marked this conversation as resolved.
Show resolved
Hide resolved
MinionJakub marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| data NotNegativeInt = Zero | Positive of Int | ||||||
|
|
||||||
| let addOne value = | ||||||
| match value with | ||||||
| | Zero => Positive 1 | ||||||
| | Positive n => Positive (n+1) | ||||||
| end | ||||||
|
|
||||||
| let subOne value = | ||||||
| match value with | ||||||
| | Zero => Zero | ||||||
| | Positive n => if n == 1 then Zero else Positive (n-1) | ||||||
| end | ||||||
|
|
||||||
| data RotationState Val = | ||||||
| | Idle | ||||||
| | Reversing of NotNegativeInt, List Val, List Val, List Val, List Val | ||||||
| | Appending of NotNegativeInt, List Val, List Val | ||||||
| | Done of List Val | ||||||
|
|
||||||
| data HoodMelvilleQueue Val = | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type should be abstract. As is right now, it can't be used to annotate stuff outside this module. Also, name could be shorter, maybe |
||||||
| | HMQueue of NotNegativeInt, List Val, RotationState Val, | ||||||
| NotNegativeInt, List Val | ||||||
|
||||||
| NotNegativeInt, List Val | |
| NotNegativeInt, List Val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just like in fold function: you have to respect element count. In case a function f is a partial function, there may be edge cases where you terminate a program on a value that shouldn't be in queue. We don't need this function, composition of toList > map > fromList should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remane this to cons. Push is confusing.
Uh oh!
There was an error while loading. Please reload this page.