diff options
Diffstat (limited to 'template')
-rw-r--r-- | template/go/snip-sorter.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/template/go/snip-sorter.go b/template/go/snip-sorter.go new file mode 100644 index 0000000..49fe7ac --- /dev/null +++ b/template/go/snip-sorter.go @@ -0,0 +1,13 @@ +func ({{_var_:varname}} {{_var_:name}}) Len() int { + return len({{_var_:varname}}) +} + +func ({{_var_:varname}} {{_var_:name}}) Less(i, j int) bool { + return {{_var_:varname}}[i] < {{_var_:varname}}[j] +} + +func ({{_var_:varname}} {{_var_:name}}) Swap(i, j int) { + {{_var_:varname}}[i], {{_var_:varname}}[j] = {{_var_:varname}}[j], {{_var_:varname}}[i] +} +{{_define_:name:input('name: ')}} +{{_define_:varname:substitute('{{_var_:name}}' =~ '^[ij]' ? '{{_var_:name}}'[:1] : '{{_var_:name}}'[0],'\w\+', '\l\0', '')}} |