Skip to content

Instantly share code, notes, and snippets.

-- I have discovered a way to convert _any_ lua iterator into an
-- object which is lazily evaluated and which can be given behaviors
-- somewhat similar to the Iterator trait in Rust. Further, these
-- objects use metatables to allow for chained calls instead of the
-- Python-like ugly right-to-left series of calls (e.g.
-- `reduce(map(filter(range(1, 4), func), func), func)`)
--
-- This seems fairly elegent and obvious to me, so I am surprised I have not
-- seen any prior work in this area. I would love to be proven wrong, though!
--
import math
import operator
from functools import reduce
from itertools import combinations
from typing import Union
Number = Union[int, float]
def all_close(*values: Number):
@deoxys314
deoxys314 / 4d.vim
Last active October 14, 2020 15:16
Four-Dimensional Editing in Vim
let s:second = 1
let s:minute = 60 * s:second
let s:hour = 60 * s:minute
let s:day = 24 * s:hour
let s:week = 7 * s:day
let s:month = 30 * s:day
let s:year = 365 * s:day
function! s:get_undo_time(undo_dict) abort
let l:idx = a:undo_dict.seq_cur