Permalink
Browse files

This subproject now has its own repository:

 * http://github.com/apauley/polygluttony

Removed code, left README
  • Loading branch information...
1 parent 7446227 commit 0b2a9c72f2d85677c29bcd4ed81296827edd6c7b @apauley committed May 27, 2010
View
3 CodeSnippets/Quine/Erlang/quine.erl
@@ -1,3 +0,0 @@
-main(_) ->
- S = "main(_) ->~n S = ~s~n io:format(S, [[34] ++ S ++ [34, 44]]).~n",
- io:format(S, [[34] ++ S ++ [34, 44]]).
View
0 CodeSnippets/Quine/Python/fakequine-empty.py
No changes.
View
4 CodeSnippets/Quine/Python/fakequine.py
@@ -1,4 +0,0 @@
-filename = 'fakequine.py'
-f = file(filename, 'r')
-print f.read(),
-f.close()
View
5 CodeSnippets/Quine/Python/fakequine2.py
@@ -1,5 +0,0 @@
-import sys
-filename = sys.argv[0]
-f = file(filename, 'r')
-print f.read(),
-f.close()
View
1 CodeSnippets/Quine/Python/notquine
@@ -1 +0,0 @@
-Bleep
View
4 CodeSnippets/Quine/Python/quine.py
@@ -1,4 +0,0 @@
-src = """print 'src = ' + (chr(34) * 3) + src + (chr(34) * 3)
-print 'exec(src)'
-"""
-exec(src)
View
3 CodeSnippets/Quine/Python/quine.rb
@@ -1,3 +0,0 @@
-puts(s = <<e, s, 'e')
-puts(s = <<e, s, 'e')
-e
View
19 CodeSnippets/Quine/Python/test_selfreproducingprogram
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-USAGE="${0} <interpreter> <sourcefile>"
-
-if [ ${#} -lt 2 ]; then
- echo ${USAGE}
- exit 1
-fi
-
-INTERPRETER=${1}
-FILENAME=${2}
-
-if ["`${INTERPRETER} ${FILENAME}`" = "`cat ${FILENAME}`"]; then
- echo 'mooi'
-fi
-
-#$ test "`python myself.py`" = "`python myself.py|python`"; echo $?
-#$ test "`python myself.py`" = "`python myself.py|python|python`"; echo $?
-
View
50 CodeSnippets/Quine/Python/test_selfreproducingprogram.py
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-import sys, subprocess
-
-usage = "%s <interpreter> <filename>" % sys.argv[0]
-try:
- selfrepInterpreter = sys.argv[1]
- selfrepProgram = sys.argv[2]
- selfrepSourceFromFile = file(selfrepProgram, 'r').read()
-except IndexError:
- print usage
- sys.exit(1)
-
-def outputOfSelfReproducingProgram(selfrepSource):
- p = subprocess.Popen([selfrepInterpreter],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- out, err = p.communicate(selfrepSource)
- if err:
- raise RuntimeError("Error when interpreting source")
- return out
-
-def sourceMatchesOutput(selfrepSource, selfrepOutput):
- return outputOfSelfReproducingProgram(selfrepSource) == selfrepOutput
-
-print 'Checking that program is not empty... ',
-if not (selfrepSourceFromFile.strip() == ''):
- print 'passed.'
-else:
- print 'failed.'
-
-print 'Checking that program does not reference its own filename... ',
-if not (selfrepProgram in selfrepSourceFromFile):
- print 'passed.'
-else:
- print 'failed.'
-
-print 'Checking that source matches output... ',
-selfrepOutput = outputOfSelfReproducingProgram(selfrepSourceFromFile)
-if sourceMatchesOutput(selfrepSourceFromFile, selfrepOutput):
- print 'passed.'
-else:
- print 'failed.'
-
-print 'Checking the output of the output... ',
-if sourceMatchesOutput(selfrepOutput, outputOfSelfReproducingProgram(selfrepOutput)):
- print 'passed.'
-else:
- print 'failed.'
View
18 CodeSnippets/SumPairs/SumOfPairs.java
@@ -1,18 +0,0 @@
-// Java solution by Etienne Labuschagne
-// Edited by me to fit in with the other examples
-
-public class SumOfPairs {
- public static int[] sumPairs(int[] a) {
- int[] newArray = new int[a.length-1];
-
- for (int i = 1; i < a.length; i++)
- newArray[i-1] = a[i-1]+a[i];
-
- return newArray;
- }
-
- public static void main(String[] args) {
- int[] a = new int[]{1,2,3,4,5};
- sumPairs(a);
- }
-}
View
11 CodeSnippets/SumPairs/sumpairs-flatmap.scala
@@ -1,11 +0,0 @@
-/**
-Scala solution by Julian Exenberger
-http://dotneverland.blogspot.com/2009/09/quick-sample-of-lists-and-tuples-in.html
-*/
-
-val numbers = List(1,2,3,4,5);
-numbers.zip(numbers.tail).flatMap {
- value => {
- List(value._1+value._2);
- }
-};
View
5 CodeSnippets/SumPairs/sumpairs-map.py
@@ -1,5 +0,0 @@
-# Python solution by Pieter Nagel, based on the Clojure solution
-
-from operator import add
-a = [1, 2, 3, 4, 5]
-map(add, a[1:], a[:-1])
View
10 CodeSnippets/SumPairs/sumpairs-perl.pl
@@ -1,10 +0,0 @@
-use strict;
-use warnings;
-use Data::Dumper;
-
-my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9);
-push @array, 0 if scalar @array % 2;
-my %hash = @array;
-my @sum = map { $hash{$_}+$_ } sort keys %hash;
-
-print Dumper(\@sum);
View
16 CodeSnippets/SumPairs/sumpairs-pointer.c
@@ -1,16 +0,0 @@
-// C solution by Hardy Jonck
-
-#include <stdio.h>
-#include <string.h>
-
-
-int main (int argc, const char * argv[]) {
- int a[] = {1,2,3,4,5};
- char items = sizeof(a)/sizeof(int);
- int b[items];
- int *c=b;
- memcpy(&b,&a,items*sizeof(int));
- while(c < &b[items-1]) { *c = *c + *(c+1);printf("%d\n",*c);c++;}
-
- return 0;
-}
View
2 CodeSnippets/SumPairs/sumpairs-prolog.pl
@@ -1,2 +0,0 @@
-sumpairs([X,Y|T],Out) :- Z is X + Y, sumpairs([Y|T], Tail), append([Z],Tail,Out).
-sumpairs(_,[]).
View
4 CodeSnippets/SumPairs/sumpairs-sumzip.py
@@ -1,4 +0,0 @@
-# Python solution by Dawie Strauss
-
-a = [1, 2, 3, 4, 5]
-[sum(i) for i in zip(a,a[1:])]
View
18 CodeSnippets/SumPairs/sumpairs-zipfold.scala
@@ -1,18 +0,0 @@
-/**
-Scala solution by Julian Exenberger
-http://dotneverland.blogspot.com/2009/09/quick-sample-of-lists-and-tuples-in.html
-*/
-
-object SumPairs extends Application {
-
-val numbers = List(1,2,3,4,5);
-val result = numbers.zip(numbers.tail)
- .foldLeft(List[Int]()) (
- (list, y) => {
- y._1 + y._2 :: list
- }
- )
- .reverse;
-println(result);
-
-}
View
12 CodeSnippets/SumPairs/sumpairs.c
@@ -1,12 +0,0 @@
-// C solution by Hardy Jonck
-
-#include <stdio.h>
-
-int main (int argc, const char * argv[]) {
- int a[] = {1,2,3,4,5};
- int b[sizeof(a)/sizeof(int)-1];
- char x;
- for (x=0; x<sizeof(a)/sizeof(int)-1; x++) { b[x] = a[x]+ a[x+1];printf("%d,",b[x]);}
-
- return 0;
-}
View
5 CodeSnippets/SumPairs/sumpairs.clj
@@ -1,5 +0,0 @@
-; Clojure solution by Timothy Pratley
-; http://groups.google.com/group/clojure/browse_thread/thread/ca3ad049fba7ee82
-
-(def a '(1 2 3 4 5))
-(map + a (rest a))
View
7 CodeSnippets/SumPairs/sumpairs.erl
@@ -1,7 +0,0 @@
-%% Erlang solution by Danie Roux
-
--module(sumpairs).
--export([sumpairs/1]).
-
-sumpairs([X,Y|T]) -> [X+Y | sumpairs([Y|T])];
-sumpairs([_]) -> [].
View
4 CodeSnippets/SumPairs/sumpairs.fx
@@ -1,4 +0,0 @@
-// JavaFX solution by Etienne Labuschagne
-
-var originalArray = [1,2,3,4,5];
-for (i in for (e in [0..3]){originalArray[e]+originalArray[e+1]}){println(i)}
View
4 CodeSnippets/SumPairs/sumpairs.hs
@@ -1,4 +0,0 @@
--- Haskell solution by Danie Roux
-
-a = [1, 2, 3, 4, 5]
-main = print (zipWith (+) a (tail a))
View
4 CodeSnippets/SumPairs/sumpairs.lisp
@@ -1,4 +0,0 @@
-; Common Lisp solution by Andreas Pauley
-
-(defvar a '(1 2 3 4 5))
-(mapcar #'+ a (cdr a))
View
4 CodeSnippets/SumPairs/sumpairs.scm
@@ -1,4 +0,0 @@
-; Scheme solution by Andreas Pauley
-
-(define a '(1 2 3 4 5))
-(map + (cdr a) (reverse (cdr (reverse a))))
View
13 CodeSnippets/SumPairs/sumpairs.sql
@@ -1,13 +0,0 @@
--- SQL solution by Dawie Strauss
-
-CREATE TABLE notfib ( item INT );
-INSERT INTO notfib VALUES (1);
-INSERT INTO notfib VALUES (2);
-INSERT INTO notfib VALUES (3);
-INSERT INTO notfib VALUES (4);
-INSERT INTO notfib VALUES (5);
-SELECT nf1.item + nf2.item AS total
-FROM notfib AS nf1, notfib AS nf2
-WHERE nf1.item = (nf2.item - 1)
-ORDER BY nf1.item;
-DROP TABLE notfib;

0 comments on commit 0b2a9c7

Please sign in to comment.