Skip to content

Instantly share code, notes, and snippets.

View brendanzab's full-sized avatar
😵‍💫
writing elaborators

Brendan Zabarauskas brendanzab

😵‍💫
writing elaborators
View GitHub Profile
@emberian
emberian / links.md
Last active August 29, 2015 13:57
PL Theory etc
@sobels
sobels / life.d
Created October 20, 2014 20:41
Conway's Game of Life, using D metaprogramming
enum height = 5;
enum width = 5;
enum iterations = 20;
enum initialState = [
0, 1, 0, 1, 1,
0, 0, 0, 0, 1,
1, 1, 0, 0, 0,
1, 1, 1, 1, 1,
@kelsey-sorrels
kelsey-sorrels / gist:3939096
Created October 23, 2012 14:34
rSimulate GeoJSON Draft

Purpose

To define a common data language for applications that simulate entire worlds. When many applications speak the same language, an ecosystem develops that is often more than the sum of its parts.

General

  • All data is UTF-8 encoded.
  • MIME type is application/json
// Original version: http://play.golang.org/p/ebO20f-eax
// Requires Rust 0.5.
extern mod std;
use io::WriterUtil;
const WIDTH: uint = 76;
const HEIGHT: uint = 10;
const NUM_BALLS: uint = 10;
anonymous
anonymous / RustSyntaxProposal
Created March 18, 2013 16:33
Proposal for new syntax for type definition. Motivation: Rust tries to mix concepts from Functional languages with syntax from C/C++. structs (records) are equivalent to the C/C++ version. However enums in rust do not behave like enums from c: Enums in rust are used to define Algebraic Data Types (sum types) that act similar to 'tagged unions' i…
type Name = {
first: ~str,
last: ~str
}
type Shape = Circle(int) | Rect(int, int) // Variants with constructors
type Direction = North | South | East | West // without constructors
pub trait BaseVec: Index<uint,Self::T>
+ Eq {
type T;
static LEN: uint;
fn from_value(value: Self::T) -> Self;
}
pub trait BaseVec3: BaseVec {
fn new(x: Self::T, y: Self::T, z: Self::T) -> Self;
}
@luqmana
luqmana / rqsrt.rs
Last active December 16, 2015 15:39
fn libc_rsqrt(f: &f32) -> f32 {
1.0/f32::sqrt(*f)
}
fn llvm_rsqrt(f: &f32) -> f32 {
1.0/core::unstable::intrinsics::sqrtf32(*f)
}
fn asm_rsqrt(f: &f32) -> f32 {
let mut b = &0.0f32;
unsafe {
asm!("rsqrtss ($0), %xmm0\n\t\
fn r̄ͬ̇ͦ̓u͗͗̅̐s̔̈́ͯ̄̓ͭ͋tͣͯͦ̂̃̆̓_̍͌̉̃l̆a͐̾̿̋̈́n̉ͬͥ́ͪ̊gͭ͛̾_́cͪͬ͑͂̈oͭͨ̊̋̓ͧm̌̿̐̿ͤ̆͐e̔̓̆ͭͨ̾̚s() {
println("ĭ̒̚tͧ̂͆ͫ̄ ̃ͬ͗̍̂c̈͒̊õ͑̓ͩͦ͒m̊͗̐̒esͩ͛!ͨ̀ͩ̀͆̄̚ ĭ̿̈̍̀ͮ͑tͦ͂̉̒̔̇ ̓co͛́̾ͤ̄̉͌m͂͆̀ͫe͛ͨ͌̇͆ͣͥs͂!̇̌̎̆");
}
fn main() {
r̄ͬ̇ͦ̓u͗͗̅̐s̔̈́ͯ̄̓ͭ͋tͣͯͦ̂̃̆̓_̍͌̉̃l̆a͐̾̿̋̈́n̉ͬͥ́ͪ̊gͭ͛̾_́cͪͬ͑͂̈oͭͨ̊̋̓ͧm̌̿̐̿ͤ̆͐e̔̓̆ͭͨ̾̚s();
}
pub struct Context {
chan: SharedChan<Msg>,
}
enum Msg {
CreateWindow(Context, uint, uint, ~str, WindowMode, Chan<Option<Window>>),
DetachCurrentContext,
// window messages
GetShouldClose(*c_void, Chan<bool>),