Skip to content

Instantly share code, notes, and snippets.

View rain-1's full-sized avatar
☂️
Umbrella

rain1 rain-1

☂️
Umbrella
View GitHub Profile
@rain-1
rain-1 / minikanren.scm
Created January 6, 2019 17:49
minikanren.scm - based off orchid-hybrid mirukanren. works in Chez
;; utils
(define (assp p l)
(if (null? l)
#f
(if (p (caar l))
(car l)
(assp p (cdr l)))))
@rain-1
rain-1 / grammar-1.rkt
Last active February 7, 2019 10:35
parsing with grammars
#lang racket
;(start, (ACCEPT))
;(start, (READ #\a, sym))
;(start, (READ #\b, sym))
;(start, (READ #\(, "sexps"), PUSH(#\)))
;(sym, (ACCEPT))
;(sym, (READ #\a, sym))
;(sym, (READ #\b, sym))
@rain-1
rain-1 / closure-conversion.rkt
Created February 16, 2019 10:06
Closure Conversion
#lang racket
;; this is a stand alone simple version of the closure conversion part of the hoist pass from the tarot compiler
;; see https://rain-1.github.io/scheme for more.
(require data/queue)
;; closure conversion for lambda calculus
;;
;; the input language is:
@rain-1
rain-1 / serialize-lisp.rkt
Created February 17, 2019 16:46
serialize-lisp.rkt
#lang racket
;; This implements a baby lisp interpreter using closure conversion pass before execution
;; It supports serialization of closures (e.g. for partial evaluation/staging) and reading back and executing those objects
(require data/queue)
;; closure conversion for lambda calculus
;;
;; the input language is:
@rain-1
rain-1 / set.rkt
Created March 4, 2019 20:30
generalized set! in racket - failed idea
#lang racket
(require (for-syntax racket/syntax))
(define toplevel 'foo)
(define-syntax (set^ stx)
(syntax-case stx ()
[(_ (attr x) y)
(with-syntax ([set-attr! (format-id #'toplevel "set-~a!" (syntax-e #'attr))])
@rain-1
rain-1 / another way
Last active March 12, 2019 10:45
k-n-combinations.rkt
#lang racket
(require racket/stream)
(define (make-prefix len)
(lambda (tail)
(append (make-list len '_) (cons 'o tail))))
(define (k-combinations k n)
(cond ((= k 0)
@rain-1
rain-1 / checksum-colorizer.go
Created March 18, 2019 23:39
checksum colorizer
package main
import (
"bufio"
"fmt"
"os"
"log"
"regexp"
)
@rain-1
rain-1 / mytv.vala
Created April 7, 2019 16:20
bold text in vala
using Gtk;
// valac --pkg gtk+-3.0 mytv.vala
public class MarkupTextView : TextView {
public void append_text (string s) {
TextIter end_iter;
buffer.get_end_iter (out end_iter);
buffer.insert_with_tags_by_name (ref end_iter, s, -1, null);
}
@rain-1
rain-1 / markdown.md
Created April 17, 2019 22:32
gopher markdown specification

My Markdown Spec

This is (yet) another markdown specification. The purpose of this particular markdown spec is to provide a single unambiguous markdown specification. It aims to use formal regular expressions so that implementors can quickly create implementations (given a regex library) and the results will be consistent across platforms. We specify a very small subset of the markdown seen in the wild.

Version 0.1

@rain-1
rain-1 / SPECIFICATION.txt
Last active June 5, 2019 16:11
DEPENDS.txt
# INTRODUCTION
This document specifies the DEPENDS.TXT file for a software project.
This is simply a list of the build time and runtime dependencies of the software.
# SPEC
The file is in TSV (tab separated values) format with UTF-8 encoding, so each line is a record describing a single dependency.
Each record is <package-name>\t<type>\t<version>