Skip to content

Instantly share code, notes, and snippets.

View alphaKAI's full-sized avatar

Akihiro Shoji alphaKAI

View GitHub Profile
@alphaKAI
alphaKAI / test.d
Last active August 29, 2015 14:17
D言語で部分適用してみた
import std.stdio;
void func(int x, int y, int z){
writeln("function");
writeln("x, y, z : ", x, ",", y, ",", z);
}
void main(){
auto fxy = ((int x) => (int y) => func(1, x, y));
auto fx = fxy(2);
@alphaKAI
alphaKAI / spring.txt
Created March 8, 2015 15:28
春 - ポエムっぽい何か。
囁く春の息吹に耳を澄ませば、こだまする泡が聞こえる。
その穴には新しく芽吹いた生き物の生と、老いた生き物の死がその小さな殻に込められている。
泡が弾ける時、死に生まれる。悠久の時の中で、幾重にもこの積み重なりが積み上がっていく。ああ、諸行無常。
不変的なものなど無いが、不変的なものに美を見出す。これは憧れなのだろうか。
それとも、嫉妬なのか。いずれにしても、春の朝の燦々たる清々しい陽日を前にしては塵に等しい。
無為自然の美。これに尽きるのだろう。
さあ、歩もうか泡が弾けるその時まで。
@alphaKAI
alphaKAI / error.log
Created March 8, 2015 13:06
sinkuu/manakasi error log. Environment: OS X 10.10.2, mecab of 0.996, DMD64 D Compiler v2.066, manakasi : commit e88e9d6b0b8bb7979a873639ec051a713ad51f5e
Building manakasi ~master configuration "library", build type debug.
Running dmd...
Building example ~master configuration "application", build type debug.
Compiling using dmd...
Linking...
Undefined symbols for architecture x86_64:
"_mecab_lattice_add_request_type", referenced from:
_D8manakasi5mecab5Mecab22__T12parseToBestsTAyaZ12parseToBestsMFxAyamZ5Bests6__ctorMFNbNcC8manakasi5mecab5MecabAyamZS8manakasi5mecab5Mecab22__T12parseToBestsTAyaZ12parseToBestsMFxAyamZ5Bests in example.o
"_mecab_lattice_destroy", referenced from:
_D8manakasi5mecab5Mecab22__T12parseToBestsTAyaZ12parseToBestsMFxAyamZ5Bests6__dtorMFNbNiZv in example.o
@alphaKAI
alphaKAI / fx.d
Created March 8, 2015 02:33
グローバルなラムダでメタプログラミング的なものをやってみた図
import std.stdio,
std.array,
std.range;
auto x = (int[] arr) pure nothrow @nogc @safe { return ++arr[0] * 2; };
int[] fx(int[] xss){ return xss.length ? x(xss) ~ fx(xss[1..$]) : xss; }
void main(){
writeln(fx(100.iota.array));
@alphaKAI
alphaKAI / dream.txt
Created March 4, 2015 11:13
夢 - 随想を書こうとしたらこう(ポエムっぽく?)なった。
追えば追うほどその遠さを凍てつくような現実として、見せつけて。立ち止まればその分だけ遠のいてゆく。
果たして、夢を追いかけた結果として得られた夢は本当に自分が追い求めていた夢なのだろうか。
途中で入れ替わってはいないだろうか、見失っていないだろうか、それはわからない。
逃げることもできず、ただ無情にも時間だけが過ぎ行く。まるで、ブレーキのない自転車で急坂を下るように。
人はなぜ前を向いて夢を追いかけ歩いて行くのか、はたしてその目的とはなんなのであろうか。
おそらく、これに対する模範解答的な答えとしては、生きていくため、人間であるがゆえ、
家族のためなどというものが挙げられると思うが、ここで一つ疑問を提起しよう。
それは、なぜ生きるのか、である。どうして生存本能というものがあるのだろうか、そして欲求が生まれるのだろうか。
@alphaKAI
alphaKAI / parallelFizzbuzz.d
Created February 9, 2015 16:48
昨日の再帰FizzBuzzをマルチスレッドで実行する奴。 fizzbuzzOrderで求めたいfizzbuzzの最後の値を指定し、bitSizeで1スレッドでの計算数を指定できる。
import std.conv,
std.stdio,
std.range,
std.algorithm;
import core.thread;
string[] fizzbuzz(int max, int i = 0, string[] base = null){
return max == 0 ? base : fizzbuzz(max - 1, ++i, base ~ {
return !(i % 15) ? "FizzBuzz" :
!(i % 3) ? "Fizz" :
@alphaKAI
alphaKAI / fizzbuzz.d
Created February 8, 2015 16:22
D言語で再帰使ってFizzBuzz
import std.stdio,
std.conv,
std.algorithm;
string[] fizzbuzz(int max, int i = 0, string[] base = null){
return max == 0 ? base : fizzbuzz(max - 1, ++i, base ~ {
return !(i % 15) ? "FizzBuzz" :
!(i % 3) ? "Fizz" :
!(i % 5) ? "Buzz" : i.to!string;
}());
@alphaKAI
alphaKAI / mapper.d
Created January 18, 2015 04:48
RangeよくわからないからInputRange使ってMapみたいなの作ろうとした結果・・・
import std.algorithm,
std.stdio,
std.conv;
void main(){
int fact(int n){
return n == 1 ? 1 : n * fact(n - 1);
}
auto mapper = Maper!(int delegate(int), int)(&fact, [1, 2, 3, 4, 5]);
@alphaKAI
alphaKAI / twitnotify.d
Created January 12, 2015 14:29
Twitter Notification tool, twitnotify for mac (original: https://github.com/alphaKAI/twitnotify this program require https://github.com/alloy/terminal-notifier)
/*
TwitNotify
The Twitter Notification tool.
Copyright (C) 2014-2015 alphaKAI http://alpha-kai-net.info
The MIT License
using : My Twitter API Wrapper Twitter4D(twitter4d.d)
Twitter4D's Repository : https://github.com/alphaKAI/twitter4d
@alphaKAI
alphaKAI / app.d
Last active August 29, 2015 14:12
D言語でマルコフ連鎖を用いて文章生成させるプログラム。(可変次数) MeCabとmanakasi(https://github.com/sinkuu/manakasi/)を使っています. output.txtは青空文庫の走れメロス(一部改変)を読み込ませた結果の例です
module app;
import std.algorithm,
std.string,
std.random,
std.stdio,
std.range,
std.file;
import manakasi.mecab;
class Markov{