This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t len = strlen((char*)str) + 1; | |
utf8char *buf = new utf8char[len]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 1; i <= 12; i++) | |
for (int j = 1; j <= 12; j++) | |
std::cout << setw(4) << i*j; | |
std::cout << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////// | |
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import itertools | |
import praw | |
import time | |
# maximum 1000 | |
SUBMISSION_LIMIT = 100 | |
def flatten(it): | |
for x in it: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Super { | |
virtual Super* id() { | |
return this; | |
} | |
}; | |
struct X : Super {}; | |
struct Y : Super {}; | |
template <typename A> |