Skip to content

Instantly share code, notes, and snippets.

@Agnishom
Agnishom / RegexParseTreesFull.v
Last active May 13, 2023 07:26
Parse Tree Preference
Require Import Coq.Lists.List.
Declare Scope regex_scope.
Open Scope regex_scope.
Section Regex.
Variable (A : Type).
Inductive Regex : Type :=
@Agnishom
Agnishom / AwesomeListLemmas.v
Last active April 26, 2024 14:20
Awesome List Lemmas
(*
Some lemmas that can be used in conjunction with those in Coq.Lists.List
See https://coq.inria.fr/library/Coq.Lists.List.html
*)
Require Import Lia.
Require Import Coq.Lists.List.
@Agnishom
Agnishom / pcre.cpp
Last active February 24, 2023 22:00
PCRE Execution
#include <iostream>
#include <string>
#include <pcre.h>
#include <chrono>
using namespace std;
int main() {
string pattern;
string input;
@Agnishom
Agnishom / main.rs
Created September 29, 2022 14:34
Paige-Tarjan
use std::collections::VecDeque;
use std::cell::RefCell;
use std::rc::Rc;
use std::cell::Ref;
pub mod vllsimple;
use vllsimple::*;
struct part_man{
// pools
@Agnishom
Agnishom / hopcroft.rs
Created September 13, 2022 02:47
Hopcroft's Algorithm
use std::collections::VecDeque;
// compute the inverse relation given a function
fn inverse_fn(n: usize, f: &Vec<usize>) -> Vec<Vec<usize>> {
let mut inverse_f = vec![vec![]; n];
for i in 0..n {
inverse_f[f[i]].push(i);
}
inverse_f
}
@Agnishom
Agnishom / main.c
Created January 12, 2022 15:54
Copilot example code
#include <stdio.h>
#include "heater.c"
uint8_t temperature;
int main(){
for (int i = 0; i < 200; i++){
temperature = i;
step();
@Agnishom
Agnishom / Board.hs
Created November 7, 2021 14:21
Haskell Tic Tac Toe with CLI and Gloss GUI
module Board where
import Data.Map (Map, (!))
import qualified Data.Map as Map
import Data.List (intercalate)
data Player = X | O
deriving (Eq, Ord, Show)
newtype Board = Board (Map (Int, Int) (Maybe Player))
@Agnishom
Agnishom / IntList.java
Created November 4, 2021 18:45
Visitor Pattern
/** The functional list type defined by IntList := EmptyIntList + ConsIntList(int, IntList) */
abstract class IntList {
/** Visitor hook */
abstract public Object visit(IntListVisitor iv);
/** Adds i to the front of this. */
public ConsIntList cons(int i) { return new ConsIntList(i, this); }
/** Returns the unique empty list. */
public static EmptyIntList empty() { return EmptyIntList.ONLY; }
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wall #-}
module Regex.Glushkov where
import Control.Monad.State
import Data.Aeson.Encode.Pretty (encodePretty)
import qualified Data.Text as T
import qualified Data.ByteString.Lazy as BSL
@Agnishom
Agnishom / test.rs
Created May 26, 2021 15:17
Composable Transductions
use std::marker::PhantomData;
pub trait Sink<A> {
fn init(&mut self);
fn next(&mut self, item: A);
fn end(&mut self);
}
pub trait Query<A,B>: {
fn init(&mut self, sink: &mut dyn Sink<B>);