Skip to content

Instantly share code, notes, and snippets.

View milesrout's full-sized avatar

Miles Rout milesrout

View GitHub Profile
template< class T > struct is_pointer_helper : std::false_type {};
template< class T > struct is_pointer_helper<T*> : std::true_type {};
template< class T > struct is_pointer : is_pointer_helper<typename std::remove_cv<T>::type> {};
size_t len = strlen((char*)str) + 1;
utf8char *buf = new utf8char[len];
for (int i = 1; i <= 12; i++)
for (int j = 1; j <= 12; j++)
std::cout << setw(4) << i*j;
std::cout << std::endl;
///////////////////////////////////////////////////////
// f - function
// (f x) - (partially) apply the argument x to f
// ((f x) y) - apply the arguments x and y to f
// f - function
// f::of<x> - (partially) apply the argument x to f
// f::of<x>::of<y> - apply the arguments x and y to f
#include <iostream>
#include <type_traits>
using namespace std;
#define ALVIN_SASSERT_IS_SAME(actual, expected) static_assert(std::is_same<actual, expected>::value, "Expected " #expected ", got " #actual ".");
struct Type {};
struct Function {
template <typename T>
set([u'magicschoolbuscrash', u'RationalMayhem', u'Vimda', u'mcilrain', u'ljcrabs', u'gringer', u'toomanybeersies', u'SirChristoffee', u'wesley_wyndam_pryce', u'rifter5000', u'Portadiam', u'smellyegg', u'DirectImageLinkerBot', u'IWantUsToMerge', u'sobri909', u'back-stabbath', u'naturalethic', u'presidentchimp', u'KhyronVorrac', u'holloway', u'yacob_uk', u'Throwaway_Kiwi', u'some_arab', u'bbqroast', u'WasterDave', u'hexasquid', u'SCombinator'])
import collections
import itertools
import praw
import time
# maximum 1000
SUBMISSION_LIMIT = 100
def flatten(it):
for x in it:
namespace std {
using numeric_range = struct { min,max,stride: int };
// provide an implementation of the Range concept for numeric_range
impl Range<numeric_range> {
using iterator = struct { min,stride: int };
using sentinel = struct { max: int };
let begin(nr: numeric_range) => iterator{nr.min, nr.stride};
let end(nr: numeric_range) => sentinel{nr.max};
@milesrout
milesrout / 1.hs
Last active August 29, 2015 14:21
-- you can call a function like `map` with a function and a list of integers, e.g.
map (+1) [0,1,2] --> [1,2,3]
-- or on a list of strings
map (++", world!") ["Hello","Goodbye"] --> ["Hello, world!","Goodbye, world!"]
-- question: can we use this function on any type, or just built in types?
-- `map` has this type signature:
map :: (a -> b) -> [a] -> [b]
struct Super {
virtual Super* id() {
return this;
}
};
struct X : Super {};
struct Y : Super {};
template <typename A>