Write minWinPercentage and minVotes
Now, we are ready to create two new functions, minWinPercentage
and minVotes
.
[{
"_id": "_fn",
"name": "minWinPercentage",
"params": [ "PARAMS HERE" ],
"code": "SMART FUNCTION CODE HERE"
},
{
"_id": "_fn",
"name": "minVotes",
"params": [ "PARAMS HERE" ],
"code": "SMART FUNCTION CODE HERE"
}]
In order to write these functions, we'll need to use the smart functions we created, (yesVotes)
and (noVotes)
.
Both (yesVotes)
and (noVotes)
will return an array of auth records, for example [25769804775, 25769804776, 25769804777, 25769804778]
.
The function, count
, (i.e. (count (yesVotes))
) returns the count of the yesVotes.
You'll also need several of the following smart functions.
Function | Arguments | Example |
---|---|---|
inc | n optional | (inc) |
dec | n optional | (dec) |
== | arg1 arg2 ... | (== 1 1 1 1) |
+ | arg1 arg2 ... | (+ 1 2 3) |
- | arg1 arg2 ... | (- 10 9 3) |
* | arg1 arg2 ... | (* 90 10 2) |
/ | arg1 arg2 ... | (/ 36 3 4) |
> | arg1 arg2 ... | (> 90 10 2) |
< | arg1 arg2 ... | (< 90 10 2) |
>= | arg1 arg2 ... | (>= 90 90 10 2) |
< | arg1 arg2 ... | (< 2 10 90) |
<= | arg1 arg2 ... | (<= 2 10 90 90) |
max | arg1 arg2 ... | (max 1 2 3) |
min | arg1 arg2 ... | (min 1 2 3) |
and | arg1 arg2 ... | (and (== 1 1) (> 10 3)) |
or | arg1 arg2 ... | (or (== 1 1) (> 10 3)) |
Complete the Transaction
Add parameters and code to complete the above transaction.