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
-- Author: Michael-Keith Bernard | |
-- Date: May 22, 2012 | |
-- Description: Various implementations of the Fibonacci sequence in Lua. Lua | |
-- has native support for tail-call elimination which is why `tail_call` and | |
-- `continuation` run in near constant time. For sufficiently large numbers of n | |
-- you can start to see linear performace characteristics (particularly for the | |
-- `continuation` implementation), but ultimately the `tail_call` implementation | |
-- is an order of magnitude faster than iteration even for values of n as small | |
-- as 500k. |
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 dataclasses as dc | |
import typing as ty | |
import inspect | |
import functools | |
S = ty.TypeVar("S") | |
A = ty.TypeVar("A") | |
B = ty.TypeVar("B") | |
@dc.dataclass(frozen=True) |
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
-module(sortlib). | |
-export([qsort/1, bsort/1, ssort/1, isort/1, msort/2, | |
msort_lte/1, msort_gte/1]). | |
-export([test_sort/0, test_sort/1, shuffle/1, split/1, merge/3]). | |
-import(lists, [reverse/1]). | |
%% Various sorting algorithms implemented in Erlang |
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
#!/usr/bin/env python | |
import csv | |
import json | |
import sys | |
import argparse | |
import dataclasses as dc | |
@dc.dataclass(frozen=True) |
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
from ctypes import CDLL, c_void_p, byref | |
from ctypes.util import find_library | |
# The following code fails on ubuntu 18.04, but succeeds on 14.04 | |
lib = CDLL(find_library('guestlib')) | |
handle = c_void_p() | |
ret = lib.VMGuestLib_OpenHandle(byref(handle)) | |
if ret != 0: | |
raise RuntimeError("failed to get handle") |
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
def iter_paths(d): | |
def iter1(d, path): | |
paths = [] | |
for k, v in d.items(): | |
if isinstance(v, dict): | |
paths += iter1(v, path + [k]) | |
paths.append((path + [k], v)) | |
return paths | |
return iter1(d, []) |
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
from functools import partial | |
def identity(e): | |
return e | |
def walk(inner, outer, coll): | |
if isinstance(coll, list): | |
return outer([inner(e) for e in coll]) | |
elif isinstance(coll, dict): | |
return outer(dict([inner(e) for e in coll.iteritems()])) |
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
package main | |
import ( | |
"fmt" | |
) | |
type RNG interface { | |
Next() (uint64, RNG) | |
} |
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
package com.segfaultax; | |
public interface Function<Param, Result> { | |
public Result apply(Param in); | |
} |
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
def main(): | |
# Application code goes here! | |
pass | |
PACKAGES = ("praw", ) | |
### IGNORE BELOW THIS LINE ### | |
def run(cmd, shell=False, silent=False): |
NewerOlder