This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Used with https://github.com/DeviaVir/zenbot | |
// I store this file at zenbot\scripts\genetic_backtester\summarize.js | |
// Example usage: | |
// node scripts\genetic_backtester\summarize.js --population_data simulations/popDataFolder --count 5 --prop endBalance --gen 1 | |
const fs = require('fs'), | |
KEY_POP_DATA = 'population_data', | |
KEY_BT_GEN = 'backtester_generation', | |
KEY_STRAT = 'strategy', | |
KEY_FITNESS = 'fitness', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(ptr_offset_from)] | |
type ParseResult<'a> = Option<&'a str>; | |
trait Peg<'a> { | |
fn p(&self, s: &mut &'a str) -> ParseResult<'a>; | |
} | |
struct Wrap<T>(T); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const Tag = enum { | |
A, | |
B, | |
C, | |
}; | |
const Tagged = union(Tag) { | |
A: bool, | |
B: i32, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
test "fields" { | |
const U1s = packed struct { | |
a: u1, | |
b: u1, | |
c: u1, | |
}; | |
const x = U1s{ .a = 1, .b = 0, .c = 0 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zig build-obj --emit asm --strip --release-small view_asm.zig && cat view_asm.s | |
const std = @import("std"); | |
pub fn panic(msg: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | |
while (true) {} | |
} | |
export nakedcc fn _start() noreturn { | |
// code here will appear in _start section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const pi: f64 = 3.141592653589793; | |
const solar_mass: f64 = 4.0 * pi * pi; | |
const year: f64 = 365.24; | |
const n_bodies: usize = 5; | |
const Body = struct { | |
x: @Vector(3, f64), | |
v: @Vector(3, f64), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ zig build-exe --release-fast spectralnorm.zig && time ./spectralnorm 5500 | |
const std = @import("std"); | |
const warn = std.debug.warn; | |
const V2f64 = @Vector(2, f64); | |
inline fn A(_i: usize, _j: usize) f64 { | |
var i: f64 = @intToFloat(f64, _i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Computer Language Benchmarks Game | |
// https://salsa.debian.org/benchmarksgame-team/benchmarksgame/ | |
// | |
// Contributed by Mark C. Lewis. | |
// Modified slightly by Chad Whipkey. | |
// Converted from Java to C++ and added SSE support by Branimir Maksimovic. | |
// Converted from C++ to C by Alexey Medvedchikov. | |
// Modified by Jeremy Zerfas. | |
// Converted to zig by Travis Staloch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn RingBuffer(comptime T: type) type { | |
return struct { | |
data: []T, | |
current: [*]T, | |
count: usize, | |
dtor: ?fn (T) void, | |
const Self = @This(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const warn = std.debug.warn; | |
test "parse psf font file" { | |
// https://github.com/monarrk/trOS/raw/master/src/vga/font.psf | |
// const font_raw = @embedFile("font.psf"); | |
// https://github.com/powerline/fonts/blob/master/Terminus/PSF/ter-powerline-v16b.psf.gz | |
const font_raw = @embedFile("ter-powerline-v16b.psf"); | |
const PSFHeader = extern struct { |
OlderNewer