Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.58 KB | None | 0 0
  1. let move x' y' (shape, _, _, height, width) =
  2.     (shape, x', y', height, width)
  3.  
  4. type Event =
  5.     | ShapeCreated of shape:string * x:int * y:int * id:int64
  6.     | ShapeMoved of x: int * y: int * id: int64
  7.     | ShapeDeleted of id: int64
  8.  
  9. let folder state event =
  10.     match event with
  11.     | ShapeCreated(shape, x, y, id) ->
  12.         Map.add id (shape ,x, y, 50, 50) state
  13.     | ShapeMoved(x', y', id) ->
  14.         Map.map (fun key shape ->
  15.             if key = id then move x' y' shape
  16.             else shape)
  17.             state
  18.     | ShapeDeleted id ->
  19.         Map.remove id state
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement