Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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