This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Control.Applicative (liftA2) | |
import Data.Char | |
import Data.Foldable (for_) | |
import Data.Functor | |
import qualified Data.HashMap.Strict as M | |
import Data.List (intercalate) | |
import Prelude hiding (any) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Author: Jonathan Blow | |
// Version: 1 | |
// Date: 31 August, 2018 | |
// | |
// This code is released under the MIT license, which you can find at | |
// | |
// https://opensource.org/licenses/MIT | |
// | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; vim: set sts=2 sw=2 et sm lisp : | |
(defvar *reading-a-list* nil) | |
(defun read-terminator (stream char) | |
(declare (ignore stream)) | |
(error (format nil "unexpected ~S" char))) | |
(defun get-infix-precedence (symbol) | |
(case symbol |
Summary of and excerpts from chapter 9 and 10 of On Lisp. Examples are mainly in Common Lisp.
- [Variable capture] (https://gist.github.com/nimaai/2f98cc421c9a51930e16#variable-capture)
- [Macro argument capture] (https://gist.github.com/nimaai/2f98cc421c9a51930e16#macro-argument-capture)
- [Free symbol capture] (https://gist.github.com/nimaai/2f98cc421c9a51930e16#free-symbol-capture)
- [Multiple evaluation] (https://gist.github.com/nimaai/2f98cc421c9a51930e16#multiple-evaluation)
- [Order of evaluation] (https://gist.github.com/nimaai/2f98cc421c9a51930e16#order-of-evaluation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import asyncio | |
import multiprocessing | |
import os | |
import ssl | |
from time import sleep | |
port = 9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signature TYPEINFER = | |
sig | |
type tvar = int | |
datatype monotype = TBool | |
| TArr of monotype * monotype | |
| TVar of tvar | |
datatype polytype = PolyType of int list * monotype | |
datatype exp = True | |
| False | |
| Var of int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//xcr.c | |
//cc -o xcr $(pkg-config --cflags --libs cairo xcb xcb-icccm) xcr.c -lcairo -lxcb -lxcb-icccm | |
#include <stdlib.h> | |
#include <string.h> | |
#include <cairo.h> | |
#include <cairo-xcb.h> | |
#include <xcb/xcb.h> | |
#include <xcb/xcb_image.h> | |
#include <xcb/xcb_aux.h> | |
#include <xcb/xcb_icccm.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gcc -Wall -o match match.c && ./match | |
# | |
#include <stdio.h> | |
#include <string.h> | |
#include <regex.h> | |
NewerOlder