In functional programming you often want to apply a function partly. A simple example is a function add
.
It would be nice if we could use add
like:
var res2 = add(1, 3); // => 4
var add10To = add(10);
var res = add10To(5); // => 15
import sublime | |
import sublime_plugin | |
class NumberCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
selection = self.view.sel() | |
for region in selection: | |
try: | |
value = int(self.view.substr(region)) | |
self.view.replace(edit, region, str(self.op(value))) |