Skip to content

Instantly share code, notes, and snippets.

(function buildReader() {
var Record = function () {
this.transforms = undefined
};
Record.geometry_msgs_TransformStamped = function() {
this.header = undefined;
this.child_frame_id = undefined;
this.transform = undefined
};
(function buildReader() {
var Record = function (reader) {
var length_transforms = reader.uint32();
this.transforms = new Array(length_transforms)
for (var i = 0; i < length_transforms; i++) {
this.transforms[i] = new Record.geometry_msgs_TransformStamped(reader);
}
};
Record.geometry_msgs_TransformStamped = function(reader) {
@MatthewSteel
MatthewSteel / ttt.c
Created July 22, 2012 05:35
Minimax (full tree search) tic-tac-toe AI in C
//Tic-tac-toe playing AI. Exhaustive tree-search. WTFPL
//Matthew Steel 2009, www.www.repsilat.com
#include <stdio.h>
char gridChar(int i) {
switch(i) {
case -1:
return 'X';
case 0:
@MatthewSteel
MatthewSteel / Zipper.cpp
Created June 24, 2012 12:09
A lazy zipper in C++11. Written before I heard about all of the LINQ-like libs coming out. Good demonstration of how nice Haskell can be...
#include <iostream>
#include <vector>
#include <tuple>
/*
* Roughly equivalent to the following two lines of Haskell:
* zip (x:xs) (y:ys) = (x,y) : zip xs ys
* zip xs ys = []
*/
@MatthewSteel
MatthewSteel / TupleForEach2.cpp
Created June 24, 2012 12:00
Almost proper for-each algorithm for tuples in C++11. Works with the STL, everything type-checked, sadly uses heap data and inheritance, homogeneous data only.
#include <tuple>
#include <iostream>
#include <type_traits>
#include <memory>
#include <stdexcept>
#include <algorithm>
/*
* Before beginning: This is so stupid. Turning homogeneous tuples into STL-
* compatible containers using inheritance... No part of this is a good idea.
@MatthewSteel
MatthewSteel / TupleForEach.cpp
Created June 24, 2012 10:02
A "proper" for-each algorithm for tuples in C++11. Everything type-checked, no virtual function calls, heterogeneous data works.
#include <tuple>
#include <iostream>
#include <stdexcept>
using namespace std;
/*
* "A partially specialized non-type argument expression shall not involve a
* template parameter of the partial specialization except when the argument
* expression is a simple identifier."