[ create a new paste ] login | about

aaronla

Name: Aaron Lahman
Email:
Site/Blog: http://ra3s.com/wordpress/dysfunctional-programming/
Location: Redmond, Wa
Default language: C++
Favorite languages: C++, Scheme, Python
About:

Saved pastes by aaronla:

C, pasted on May 18:
1
2
3
4
5
#include <stdio.h>

int main()
{
  *(int*)0;
...
view (8 lines, 1 line of output)
C++, pasted on May 15:
1
2
3
4
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
...
view (21 lines, 3 lines of output)
C++, pasted on Apr 23:
1
2
3
4
5
using System;
using System.Runtime.InteropServices;
using System.Drawing;

namespace ConsoleApplication1
...
view (46 lines)
C, pasted on Apr 23:
1
2
3
4
5
#include <stdio.h>

int main()
{
    int* p = malloc(sizeof(int));
...
view (12 lines, 1 line of output)
C, pasted on Apr 23:
1
2
3
4
5
#include <stdio.h>

int main()
{
    int* p = malloc(sizeof(int));
...
view (15 lines, 1 line of output)
Python, pasted on Mar 2:
1
2
3
4
5
# simplified monadic packrat (almost CFG) parser
#  derived from parse6.py, added (lazy) backtracking   
#
#  parser :: str -> [ (value, str) ]
class lcons (object):
...
view (140 lines, 22 lines of output)
Python, pasted on Mar 2:
1
2
3
4
# simplified monadic (PEG) parser. no memoization, some backtracking.
#  parser :: str -> maybe (value, str)
def ret (value): 
    return lambda s: (value, s)
...
view (98 lines, 16 lines of output)
Python, pasted on Feb 15:
1
2
3
4
def main():
  print "now, take it for a spin"
  print "", to_seq([1,2,3]).to_list()
    
...
view (58 lines, 6 lines of output)
Python, pasted on Feb 14:
1
2
3
4
5
from parse import *
from test1 import timeit

def group(p):
  return p % (lambda v: ('group', v))
...
view (31 lines)
Python, pasted on Feb 10:
1
2
3
4
5
# first, some boilerplate
class Seq:
  def __init__(self, defer):
    self._defer = defer
  def force(self):
...
view (53 lines, 6 lines of output)
Python, pasted on Feb 10:
1
2
3
4
5
# first, some boilerplate
class Seq:
  def __init__(self, defer):
    self._defer = defer
  def force(self):
...
view (56 lines, 6 lines of output)
C++, pasted on Feb 8:
1
2
3
4
5
#include <iostream>

template <typename T> struct Base {
   void f(int) {
       std::cout << "Base<T>::f\n";
...
view (23 lines, 1 line of output)
C++, pasted on Feb 8:
1
2
3
4
5
#include <iostream>

template <typename T> struct Base {
   void f(int) {
       std::cout << "Base<T>::f\n";
...
view (23 lines, 2 lines of output)
C++, pasted on Dec 22:
1
2
3
4
5
#include <iostream>
#include <iomanip>
using namespace std;

namespace n1 {
...
view (27 lines, 3 lines of output)
C++, pasted on Dec 22:
1
2
3
4
#include <iostream>
#include <iomanip>
#include <typeinfo>
using namespace std;
...
view (32 lines, 5 lines of output)
Python, pasted on Dec 13:
1
2
import operator 
print len(reduce(operator.add, (((),),((),))))
view (2 lines, 1 line of output)
Python, pasted on Oct 22:
1
2
3
4
5
import random
import time


def analyzeCoin(coin, numSamples=1000):
...
view (37 lines, 2 lines of output)
C++, pasted on Oct 21:
1
2
3
4
5
    #include <iostream>
    #include <iomanip>
    using namespace std;

    template <class T>
...
view (35 lines, 6 lines of output)
C++, pasted on Oct 21:
1
2
3
4
5
#include <iostream>
#include <iomanip>
using namespace std;

struct S{
...
view (16 lines, 3 lines of output)
C++, pasted on Oct 7:
1
2
3
4
5
typedef int HRESULT ;
bool SUCCEEDED(HRESULT x){return(x)>=0;}
HRESULT f(){return 0;}
#define g f
#define h f
...
view (38 lines)
Python, pasted on Sep 30:
1
2
3
4
def e(x):
  return e(x-1) if x else 0
def e(x, e=e):
  return e(x-1) if x else 1
...
view (7 lines, 5 lines of output, 1 comment)
Python, pasted on Aug 25:
1
2
fact = lambda x: 1 if x<1 else x*fact(x-1)
print fact(20)
view (2 lines, 1 line of output)
C++, pasted on Aug 12:
1
2
3
4
5
// in reference to http://hbfs.wordpress.com/2011/08/09/programming-challenge-luminance/
#include <iostream>
#include <iomanip>

using namespace std;
...
view (66 lines, 2 lines of output)
Python, pasted on Aug 4:
1
2
3
4
#! python

# digraph.txt used: http://jnicholl.org/Cryptanalysis/Data/DigramFrequencies.php
import math
...
view (42 lines, 4 lines of output)
Scheme, pasted on Jan 12:
1
2
3
4
5
;; QR card for scheme
;; (c) 2011 Aaron Lahman

;; r5rs load module
(load {filename-string})
...
view (152 lines)
Scheme, pasted on Jan 11:
1
2
3
4
;QR card for scheme

;r5rs load module
(load {filename-string})
...
view (118 lines)
Scheme, pasted on Aug 7:
1
2
3
;;
;; hello world plt-scheme servlet
;;
...
view (35 lines)
Scheme, pasted on May 2:
1
2
3
4
5
; mb.ss
;
; mandelbrot set

(define (1+ r)
...
view (51 lines, 30 lines of output)
C++, pasted on Mar 16:
1
2
3
4
5
    #include <iostream>
    using namespace std;

    void f() {
        throw 1;
...
view (31 lines, 1 line of output)
Python, pasted on Feb 26:
1
2
3
4
5
def adds_dynamic_z_decorator(f):
  def replacement(*arg,**karg):
    # create a new 'z' binding in globals, saving previous
    if 'z' in globals():
      oldZ = (globals()['z'],)
...
view (42 lines, 9 lines of output)
C++, pasted on Dec 22:
1
2
3
4
5
/// answer to question on blog post
/// http://eli.thegreenplace.net/2008/12/22/an-rc-circuit-puzzle/
///
/// From the exercise, Eli said "But the current through the capacitor 
/// and resistor is the same current".  I'm not sure where you get this 
...
view (11 lines)
C++, pasted on Dec 22:
1
2
3
4
5
#include <type_traits>

using std::tr1::is_base_of;

// --- policy metaprogramming ---
...
view (79 lines)
Lua, pasted on Nov 28:
1
2
3
4
5
function memoize(f)
  store = {}
  function anon(x)
    if store[x] then
      return store[x]
...
view (28 lines, 2 lines of output)
Lua, pasted on Nov 28:
1
2
3
4
5
function memoize(f)
  store = {}
  function anon(x)
    if store[x] then
      return store[x]
...
view (30 lines, 2 lines of output)
Lua, pasted on Nov 28:
1
2
3
4
5
function memoize(f)
  store = {}
  function anon(x)
    if store[x] then
      return store[x]
...
view (29 lines, 1 line of output)
C++, pasted on Nov 21:
1
2
3
4
struct to_listoftuples
{
    template <class OuterContainerType>
    static PyObject* convert(OuterContainerType const& a)
...
view (18 lines)
C++, pasted on Nov 20:
1
2
3
4
5
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
template <class It>
...
view (28 lines, 1 line of output)
C++, pasted on Nov 19:
1
2
3
4
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
...
view (26 lines, 1 line of output)
C++, pasted on Oct 31:
1
2
3
4
5
#include <iostream>
#include <iomanip>
#include <set>
#include <algorithm>
#include <iterator>
...
view (40 lines, 5 lines of output)
C++, pasted on Oct 31:
1
2
3
4
5
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
...
view (40 lines, 5 lines of output)
C++, pasted on Oct 2:
1
2
3
4
5
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
using namespace std;
...
view (25 lines, 5 lines of output)
C++, pasted on Oct 2:
1
2
3
4
5
#include <iostream>
#include <iomanip>
#include <iterator>
#include <vector>
using namespace std;
...
view (25 lines, 5 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
#include <iostream>
#include <iomanip>
#include <map>

// memoizer.  
...
view (61 lines, 4 lines of output)
C++, pasted on Sep 23:
1
2
3
4
5
#include <iostream>
using namespace std;
template <int I, bool Fizz = !(I % 3), bool Buzz = !(I % 5)> struct number {};
template <int I> void fizzbuzz(number<I, false, false>){ cout << I << "\n"; }
template <int I> void fizzbuzz(number<I, true, false>){ cout << "Fizz\n"; }
...
view (21 lines, 100 lines of output)