Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
majorityJudgment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
delanoe
majorityJudgment
Commits
2a28144f
Commit
2a28144f
authored
Dec 18, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Diff -> Xor on lists
parent
c18571d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
README.md
README.md
+2
-1
Lib.hs
src/Lib.hs
+6
-6
No files found.
README.md
View file @
2a28144f
...
...
@@ -4,7 +4,8 @@
This implementation is more generic that this
[
definition on
wikipedia](https://en.wikipedia.org/wiki/Majority_judgment), even if it
reuses the same application example: if two ballots have the same score,
then diff of vote is computed to compute a new score.
then xor of votes is computed to then compute a new score on these same
ballots.
Not really tested yet, feedbacks welcome, just to better understand how
it works.
...
...
src/Lib.hs
View file @
2a28144f
...
...
@@ -87,20 +87,20 @@ instance Ord Ballot where
False
->
compare
(
score
v1
)
(
score
v2
)
True
->
compare
(
score
v1'
)
(
score
v2'
)
where
(
v1'
,
v2'
)
=
diff
(
v1
,
v2
)
(
v1'
,
v2'
)
=
xor
(
v1
,
v2
)
score
::
[
Vote
]
->
Maybe
Rational
score
=
median
.
map
voteToRational
------------------------------------------------------------------------
diff
::
Ord
a
=>
([
a
],[
a
])
->
([
a
],[
a
])
diff
(
m1
,
m2
)
=
(
fromMap
m1'
,
fromMap
m2'
)
xor
::
Ord
a
=>
([
a
],[
a
])
->
([
a
],[
a
])
xor
(
m1
,
m2
)
=
(
fromMap
m1'
,
fromMap
m2'
)
where
(
m1'
,
m2'
)
=
diff
Map
(
toMap
m1
,
toMap
m2
)
(
m1'
,
m2'
)
=
xor
Map
(
toMap
m1
,
toMap
m2
)
diff
Map
::
Ord
a
=>
(
Map
a
Int
,
Map
a
Int
)
->
(
Map
a
Int
,
Map
a
Int
)
diff
Map
(
m1
,
m2
)
=
(
m1'
,
m2'
)
xor
Map
::
Ord
a
=>
(
Map
a
Int
,
Map
a
Int
)
->
(
Map
a
Int
,
Map
a
Int
)
xor
Map
(
m1
,
m2
)
=
(
m1'
,
m2'
)
where
m1'
=
DM
.
unionWith
outer
m1
m13
m2'
=
DM
.
unionWith
outer
m2
m23
...
...
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