Skip to content

Instantly share code, notes, and snippets.

View alphaKAI's full-sized avatar

Akihiro Shoji alphaKAI

View GitHub Profile
@alphaKAI
alphaKAI / tinyBrainfuck.d
Last active February 26, 2016 11:38
An one-line Brainfuck interpreter in D.
import std.algorithm,
std.string,
std.array,
std.stdio,
std.conv;
import core.memory;
/*
Useing raw pointer and manually memory manegement for perfourmance.
D's dynamic array is very useful but a litle slower but safe.
@alphaKAI
alphaKAI / immutableAndConst.d
Last active February 5, 2016 17:17
Immutable と constの簡単な違い
import std.stdio;
void immutableTest() {
immutable int N = 10;//変更不可能
immutable int* ptr = &N;//変更不可能なポインタ
//ptr = &N;当然不可能
// このコードは動かない
// immutableなポインタはimmutableな変数しかとれない
@alphaKAI
alphaKAI / pe3_omit_type.d
Last active January 30, 2016 09:59
Project Euler - Problem 3 in D
import std.algorithm,
std.random,
std.range,
std.stdio;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
}
void main() {
@alphaKAI
alphaKAI / pe3.d
Last active January 30, 2016 09:53
Project Euler - Problem 3 in D
import std.algorithm,
std.random,
std.range,
std.stdio;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
}
void main() {
@alphaKAI
alphaKAI / forTemplate.d
Last active January 4, 2016 15:05
D言語でTemplate Meta Programmingを駆使して書いた、任意の深さのnested forを生成するテンプレート
import std.stdio;
template FOR(alias func, alias cond) {
import std.algorithm,
std.traits,
std.range,
std.conv;
void FOR() {
immutable lambdaStr = (lamArgs =>
import std.stdio,
std.typetuple;
alias TypeTuple!(
byte, ubyte, short,
ushort, int, uint, long,
ulong, float, double, real) primitiveTypes;
Caluculatable!T newCaluculatable(T)(T v){
return Caluculatable!T(v);
@alphaKAI
alphaKAI / ifExpression.d
Created December 20, 2015 09:10
ifExpression for D language
// ifExpression for D language
template IF(alias condition){
import std.traits;
//IF!(condition) -> Return : bool
auto IF(){
return condition;
}
auto IF(T, F)(T trueExpression, F falseExpression){
@alphaKAI
alphaKAI / README.md
Last active October 17, 2015 10:15
The 2048 written in D.

#D2048 The 2048 written in D.

##How to use

  1. Place file as follow:
d2048Root/
 |-source/
@alphaKAI
alphaKAI / docomo4d.d
Last active October 12, 2015 09:26
DocomoのAPIラッパーをD言語で書こうと思ってとりあえず書いてみた,対話APIと対話できるプログラム。API Keyを書き換えれば動きます。
import std.net.curl,
std.algorithm.iteration,
std.string,
std.base64,
std.json,
std.conv;
import std.stdio;
class TaiwaService{
@alphaKAI
alphaKAI / instanceSharing.ts
Created September 13, 2015 16:43
TypeScriptでインスタンスを共有する
class Test1{
varStr: string;
constructor(){
this.varStr = "ABC";
}
}
class Test2{
private t1: Test1;