Skip to content

Instantly share code, notes, and snippets.

@sinfu
sinfu / gist:657669
Created November 1, 2010 05:27
Sealed Rangeの件

Sealed Rangeには「安いコピコン」という前提が必須

Sealed Range

要素が参照になっていないけども,代入プロパティは存在するようなrange. コンテナにくっついているものが前提.

struct SealedRange

{

@sinfu
sinfu / gist:655725
Created October 30, 2010 20:49
内部イテレータ
import std.stdio : writeln;
void main()
{
int[] r = [ 1,2,3,4,5,6 ];
writeln("Elements multiplied by 1.5:");
foreach (e; map!"1.5*a"(r.iterator))
@sinfu
sinfu / gist:653021
Created October 29, 2010 06:21
zshの右プロンプトにgitブランチと時刻表示するやつ
#------------------------------------------------------------------------------#
# Utility Functions
#------------------------------------------------------------------------------#
# For PROMPT.
color_prompt()
{
typeset -A colors
colors=( 'K' 'black' 'R' 'red' 'G' 'green' 'Y' 'yellow' \
'B' 'blue' 'M' 'magenta' 'C' 'cyan' 'W' 'white' )
@sinfu
sinfu / output.txt
Created October 27, 2010 22:04
余計なRTTIを生成することなく,シーケンスを単一型にパックする
true
tuple((double),"value",5)
tuple((double),"value",5)
@sinfu
sinfu / ctfe-writeln.patch
Created October 25, 2010 09:28
[hack] writeln() and dump_istate() for CTFE
diff --git src/interpret.c src/interpret.c
index 5a6cf07..bed664f 100644
--- src/interpret.c
+++ src/interpret.c
@@ -36,6 +36,7 @@ struct InterState
Expression *localThis; // value of 'this', or NULL if none
bool awaitingLvalueReturn; // Support for ref return values:
// Any return to this function should return an lvalue.
+ Loc loc;
InterState();
struct S
{
int value = 9999;
void change()
{
value = 1;
}
}
enum N = 20;
alias Lambda!(int, N, // P = int, q = N
q{
alias P[a][q] _;
})
IntArray;
static assert(is(IntArray!(3) == int[3][N]));
void main()
{
void f() pure
{
}
enforce(100, &f);
}
T enforce(T, DG)(T v, DG dg) pure
if (is(DG == void delegate() pure))
import std.array;
import std.stdio;
alias immutable(ubyte)[] bstring;
void main()
{
auto s = cast(bstring) "abc\rxyz\n\n012\r\n789\r\r...";
|
| $f = new IO::File "test-dat.txt", "r+";
|
open("test-dat.txt",O_RDWR,00) = 3 (0x3)
ioctl(3,TIOCGETA,0xbfbfe6d0) ERR#25 'Inappropriate ioctl for device'
lseek(3,0x0,SEEK_CUR) = 0 (0x0)
fstat(3,{ mode=-rw-r----- ,inode=6335544,size=12,blksize=16384 }) = 0 (0x0)
fcntl(3,F_SETFD,FD_CLOEXEC) = 0 (0x0)
|
| read $f, $s, 2;