Skip to content

Instantly share code, notes, and snippets.

View alpha-convert's full-sized avatar

Joseph Cutler alpha-convert

View GitHub Profile
@alpha-convert
alpha-convert / RaineyTree.ml
Created November 30, 2024 06:30
Summing Trees, n Ways.
type 'a tree = Empty | Node of 'a * 'a tree * 'a tree
module type SUM = sig
val sum : int tree -> int
end
(*
1. Normal Recursive tree sum.
*)
module Recursive : SUM = struct
@alpha-convert
alpha-convert / tries.v
Last active September 18, 2023 15:08
Tries are Derivative-y
Inductive regex : Set :=
| Zero : regex
| Eps : regex
| Nat : nat -> regex
| Cat : regex -> regex -> regex
| Or : regex -> regex -> regex.
Fixpoint nullableT (r : regex) : Type :=
match r with
@alpha-convert
alpha-convert / grp.idr
Last active March 17, 2018 15:23
Idris Group Problem
interface Group a where
(<*>) : a -> a -> a
inv : a -> a
e : a
lAssoc : (x <*> y) <*> z = x <*> (y <*> z)
rAssoc : x <*> (y <*> z) = (x <*> y) <*> z
lId : e <*> x = x
rId : x <*> e = x
lInv : inv x <*> x = e
rInv : x <*> inv x = e
using System;
using System.Linq;
namespace Learn
{
public class Sorter
{
public void PrintArray(int[] arr){
Console.WriteLine(string.Join(",",arr));
}
char *a = "Hello, ";
int a_len = strlen(a);
//This?
char *b = calloc(a_len,1);
strncpy(b,a);
strncat(b,"World!",6);
//Or this?
char *b = calloc(a_len + 6,1);