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 <string> | |
#include <memory> | |
#include <unordered_set> | |
#include <unordered_map> | |
#include <boost/functional/hash.hpp> | |
class my_class { | |
std::string m_name; |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
auto member_of(const std::vector<char> &cs) { | |
return [=](const char c) -> bool { | |
for (const char &x : cs) if (c == x) return true; | |
return false; | |
}; | |
}; |
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 <string> | |
#include <memory> | |
#include <set> | |
#include <boost/variant.hpp> | |
#include <format.h> | |
// Selection of symbols | |
/** A set of symbols for printing / parsing formula. */ |
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
(use '[clojure.core.match :only [match]]) | |
(defn evaluate [env [sym x y]] | |
(match [sym] | |
['Number] x | |
['Add] (+ (evaluate env x) (evaluate env y)) | |
['Multiply] (* (evaluate env x) (evaluate env y)) | |
['Variable] (env x))) | |
(def environment {"a" 3, "b" 4, "c" 5}) |
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
sealed abstract class Expr | |
case class Variable(name: String) extends Expr | |
case class Const(value: Int) extends Expr | |
case class Add(left: Expr, right: Expr) extends Expr | |
case class Mult(left: Expr, right: Expr) extends Expr | |
object Simplify { | |
def one(e: Expr): Expr = e match { | |
case Add(Const(0), r) => r | |
case Add(l, Const(0)) => l |
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 <string> | |
#include <boost/variant.hpp> | |
struct Add; | |
struct Mult; | |
using Expr = boost::variant<int, std::string, boost::recursive_wrapper<Add>, | |
boost::recursive_wrapper<Mult>>; |
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
abstract Expr | |
type Const <: Expr; value::Int end | |
type Var <: Expr; name::String end | |
type Add <: Expr; left::Expr; right::Expr end | |
type Mult <: Expr; left::Expr; right::Expr end | |
add(x::Const, y::Const) = Const(x.value + y.value) | |
add(x::Const, y::Expr) = x.value == 0? y : Add(x, y) | |
add(x::Expr, y::Const) = add(y, 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
data Expr = | |
Var String | |
| Const Int | |
| Add Expr Expr | |
| Mult Expr Expr | |
simplify1 :: Expr -> Expr | |
simplify1 e = case e of | |
Add (Const 0) x -> x | |
Add x (Const 0) -> 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
Section "Device" | |
Identifier "nvidia" | |
Driver "nvidia" | |
Option "NoLogo" "true" | |
Option "DPI" "96 x 96" | |
# Specify Nvidia PCI device | |
BusID "PCI:1:0:0" | |
# Make sure X starts also when no outputs are connected to the Nvidia chip | |
Option "AllowEmptyInitialConfiguration" | |
EndSection |