Skip to content

Instantly share code, notes, and snippets.

@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>);
@Agnishom
Agnishom / monoid_recognizers.lean
Last active January 14, 2020 13:39
Lean Automata
import data.fintype
structure dfa (alphabet : Type) [fintype alphabet] :=
(qq : Type) {is_finite : fintype qq} {has_decidable_eq : decidable_eq qq}
(δ : qq → alphabet → qq)
(init : qq)
(fin : qq → bool)
def language (alphabet : Type) [fintype alphabet] := list alphabet → bool
@Agnishom
Agnishom / keybase.md
Created September 6, 2019 04:17
Keybase

Keybase proof

I hereby claim:

  • I am agnishom on github.
  • I am agnishom (https://keybase.io/agnishom) on keybase.
  • I have a public key ASBEfGCEQw4cY-VOkwSiHBWosC_4pM60jwJi5AufQzgF2wo

To claim this, I am signing this object:

@Agnishom
Agnishom / multiplication.hs
Created August 10, 2019 02:39
When is Karatsuba faster?
import Data.List
{-
We are assumming the multiplication is happening in decimal digits. Here is the yardstick with which we are measuring the number of operations
1. Every single digit multiplication is 1 step
2. Adding two n-digit numbers is n steps.
Adding an m-digit and an n-digit number takes max(m, n) steps.
Adding two n-digit numbers produce an (n+1)-digit number.
@Agnishom
Agnishom / immerman.hs
Created February 8, 2019 03:01
A Haskell-Aware Explanation of Immerman–Szelepcsényi Theorem
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
type NonDet a = [a]
type NonDetState s a = StateT s [] a
type Vertex = Int
@Agnishom
Agnishom / monadic_party.md
Created February 3, 2019 16:16
Monadic Party SOP

I am a final year undergraduate student of Mathematics and (Theoretical) Computer Science studying in Chennai Mathematical Institute, India. My interests in computer science are along the lines of programming languages and logic.

My interest in functional programming began as a leisure activity, but became more serious when I took my first introductory Haskell Course. As time progressed, I educated myself through the means of several internet blogs and other online resources. I also took a follow up course titled "Implementation of Functional Programming" where we discussed the challenges of the implementational aspects of languages with functional abstraction. In the subsequent year, I offered to be the teaching assistant of the same introductory Haskell course which was my initial inspiration. Not only did I tutor this course in my institution, but also over online courses conducted by NPTEL, twice in a row.

Last summer, I interned at a technological start-up VacationLabs, Goa where we used functional p