C++のテンプレートメタプログラミングライブラリ「Boost.MPL」について勉強中.新しいものを勉強する時はとりあえずそれを使ってBrainf*ckのインタプリタを作るのが学習法の定石なので,早速Boost.MPLを使ってBrainf*ckのインタプリタを書いた. ソース コンパイル中にBrainf*ckが実行される. mpl_brainfuck.cc #include <iostream> // change this parameter according to the length of your program #define BOOST_MPL_LIMIT_STRING_SIZE 128 #include <boost/mpl/at.hpp> #include <boost/mpl/comparison.hpp> #include <boost/mpl/erase.hpp> #
I did know about the twIP, a very small IP stack that can only respond to pings and also fit in a tweet, but recently I tried to execute the idea of making small and still usable things like that. Well, I ended up with a slightly large program than a tweet, but it fits in two lines, i.e. 160 bytes. Let me introduce the world’s smallest Brainfuck interpreter1 in C: (Gist) Test it yourself! For exam
Brainf*ck はチューリング完全らしいですよ。 Brainf*ck 自体に興味のある方は、Brainf*ck や Brainfuck - Wikipedia へどうぞ。 WITH -- 入力 Input(id, bf_program, stdin) AS ( -- Hello, World!と標準出力に出力するプログラム SELECT 0, ' >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++ ++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]> ++++++++[<++++>-]<+.[-]++++++++++.', '' -- hogeと標準出力に出力するプログラム UNION ALL
Cプリプロセッサ上で実装されたBrainfuckインタプリタです。 $ cat hello.txt # include "bfi.h" BFI_RUN1(x x x x x x x x x (b x x x x x x x x b x x x x x x x x x x x b x x x x x d d d _) b w b x x w x x x x x x x w w x x x w b _ w _ _ _ _ _ _ _ _ _ _ _ _ w d x x x x x x x x w _ _ _ _ _ _ _ _ w x x x w _ _ _ _ _ _ w _ _ _ _ _ _ _ _ w b x w) $ cpp -P hello.txt Hello, world! bfi-0.tar.gz 使い方 "bfi.h"で定義されているBFI_RUNマクロがインタプリタの本体で
先日、「はてなFizzBuzzグループ」に入って、さっそくvimのFizzBuzzを書いたのですが... 2010-03-04 - mattnの日記 - fizzbuzzグループ for v in range(1,100)|ec v%15?v%3?v%5?v :"Buzz":"Fizz":"FizzBuzz"|endfo http://fizzbuzz.g.hatena.ne.jp/mattn/20100304 数日後にid:tyruさんにgolfで抜かされた! Vim script - id:tyruが毎日FizzBuzzを一生懸命書く日記 - fizzbuzzグループ for i in range(1,100)|ec[[i,"Buzz"],["Fizz","FizzBuzz"]][i%3<1][i%5<1]|endfo http://fizzbuzz.g.hatena.ne.jp/ty
まず、世界中のプログラマが誰でも一番最初に作るであろう「Hello, world!」を標準出力に表示するプログラムを書いてみましょう。 C言語 2006-12-19 char main[]= "QVWUZ%@@@@% P^JJJJJJJJJJJJJJJJJJJJJJJJ3B PVXH, PTXHHHH!0Z_18R_)8)8)8)8" ")8)8)8)8WV_38WX_)8)8)8@)8@@@@)8)8)8T_VXOOOOOOOOOOOOOOOOOOOOOOOOWYVX!75Hel" "lVP^17^GGGGVX!75o, wVP^17^GGGGVX!75orldVP^17^GGGGVX!75aJ@@5@@@@VP^17^VXP[" "PZBBBBBBBBBBBBBBC@@@@AHI@AHI@AHI@AHI@AHI@AHI@j__^Y`"; このプログラムを hello.c という名前で保
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く