SHARE
TWEET

Untitled

a guest Feb 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top