Skip to content

Instantly share code, notes, and snippets.

garykpdx /
Last active Jul 12, 2016
Example of concurrent processusing Python builtin library(example modified from example in Python docs)
#!/usr/bin/env python
import os
from concurrent.futures import ProcessPoolExecutor
import math
import time
garykpdx /
Last active Aug 29, 2015
A decorator that enforces a particular type/subtype for each parameter of a function
class enforce(object):
def __init__(self,*argtypes):
# the types that need to be enforced for each position arg[i]
self.argtypes = argtypes
def __call__(self,f):
def wrapper(*args):
# bail if the definition isn't set up to handle this many arguments
if len(self.argtypes) < len(args):
raise Exception('too many parameters passed in')
* This program shows the different kinds of calls that can be made for functions like the factorial, and fibonacci
public class FactorialExample {
public static void main(String[] args) {
System.out.println( factRecursive(5));
System.out.println( factTailRecursive(5));
System.out.println( factIterative(5));