This file contains hidden or 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
data Natural = Zero | Succ Natural | |
add :: Natural -> Natural -> Natural | |
add Zero b = b | |
add (Succ a) b = add a (Succ b) | |
mul :: Natural -> Natural -> Natural | |
mul Zero _ = Zero | |
mul _ Zero = Zero | |
mul (Succ a) b = add b (mul a b) |
This file contains hidden or 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
-- ? doesn't have statements, it has sentences. | |
-- sentences end with a full stop, as everyone knows. | |
-- every expression can be a sentence. | |
let a = 1. | |
-- let expressions look like this: | |
-- `'let' VARIABLE '=' EXPRESSION (',' VARIABLE '=' EXPRESSION)* ('and' VARIABLE '=' EXPRESSION)?` | |
let b = 2 and c = 3. | |
let d = 4, e = 5 and f = 6. | |
let g = 7, h = 8. |
This file contains hidden or 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
syntax on | |
nnoremap ; : | |
nnoremap : ; | |
" Sane auto-completion | |
set wildmode=list:longest,longest | |
" Set working directory to the current file automatically | |
set autochdir |
This file contains hidden or 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
cat pacman.log | grep ' installed' | cut -d ' ' -f 5 | uniq | wc -l | |
for directory in $(ls -lAFp | grep '/' | sed 's/\///' | cut -f 2 --d ':' | cut -f 2 --delim ' '); do cd $directory; echo -n "$directory "; sudo find | wc -l; cd ..; done | |
find . -name "*.[ch]" | xargs etags -o ~/.tags/TAGS | |
pavucontrol |
This file contains hidden or 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
# | |
# ~/.bashrc | |
# | |
# If not running interactively, don't do anything | |
[[ $- != *i* ]] && return | |
alias ls='ls --color=auto' | |
# Play a directory |
This file contains hidden or 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 __make_init(*argnames): | |
def __init__(self, *args): | |
expected = len(argnames) | |
actual = len(args) | |
if expected != actual: | |
s = '' if expected == 1 else 's' | |
raise TypeError("__init__() takes exactly {expected} argument{s} ({actual} given)".format(**locals())) | |
for (arg, argname) in zip(args, argnames): | |
setattr(self, argname, arg) | |
return __init__ |
This file contains hidden or 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
# Determine whether, in any state, the expected chosen prize is greater than the maximum prize | |
from itertools import combinations | |
from math import log, exp | |
cases = {1,10,100,1000} | |
maxprize = 200 | |
s = set.union(*[set(combinations(cases, i)) for i in range(1, len(cases)+1)]) | |
ss = sorted(s) |
This file contains hidden or 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
DCPU-16 Specification | |
Copyright 1985 | |
Version 1.7 | |
=== SUMMARY ==================================================================== | |
* 16 bit words | |
* 0x10000 words of ram | |
* 8 registers (A, B, C, X, Y, Z, I, J) | |
* program counter (PC) |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, void>::type> | |
constexpr T pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798; | |
int main() | |
{ | |
float radiusf; |
This file contains hidden or 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
#define GL_GLEXT_PROTOTYPES | |
#include <GLFW/glfw3.h> | |
#include <cstdlib> | |
#include <cstdio> | |
#include <cstring> | |
#include <cmath> | |
#include <algorithm> | |
#include <fstream> |