Skip to content

Instantly share code, notes, and snippets.

@splinterofchaos
splinterofchaos / ConAbRanSeq.lisp
Created May 27, 2012 01:18
A test taker for a test that tries whether you think concretely or abstractly, randomly or sequentialy.
#! /usr/bin/clisp
;;; A tester for http://www.thelearningweb.net/personalthink.html
;; It tests you thinking style in terms of concrete or abstract,
;; random or sequencial. If you plug your answers into this test,
;; (run with no arguments) it will generate a file, results.dat.
;; You can create a gnuplot graph with that by running
;; "gnuplot -persist plot.gnu".
(defun args()
@splinterofchaos
splinterofchaos / mapgen.hs
Created June 5, 2012 12:57
A simple roguelike map generator. Uses naiive splatter pattern to create rooms.
import System.Random
import System.Console.GetOpt
import System.Environment(getArgs, getProgName)
type Coord = (Int,Int)
type Range = (Int,Int)
type Area = (Coord,Coord) -- Upper-left and lower-right bounds.
@splinterofchaos
splinterofchaos / pure-test.cpp
Created July 18, 2012 14:24
Pure.h use-case
#include <functional>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <iterator>
using namespace std;
@splinterofchaos
splinterofchaos / fmap.cpp
Created October 26, 2012 18:02
Fmap in C++
#include <memory>
#include <utility>
#include <iostream>
#include <algorithm>
#include <iterator>
struct sequence_tag {};
struct pointer_tag {};
template< class X >
#include <memory>
#include <iostream>
#include <utility>
#include <algorithm>
#include <iterator>
struct sequence_tag {};
struct pointer_tag {};
#include <memory>
#include <iostream>
#include <sstream>
#include <utility>
#include <algorithm>
#include <iterator>
struct sequence_tag {};
struct pointer_tag {};
.file "func-effic.cpp"
# GNU C++ (Ubuntu/Linaro 4.7.2-4precise1) version 4.7.2 (x86_64-linux-gnu)
# compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
# GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
# options passed: -imultiarch x86_64-linux-gnu -D_GNU_SOURCE
# func-effic.cpp -mtune=generic -march=x86-64 -O4 -std=c++11 -fverbose-asm
# -fstack-protector
# options enabled: -fasynchronous-unwind-tables -fauto-inc-dec
# -fbranch-count-reg -fcaller-saves -fcombine-stack-adjustments -fcommon
# -fcompare-elim -fcprop-registers -fcrossjumping -fcse-follow-jumps
@splinterofchaos
splinterofchaos / binary-function.cpp
Created November 6, 2012 13:14
Rethinking std::binary_function
#include <memory>
#include <iostream>
#include <sstream>
#include <utility>
#include <algorithm>
#include <iterator>
template<class...> struct Part;
@splinterofchaos
splinterofchaos / constructChainable.cpp
Created November 10, 2012 04:47
Construct Chainable -- A demonstration of a left-associative type constructor.
#include <utility>
#include <iostream>
// http://en.cppreference.com/w/cpp/types/decay
template< class X >
using Decay = typename std::decay<X>::type;
// ConstructBinary<T>(X,Y) = T<X,Y>
template< template<class...> class X >
struct ConstructBinary {
@splinterofchaos
splinterofchaos / gist:4055136
Created November 11, 2012 14:56
Transitivity and Associativity.
#include <utility>
using std::forward;
using std::declval;
using std::move;
template< class F, class X >
struct Part {
F f;
X x;