This file contains 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
inoreabbrev <buffer> <expr> += '= ' .. getline('.')->matchstr('\c\(assign\s*\)\?\zs\S.*\ze+=') .. '+' | |
inoreabbrev <buffer> <expr> *= '= ' .. getline('.')->matchstr('\c\(assign\s*\)\?\zs\S.*\ze\*=') .. '*' | |
inoreabbrev <buffer> <expr> -= '= ' .. getline('.')->matchstr('\c\(assign\s*\)\?\zs\S.*\ze-=') .. '-' | |
inoreabbrev <buffer> <expr> /= '= ' .. getline('.')->matchstr('\c\(assign\s*\)\?\zs\S.*\ze/=') .. '/' |
This file contains 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
(defpackage :elo | |
(:use :cl)) | |
(in-package :elo) | |
(defvar *expected-outcome-fun* nil | |
"This is used to supply an alternative function for | |
calculating the expected outcome of a game (whose | |
arguments are the Elo scores of the two players, and | |
returns a number between 0 and 1). |
This file contains 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
" Parses Vimscript commands | |
" Caveats: | |
" - Assumes that "a:source" is a well-formed single-line Vim command; it doesn't always fail gracefully otherwise | |
" - Assumes there is only one command (i.e. "|"s are part of the arguments of the command and aren't used as separators) | |
" - For ":!" commands, "cmd" is an empty string, "has_bang" is TRUE, and "args" is the entire shell command | |
func ParseCmd(source) abort | |
" sorry. | |
let res = matchlist(a:source, '^[ \t:]*\%(\(\%([%.$,;]\|[''\\].\|[-+]\?\d\+\%(\s*match\)\@!\|\([/?]\).\{-\}[^//]\%(\\\\\)*\%(\2\|$\)\)*\)\s*\(\%(\a\|\d\)*\)\(!\?\)\s*\(.*\)\&[^"#]\)') | |
return empty(res) ? {} : #{ | |
\ source: res[0], |
This file contains 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
(defmacro valsetf (values-form . places) | |
"Assigns the values of VALUES-FORM to the given PLACES. | |
If VALUES-FORM yields more values than there are fields in PLACES, the | |
remaining values are discarded. If there are more fields in PLACES | |
than there are values returned by the VALUES-FORM, the remaining | |
fields are initialized to NIL." | |
(assert places) | |
(let* ((*gensym-counter* 1) | |
(gensyms (mapcar #'(lambda (_) |
This file contains 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
fu! Bezout(lhs, rhs) abort | |
let r = [a:lhs, a:rhs] | |
let [u, v] = [[1, 0], [0, 1]] | |
while r[1] != 0 | |
let q = r[0] / r[1] | |
let r = [r[1], r[0] % r[1]] | |
let u = [u[1], u[0] - u[1] * q] | |
let v = [v[1], v[0] - v[1] * q] | |
endwhile | |
return #{ |
This file contains 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
import Foundation | |
//MARK: Enumerations and Classes | |
enum Suit { | |
case hearts, diamonds, clubs, spades | |
} | |
enum Language { |
This file contains 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
/// An example implementation of the `KnapsackItem` protocol. | |
struct Example: KnapsackItem, CustomStringConvertible { | |
var name: String | |
var weight: Int | |
var value: Int | |
var description: String { name } | |
} |
This file contains 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
" tinyvimrc | |
se nu rnu hid ttm=100 list lcs=tab:\|\ ,trail:· | |
" Version-specific settings{{{ | |
if has('cmdline_info') | |
se sc | |
endif | |
if has('extra_search') | |
se is hls | |
noh |