Skip to content

Instantly share code, notes, and snippets.

View zypeh's full-sized avatar
🔎
If you look for perfection, you'll never be content.

zypeh zypeh

🔎
If you look for perfection, you'll never be content.
View GitHub Profile
benchmarked sexp/fpbasic
time 3.193 ms (3.073 ms .. 3.357 ms)
0.989 R² (0.978 R² .. 0.998 R²)
mean 2.960 ms (2.928 ms .. 3.023 ms)
std dev 145.1 μs (89.51 μs .. 250.5 μs)
variance introduced by outliers: 28% (moderately inflated)
benchmarked sexp/fpstateful
time 3.417 ms (3.346 ms .. 3.471 ms)
0.997 R² (0.995 R² .. 0.999 R²)
@zypeh
zypeh / evaluator.rs
Created December 14, 2020 09:12
evaluator for untyped lambda calculus
use std::boxed::Box;
#[derive(Clone, Debug)]
enum Expr {
VAR(String),
APP { func: Box<Expr>, arg: Box<Expr> },
LAM { arg: String, body: Box<Expr> },
}
type Env = Vec<(String, Val)>;
@zypeh
zypeh / stlc.rs
Created December 9, 2020 12:40
Type-checker for Simply Typed Lambda Calculus
use std::boxed::Box;
/// Simply typed lambda calculus is based on untyped lambda calculus, but
/// added a simple type. (Which is the function type A -> B)
#[derive(PartialEq, Eq, Debug)]
enum Type {
/// Base type
BuiltIn(&'static str), Var(String),
/// Function type (Type * Type)
Lambda(Box<Type>, Box<Type>),
-- 'Topoi Core' is basically the desugared topoi language.
-- Only consists of basic primitive atoms and functions.
-- This is largely referenced to the ML language, Pie language from the book
-- 'The Little Typer' and (GHC Core)
-- [https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/core-syn-type]
-- write once variable, top level no need to write `let`
n = 3
-- comments
--| doc comments (default markdown)
--| prefix | prefixed comments
--[ block comment
]--
--[ prefix |
prefixed block comment
]--
-- comments
--| doc comments, should support latex (my dream)
--|prefix| prefixed comments
--[block comment]--
--[prefix| prefixed block comment]--
[1, 2, 3] -- lists
1 :: 2 :: 3 :: [] -- list
-- Types, should starts with uppercase letters
-- single line comment, no multi-line comment allowed. Keep it simple, okay ?
-- https://futhark-lang.org/blog/2017-10-10-block-comments-are-a-bad-idea.html
---------------------------------------------------
-- Functions and Values Assignment --
---------------------------------------------------
let varname = 1
let varname_with_type: Bool = true
-- ^-- values name ^-- type
# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
@zypeh
zypeh / designer.html
Last active August 29, 2015 14:15
designer
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-app.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@zypeh
zypeh / net.py
Last active August 29, 2015 14:10
Check network interface
#!/usr/bin/env python
import time
import sys
if len(sys.argv) > 1:
INTERFACE = sys.argv[1]
else:
INTERFACE = 'eth0'
STATS = []