Skip to content

Instantly share code, notes, and snippets.

@epi
epi / nbp.d
Created January 12, 2018 13:30
NBP Web API
/+dub.sdl:
dependency "vibe-d" version="~>0.8.0"
+/
import vibe.d;
import std.stdio;
struct RateByDate
{
string no;
string effectiveDate;
@epi
epi / pi.d
Last active March 6, 2017 13:01
Approximate Pi using randomly scattered points
auto approximate(double radius, uint npoints)
{
import std.range : generate, take;
import std.algorithm : count;
import std.random : Xorshift, unpredictableSeed, uniform;
auto radius2 = radius * radius;
auto generator = Xorshift(unpredictableSeed);
auto makeRandomCoord() { return uniform!`[]`(0, radius, generator) ^^ 2; }