Skip to content

Instantly share code, notes, and snippets.

View MartinNowak's full-sized avatar
🎯
Focusing

dawg MartinNowak

🎯
Focusing
View GitHub Profile
@MartinNowak
MartinNowak / list_comprehension.d
Created September 1, 2011 19:05
Range interface List comprehension
import std.algorithm, std.conv, std.functional, std.stdio, std.range, std.traits, std.typetuple, std.typecons;
pragma(importpath, "dranges=https://raw.github.com/dawgfoto/dranges/master");
import dranges.functional;
pragma(build, dranges);
Permute!Ranges permute(Ranges...)(Ranges ranges)
{
return typeof(return)(ranges);
}
module std.regionallocator;
import std.algorithm, std.conv, std.exception, std.traits, std.typecons;
import core.bitop, core.exception, core.memory;
interface Allocator {
enum alignment = 1;
enum isAutomatic = false;
enum isScoped = false;
enum freeIsChecked = false;
import std.algorithm, std.exception, std.random, std.range, std.stdio;
PowerSet!R powerSet(R)(R range) if(isRandomAccessRange!R)
{
return typeof(return)(range);
}
auto powerSet(R)(R range) if(!isRandomAccessRange!R && !isInfinite!R)
{
return powerSet(array(range));
@MartinNowak
MartinNowak / arrayOp.d
Created September 22, 2011 17:52
vector array operations
import core.bitop, core.cpuid;
version (D_InlineAsm_X86)
{
enum GeneralPurposeRegs : string
{
AX = "EAX",
CX = "ECX",
DX = "EDX",
BX = "EBX",
import std.ascii, std.algorithm, std.conv, std.range, std.stdio, std.string;
ulong fromHexDigit(dchar c) {
if (!isHexDigit(c))
throw new Exception("Illegal char in hex number: "~to!string(c));
return c <= '9' ? (c & 0xF) : 9 + (c & 0xF);
}
ulong fromBinDigit(dchar c) {
if (c == '0') return 0;
We couldn’t find that file to show.
module buffered_range;
import std.algorithm, std.conv, std.exception, std.range, std.traits, std.typecons;
import core.memory, core.stdc.stdlib;
/*
* Adds the save function to an input range thus promoting
* it to a forward range. This is done by buffering the input range
* in blocks of size blockSize.
*/
We couldn’t find that file to show.
import std.random, std.traits, std.typecons, std.typetuple;
struct Builder(UserGens...)
{
Tuple!TS genTuple(TS...)()
{
Tuple!TS tup;
foreach(i, T; TS)
tup[i] = gen!T();
return tup;
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include "array.hpp"
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// This is header only, so we just need to create an empty compile unit.