Skip to content

Instantly share code, notes, and snippets.

View marionette-of-u's full-sized avatar

arithmeticae marionette-of-u

View GitHub Profile
@marionette-of-u
marionette-of-u / 1.txt
Last active August 29, 2015 14:05
TRS-比較.txt
f(X1,0) -> X1)
f(X1,i(X1)) -> 0)
f(f(X1,X2),X3) -> f(X1,f(X2,X3)))
f(0,X1) -> X1)
i(0) -> 0)
i(i(X1)) -> X1)
f(i(X1),X1) -> 0)
f(X1,f(i(X1),X2)) -> X2)
f(i(X1),f(X1,X2)) -> X2)
i(f(X1,X2)) -> f(i(X2),i(X1))

機能

Copying GC が何なのか, という事については authorNari さんの記述や pasberth さんの記述に任せるとして, ここでは満たすべき機能を記述したいと思います.

(1) プログラマの記述した型に適合した heap から allocate してくる.

    // int に適合した heap を適当に 256 用意する.
    memory_manager<int> manager(256);
    // ここで allocate する.
    int *x = manager.alloc(10);
#include <string>
#include <memory>
#include <exception>
#include <type_traits>
#include <cstdint>
#include <cctype>
#include <cstddef>
#include <cstdlib>
#include <cstdio>
#include <cstring>
@marionette-of-u
marionette-of-u / integer.hpp
Last active August 29, 2015 14:01
integer (multi-precision).
#ifndef MULTI_PRECISION_INCLUDE_INTEGER_HPP
#define MULTI_PRECISION_INCLUDE_INTEGER_HPP
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <iterator>
#include <utility>
#include <random>
@marionette-of-u
marionette-of-u / enum_prime_number.cpp
Last active August 29, 2015 14:01
enum_prime_number.cpp
#include <algorithm>
#include <vector>
#include <deque>
#include <iostream>
#include <utility>
#include <limits>
#include <array>
#include <functional>
#include <cstdint>
#include <cmath>
@marionette-of-u
marionette-of-u / multi_precision_integer.cpp
Created May 8, 2014 01:34
160行で分かる(可能性がある)!多倍精度整数演算!
#include <iostream>
#include <cstdint>
#include <cmath>
namespace delta_zero{
namespace impl{
// primitive quadriplegic integer.
template<class UInt = std::uint32_t, class DoubleUInt = std::uint64_t, class DoubleInt = std::int64_t, DoubleUInt BitNum = sizeof(UInt) * 8>
struct quint{
template<DoubleUInt Count>
@marionette-of-u
marionette-of-u / popen2.cpp
Created April 30, 2014 16:54
popen2は新しくプログラムを起動してその入出力を奪う。どこかのサイトからのこぴぺなんだけど失念してしまいました。
#include <unistd.h>
#include <netdb.h>
#include <dirent.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <iostream>
#include <string>
int main(){
using namespace mll;
// variant.
// template arguments で与えられたどれかの型の変数を保持.
{
mll::variant<int, std::string> v;
#include <fstream>
#include <functional>
#include <thread>
#include <memory>
#include <iostream>
int main(){
std::ofstream ofile("bfe.hpp");
std::size_t size = 5;
const char pattern_array[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_' };
struct echo_server : public keisan_kun::http_server<>{
using base_type = keisan_kun::http_server<>;
bool proc(stream &s){
std::string str;
s >> str;
s << str;
return false;
}
};