Skip to content

Instantly share code, notes, and snippets.

View rexim's full-sized avatar
📺
https://twitch.tv/tsoding

Alexey Kutepov rexim

📺
https://twitch.tv/tsoding
View GitHub Profile
object TermOutputHelper {
def smartShowTerm(term: LambdaTerm): String = {
val (prefix, value) = decode(term)
s"$prefix: $value"
}
private def decode(term: LambdaTerm): (String, String) = {
decoders
.map(_(term)) // apply each encoder to the term
{-# LANGUAGE InstanceSigs #-}
module Haph (bfs) where
import qualified Data.Set as Set
import qualified Data.Map as Map
import qualified Data.List.Ordered as O
newtype AdjacencyList v = AdjacencyList (Map.Map v [v])
class Graph g where
@rexim
rexim / FingerTree.hs
Last active February 5, 2018 10:12
FingerTree Implementation
data FingerTree a = Empty
| Single a
| Deep (Digit a) (FingerTree (Node a)) (Digit a)
deriving Show
data Digit a = One a | Two a a | Three a a a | Four a a a a deriving Show
data Node a = Node2 a a | Node3 a a a deriving Show
digitToList :: Digit a -> [a]
digitToList (One y1) = [y1]
#!/usr/bin/env tclsh
package require Tk
proc snowflake {can x1 y1 n len level} {
if {$level <= 0} {
return
}
set pi 3.1415926535897931
import java.util.*;
public class Homie<K, V> {
public Homie() {
this.backend = new HashMap<>();
}
public void insertValue(K key, V value) {
this.backend.put(key, value);
}
{-# LANGUAGE DeriveFunctor #-}
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
class Monad m => Unwrappable m where
unwrap :: m a -> a
newtype Compose u m a = Compose { runCompose :: m (u a) } deriving Functor
@rexim
rexim / main.lua
Created January 20, 2019 18:05
Sticky-sticky
local pivot = {
x = 200,
y = 200,
w = 100,
h = 150,
}
local rect = {
x = 0,
y = 0,
-- Build Instructions
-- $ ghc --make Main
-- $ ./Main
main = putStrLn "Hello, World"
@rexim
rexim / TODO.org
Last active March 22, 2019 10:08
MyPaint contribution
@rexim
rexim / main.c
Last active April 20, 2019 18:00
Delete array element benchmarking
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define N (1000 * 1000)
void array_print(int *xs, int n)
{