Created
October 29, 2012 04:37
-
-
Save camshaft/3971543 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
%% Create the state | |
State1 = ot_text:create(), | |
%% Make an op. Let's say the request wanted to add "foo" at position 0 | |
Op1 = #ot_text_r{i="foo",p=0}, | |
%% Apply the operation | |
State2 = ot_text:apply(State1, [Op1]), | |
%% State2 now equals "foo" | |
%% We can also delete some text | |
Op2 = #ot_text_r{d=<<"o">>,p=1}, | |
%% Apply the delete operation | |
State3 = ot_text:apply(State2, [Op2]). | |
%% State3 now equals "fo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment