Skip to content

Instantly share code, notes, and snippets.

View kyythane's full-sized avatar

Lillian Primrose kyythane

View GitHub Profile
@kyythane
kyythane / fizzbuzz.js
Last active October 9, 2021 23:20
FizzBuzz using Church Numerals
const ZERO = {};
const succ = (p) => ({ p });
const pred = (s) => (s.p);
const ONE = succ(ZERO);
const THREE = succ(succ(succ(ZERO)));
const FIVE = succ(succ(succ(succ(succ(ZERO)))));
const equals = (a, b) => {
@kyythane
kyythane / HilbertCurve.cs
Created March 26, 2020 17:08
Non-recursive hilbert curve algotithm in C#. Taken from a defunct side project in Unity, so the code as it stands is using Unity's Vector3Int type. But that should be a relatively easy replacement.
using System;
using UnityEngine;
namespace Assets.SunsetIsland.Utilities
{
/// <summary>
/// Convert between Hilbert index and N-dimensional points.
/// The Hilbert index is expressed as an array of transposed bits.
/// Example: 5 bits for each of n=3 coordinates.
/// 15-bit Hilbert integer = A B C D E F G H I J K L M N O is stored
@kyythane
kyythane / FizzBuzz.cs
Last active October 9, 2021 23:22
A perfectly normal C# program :)
using System;
namespace FizzBuz
{
internal class Program
{
public static void Main(string[] args)
{
var i = 1;
Loop:
@kyythane
kyythane / FPMatrix2.cs
Created May 28, 2018 03:09
Fixed point math library intended for use with a toy physics engine (a project for another day).
public struct FPMatrix2
{
public FixedPoint A { get; }
public FixedPoint B { get; }
public FixedPoint C { get; }
public FixedPoint D { get; }
public FPMatrix2(FixedPoint a, FixedPoint b, FixedPoint c, FixedPoint d) : this()
{
A = a;