Added list comprehensions and standard List, Option, Func, Pair, and Triple library (#105)
* Added standard List library and list comprehensions Added List library. Flatmaps WIP Fixed dependency in flat_map fcode generation Updated tests to use custom list lib Added comprehension test Added stdlib sanity Test * Extended stdlib for lists. Added error message for redefinition of stdlibx * Fixed type template * Improved stdlib * More functions * Fixed cyclic includes * Refixed imports and added few tests * Added fail test * Undelete removed type spec * Remove typo * Fix iter function * Fixed typo * Added if guards and let statements in list comp * Added more fail tests * Option stliv * 2 and 3 tuple stdlib * Updated stdlib to new syntax. Added recursor and changed all/any functions * Fixed performance issues. Changed include management * Fixed hash type
This commit is contained in:
committed by
Hans Svensson
parent
69ad8ce9bc
commit
b669d2df1e
@@ -47,7 +47,7 @@ module Voting : Voting = {
|
||||
let init(proposalNames: args): state =
|
||||
{ chairPerson: caller(),
|
||||
voters: AddrMap.empty,
|
||||
proposals: List.map((name) => {name: name, voteCount: 0}, proposalNames)
|
||||
proposals: MyList.map((name) => {name: name, voteCount: 0}, proposalNames)
|
||||
};
|
||||
|
||||
/* Boilerplate */
|
||||
@@ -73,7 +73,7 @@ module Voting : Voting = {
|
||||
};
|
||||
|
||||
let addVote(candidate, weight) = {
|
||||
let proposal = List.nth(state().proposals, candidate);
|
||||
let proposal = MyList.nth(state().proposals, candidate);
|
||||
proposal.voteCount = proposal.voteCount + weight;
|
||||
};
|
||||
|
||||
@@ -121,6 +121,6 @@ module Voting : Voting = {
|
||||
|
||||
/* const */
|
||||
let currentTally() =
|
||||
List.map((p) => (p.name, p.voteCount), state().proposals);
|
||||
MyList.map((p) => (p.name, p.voteCount), state().proposals);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ open Voting;
|
||||
|
||||
let print_tally() = {
|
||||
let tally = call(other, () => currentTally());
|
||||
List.map(((name, count)) => Printf.printf("%s: %d\n", name, count), tally);
|
||||
MyList.map(((name, count)) => Printf.printf("%s: %d\n", name, count), tally);
|
||||
let winner = call(other, () => winnerName());
|
||||
Printf.printf("Winner: %s\n", winner);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user