Skip to content

Commit

Permalink
Forgotten file pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
HenJi committed Nov 6, 2011
1 parent afa17f0 commit 1faf3c5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/scores.opa
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
database ./opacman

db /opacman/scores: list((int, string))

@server @publish Scores = {{

get() =
/opacman/scores

add(name, value) =
nl = String.length(name)
name =
if nl == 0 then "ZZZ"
else if nl > 3 then String.substring_unsafe(0, 3, name)
else name
cur = /opacman/scores
scores = [(value, name)|cur]
|> List.sort_by(_.f1, _)
|> List.rev
|> List.split_at(_, 5)
|> _.f1
do /opacman/scores <- scores
scores

}}

_ = if /opacman/scores == [] then
_ = Scores.add("AAA", 10000)
_ = Scores.add("BBB", 7500)
_ = Scores.add("CCC", 5000)
_ = Scores.add("DDD", 2500)
_ = Scores.add("EEE", 0)
void

0 comments on commit 1faf3c5

Please sign in to comment.