Created
September 20, 2019 14:56
-
-
Save thepiwo/5a4852f70996eb70b2b968c6cbaef52f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace List = | |
function foldr(f : (('a, 'b) => 'b), z: 'b, l : list('a)) : 'b = | |
switch(l) | |
[] => z | |
e :: l' => f(e, foldr(f, z, l')) | |
contract Identity = | |
record player = { balance : int } | |
type state = map(address, player) | |
entrypoint init() = {} | |
entrypoint get() = state | |
stateful entrypoint test() = | |
let accounts = [ak_2bKhoFWgQ9os4x8CaeDTHZRGzUcSwcXYUrM12gZHKTdyreGRgG, ak_2VnwoJPQgrXvreUx2L9BVvd9BidWwpu1ASKK1AMre21soEgpRT, ak_2bKhoFWgQ9os4x8CaeDTHZRGzUcSwcXYUrM12gZHKTdyreGRgG] | |
let amount = 100 | |
put(List.foldr(add_player(amount), state, accounts)) | |
function add_player(amount : int) = (account : address, acc : state) => | |
state{[account = {balance = 0}] @ player = player{balance @ b = b + amount}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment