Skip to content

Instantly share code, notes, and snippets.

View vanaur's full-sized avatar
🐿️
I enjoy squirrels

vanaur

🐿️
I enjoy squirrels
View GitHub Profile
@vanaur
vanaur / UnionFind.fs
Created April 9, 2024 12:48
This module implements a generic union-find data structure in F# (for .NET)
/// This module implements a generic [union-find](https://en.wikipedia.org/wiki/Disjoint-set_data_structure) data structure.
/// This structure is used to manage disjoint sets, often used in partitioning or clustering problems.
///
/// Here is a summary of the features and members of this data structure:
///
/// 1. **Constructor**: The `UnionFind` constructor initializes a new instance of the Union-Find data structure with
/// default elements of the original set specified as a sequence. This set can be extended.
///
/// 2. **Public Members** :
/// - `UnionFind.AddElement` Adds a new element to the set.
@Hirrolot
Hirrolot / CoC.ml
Last active May 24, 2024 23:57
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@vanaur
vanaur / ColumnParser.fsx
Created June 29, 2022 14:33
Parse a file of spaced columns
#r "nuget: FParsec, 1.1.1"
open FParsec
let ws = skipMany (pchar ' ' <|> pchar '\t')
let ws1 = skipMany1 (pchar ' ' <|> pchar '\t')
let parseComment =
pstring "#" >>. skipRestOfLine true >>% []
from dataclasses import dataclass
from typing import List, Tuple, Union, Dict, Iterator, Optional
import sys
import itertools
Id = int
class UnionFind:
parents: List[Id]
@Mesabloo
Mesabloo / Test.hs
Last active July 7, 2022 18:26
A simple exercise with Haskell and genericity
{-| Exercise:
- Step 1:
Write a program simulating an iterating machine: we for example feed a range
@[0..4]@ and an action @print@ and it must execute this action on all the
elements of the range.
Writing @iterate1 [4..9] print@ must output:
> 4
@mikesmullin
mikesmullin / x86-assembly-notes.md
Last active June 19, 2024 16:42
Notes on x86-64 Assembly and Machine Code

Mike's x86-64 Assembly (ASM) Notes

Assembling Binary Machine Code

Operating Modes:

These determine the assumed/default size of instruction operands, and restricts which opcodes are available, and how they are used.

Modern operating systems, booted inside Real mode,