sample.pascaligo.txt 663 B

1234567891011121314151617181920
  1. type storage is int
  2. type parameter is
  3. Increment of int
  4. | Decrement of int
  5. | Reset
  6. type return is list (operation) * storage
  7. // Two entrypoints
  8. function add (const store : storage; const delta : int) : storage is
  9. store + delta
  10. function sub (const store : storage; const delta : int) : storage is
  11. store - delta
  12. (* Main access point that dispatches to the entrypoints according to
  13. the smart contract parameter. *)
  14. function main (const action : parameter; const store : storage) : return is
  15. ((nil : list (operation)), // No operations
  16. case action of
  17. Increment (n) -> add (store, n)
  18. | Decrement (n) -> sub (store, n)
  19. | Reset -> 0
  20. end)