View roman.c
#include <stdio.h> | |
enum { I, V, X, L, C, D, M, StackSize }; | |
const int values[] = { 1, 5, 10, 50, 100, 500, 1000 }; | |
int | |
unroman(const char *s) | |
{ | |
int stack[StackSize]; |
View CovariantIterator.java
import java.util.Iterator; | |
public class CovariantIterator<T extends U, U> implements Iterator<U> | |
{ | |
private Iterator<T> iter; | |
public CovariantIterator(Iterator<T> it) | |
{ | |
this.iter = it; | |
} |
View intern.c
#include <limits.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
const char * | |
intern(const char *s) | |
{ | |
union tree { | |
const char *str; |
View mircrev.c
#include <ctype.h> | |
#define BIT(X) (1 << (X)) | |
#define CTRL(X) ((X) - '@') | |
enum { None = -1 }; | |
enum { | |
Bold = CTRL('B'), | |
Colour = CTRL('C'), |
View next.sh
#!/bin/sh | |
dir=${1%/*} | |
bin=${1##*/} | |
shift | |
unset flag | |
set -f | |
IFS=: |
View dissre.py
import re | |
import sre_compile | |
import sre_parse | |
from sre_constants import * | |
opcodes = dict((v,k) for (k,v) in OPCODES.items()) | |
atcodes = dict((v,k) for (k,v) in ATCODES.items()) | |
chcodes = dict((v,k) for (k,v) in CHCODES.items()) | |
def print_dis(s, indent): |
View repack.py
from queue import PriorityQueue | |
class Field: | |
def __init__(self, size, align): | |
self.size = size | |
self.align = align | |
class Struct: | |
def __init__(self, fields): | |
size = 0 |
View catalan.py
from fractions import Fraction | |
def catalan(n): | |
c = 1 | |
for k in range(2, n + 1): | |
c *= Fraction(n + k, k) | |
return int(c) |
View cartesian.hs
cartesian :: [[a]] -> [[a]] | |
cartesian [] = [[]] | |
cartesian (xs:zss) = [x:ys | x <- xs, ys <- cartesian zss] |
View ucd.awk
BEGIN { FS = ";"; OFS = ","; } | |
{ name = $2; } | |
name ~ /<.*>/ { name = $11; } | |
name { print $1, name, $3; } |
OlderNewer