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
// tslint:disable | |
/* | |
* Generated by PEG.js 0.10.0. | |
* | |
* http://pegjs.org/ | |
*/ | |
"use strict"; | |
function peg$subclass(child, parent) { |
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
// With gcc 7+ or clang 5+, compiles with -std=c++17 flag | |
#include <iostream> | |
#include <variant> | |
#include <vector> | |
struct toffoli_gate { | |
uint32_t c0, c1, x; | |
toffoli_gate(uint32_t c0_, uint32_t c1_, uint32_t x_) noexcept | |
: c0(c0_), c1(c1_), x(x_) { |
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
// With gcc 7+ or clang 5+, compiles with -std=c++17 flag | |
#include <iostream> | |
#include <memory> | |
#include <vector> | |
// Base class for gates: | |
struct gate { | |
virtual void apply(std::vector<bool>& bits) const = 0; | |
virtual std::ostream& print(std::ostream&) const = 0; |
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 <map> | |
#include <unordered_map> | |
template<typename Key, typename Value> | |
using stdmap = std::map<Key, Value>; | |
template<typename Key, typename Value> | |
using stdumap = std::unordered_map<Key, Value>; |
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
#define USE_ROBIN_HOOD_HASH 1 | |
#define USE_SEPARATE_HASH_ARRAY 1 | |
template<class Key, class Value> | |
class hash_table | |
{ | |
static const int INITIAL_SIZE = 256; | |
static const int LOAD_FACTOR_PERCENT = 90; | |
struct elem |
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
{ | |
function getTerms(t, ts) { | |
if (t) { | |
var arr = []; | |
for (var i = 0; i < ts.length; ++i) { | |
arr.push(ts[i][2]); | |
} | |
return [t].concat(arr); | |
} | |
return []; |
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
#ifndef EXPRESSION_HH__ | |
#define EXPRESSION_HH__ | |
#include <iostream> | |
#include <string> | |
#include <boost/variant.hpp> | |
#include <boost/lexical_cast.hpp> | |
namespace reasoning { |
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
// clang++ -std=c++11 permutations.cc -o permutations | |
#include <iostream> | |
#include <ostream> | |
#include <set> | |
#include <vector> | |
template<typename T> | |
auto operator<<(std::ostream &os, const std::set<T> &xs) -> std::ostream& { | |
os << '{'; |
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
#load "packages/FsLab/FsLab.fsx" | |
open FSharp.Data | |
open XPlot.GoogleCharts | |
let bondUrl = "https://en.wikipedia.org/w/index.php?title=List_of_James_Bond_films&oldid=688916363" | |
type BondProvider = HtmlProvider<"https://en.wikipedia.org/w/index.php?title=List_of_James_Bond_films&oldid=688916363"> | |
let bondWiki = BondProvider.Load(bondUrl) |
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
// clang++ -std=c++11 safe_sqrt.cc | |
#include <iostream> | |
#include <cmath> | |
#include <boost/optional.hpp> | |
auto safe_sqrt(double x) -> boost::optional<double> { | |
if (x >= 0.0) | |
return std::sqrt(x); | |
return boost::none; |