puts("hello, world");
だけで実行できます(コマンドラインから「prompt>ecrun hello.c」とするだけで)。prompt>1ec "puts('hello, world')"
ってできるようにしました。1ecというコンソールアプリは、第一引数の内容に対してシングルクォーテーションをダブルクォーテーションに置換して、末尾にセミコロンを付与して、その内容の前後に上記のコードを足してtmp.cを作って・・・以下同文のやつです(「末尾のセミコロン付与」は、少しでもキータイプ量を減らそうという、怠け者の発想です)。prompt>1ec "int i, j; for (j = 1; j <= 9; j++) { for (i = 1; i <= 9; i++) printf('%3d', i * j); printf('\n'); }"
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81prompt>1ec "printf('%d', sizeof (long double))"
12
prompt>1ec "pr(1+2+3)"ってやるだけで、答えが出るようになりました。今まではprintfって6文字も書かされていましたし、'%d'も面倒でした。
#define pr(i) printf("%d", i)
#define prf(f) printf("%f", f)
#define prs(s) printf("%s", s)
#define prsp() printf(" ")
#define prlf() printf("\n")
#define go(l) goto lprompt>1ec "prf(pow(27,1.0/3))" 3.000000
prompt>1ec "pr 1*2*3*4" 24 prompt>1ec "prf sqrt(256)" 16.000000ができるようになりました。カッコが省略できるようになっただけなのですが、これは小学生だけではなく私にも便利です!
1ec>pr 12*34 408 1ec>prs "hello\n" hello 1ec>int c; for (c = 0; c < 10; c++) pr c 0123456789 1ec>
1ec>shell gcc -O3 -Wl,-s -o test.exe test.c 1ec>shell test.exeなどとやっています。すごく便利で楽しいです。この楽しさが伝わるでしょうか。
1ec>for (j = 1; j <= 9; j++) { for (i = 1; i <= 9; i++) printf("%3d", i * j); prlf; }
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 811ec>AWin *w = aOpenWin(256, 256, "graphics"); for (j = 0; j < 256; j++) for (i = 0; i < 256; i++) aSetPix(w, i, j, aRgb8(j, i, 0))

1ec>AWin *w = aOpenWin(256, 256, "graphics"); for (j = 0; j < 8; j++) for (i = 0; i < 8; i++) aFillRect(w, 32, 32, i * 32, j * 32, ((i ^ j) & 1) * 0xffff00)

1ec>AWin *w = aOpenWin(256, 256, "graphics"); aSetMode(w, AWinMode_Xor); for (i = 0; i < 256; i++) { aDrawLine(w, 0, 0, i, 255, 0x00ffff); aDrawLine(w, i, 0, 255, 255, 0x00ffff); }

1ec>AWin *w = aOpenWin(256, 256, "graphics"); for (i = 24; i < 128; i++) { j = 127 - i; aFillOvalCent(w, 128, 128, j, j, 0x020202 * i); }

1ec>AWin *w = aOpenWin(384, 256, "hinomaru"); aFillRect(w, 384, 256, 0, 0, 0xf8f8f8); aFillOvalCent(w, 192, 128, 77, 77, 0xff0000)

1ec>AWin *w = aOpenWin(256, 256, "xor"); for (j = 0; j < 256; j++) for (i = 0; i < 256; i++) aSetPix(w, i, j, 0x010101 * (i ^ j))

1 GSCREEN(G_AUTOMODE); GSETOFFSET(320,240); GSETSCALE(4,2) 2 R=0.0 3 .MAINLOOP; GCLEAR(G_BLACK); R -= 0.1 4 LOOP X0, 40, -20; LOOP Y0, 40, -20; X1 = X0 + 1; Y1 = Y0 + 1 5 (D0, D1, D2) = SQRT(X0*X0+Y0*Y0, X1*X1+Y0*Y0, X0*X0+Y1*Y1) 6 (Z0, Z1, Z2) = SIN(R+D0, R+D1, R+D2) * (50/(D0+5),50/(D1+5),50/(D2+5)) 7 GLINE(X0*2-Y0*2, X0*2+Y0*2+Z0, X1*2-Y0*2, X1*2+Y0*2+Z1, G_CYAN) 8 GLINE(X0*2-Y0*2, X0*2+Y0*2+Z0, X0*2-Y1*2, X0*2+Y1*2+Z2, G_CYAN) 9 LOOPEND Y0; LOOPEND X0 10 GFLUSH(); WAIT 1; GOTO MAINLOOP
AWin *w = aOpenWin(640, 480, "3dwave")
int r, x, y, gx[42][42], gy[42][42]
for (r = 0; w->phase != 2; r--) { // ウィンドウが閉じられるまでループ.
aFillRect(w, 640, 480, 0, 0, 0x000000)
for (y = -20; y <= 21; y++)
for (x = -20; x <= 21; x++) {
float d = sqrt(x * x + y * y), z = sin(r * 0.1 + d) * 50 / (d + 5)
int x0 = x + 19, y0 = y + 19, x1 = x + 20, y1 = y + 20
gx[y1][x1] = (x * 2 - y * 2 + z * 0) * 4 + 320
gy[y1][x1] = (x * 2 + y * 2 + z * 1) * 2 + 240
if (x0 < 0 || y0 < 0) continue;
aDrawLine(w, gx[y0][x0], gy[y0][x0], gx[y0][x1], gy[y0][x1], 0x00ffff)
aDrawLine(w, gx[y0][x0], gy[y0][x0], gx[y1][x0], gy[y1][x0], 0x00ffff)
}
aWait(8)
}

1ec>run 3dwave.cとします。
| コメント | お名前 | NameLink | |