Skip to content

Instantly share code, notes, and snippets.

//add rand and bmp as dependencies in toml file
extern crate rand;
extern crate bmp;
use bmp::Image;
use rand::Rng;
#[derive(Clone)]
enum Expr {
VariableX,
VariableY,
type ColorF(r : float, g : float, b : float) =
new(r : byte, g : byte, b : byte) = ColorF(float r / 255.0, float g / 255.0, float b / 255.0)
member __.R = r
member __.G = g
member __.B = b
member color.RGBA =
let r = int (r * 255.0)
let g = int (g * 255.0)
let b = int (b * 255.0)
.class public auto ansi abstract sealed Program
extends [mscorlib]System.Object
{
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = (
01 00 07 00 00 00 00 00
)
.class nested public auto auto sealed serializable beforefieldinit DU
extends [mscorlib]System.ValueType
implements class [mscorlib]System.IEquatable`1<valuetype Program/DU>,
[mscorlib]System.Collections.IStructuralEquatable,
using System;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
for(int i=1;i<=100;i++) {
switch (new { mod3 = i % 3, mod5 = i % 5 }) {
@neildanson
neildanson / FizzBuzzLLVM.fs
Created December 2, 2017 09:11
Example of a fizzbuzz specific AST that emits LLVM bytecode that can be run through clang
module AST =
type Name = string
type TypeName = string
type Literal = Int of int | Bool of bool | String of string | Void
type Expr =
| Literal of Literal
| Rem of Expr * Expr
@neildanson
neildanson / raytracer.glsl
Created December 2, 2017 22:10
Simple Raytracer running in GLSL
#define NUM_SPHERE 6
#define NUM_LIGHT 3
struct Camera {
vec3 position;
vec3 forward;
vec3 up;
vec3 right;
};