This article is now published on my website: Prefer Subshells for Context.
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
(function() { | |
"use strict"; | |
Object.defineProperty(HTMLLinkElement.prototype, 'template', { | |
get: function() { | |
if(!/template/i.test(this.rel)) { | |
return ""; | |
} | |
var req = new XMLHttpRequest(); |
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
; ModuleID = 'struct1' | |
; Object = struct | |
; foo = 1 | |
%ObjectT = type <{ i64 }> ; foo | |
@ObjectS = private unnamed_addr constant %ObjectT <{ i64 1 }> | |
; Shape = struct Object | |
; color = 0xff0000 | |
; area = func () 0 | |
; fillColor = func () @color / @area! |
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
(extend-type js/RegExp | |
cljs.core/IFn | |
(-invoke ([this s] (re-matches this s)))) | |
(#"foo.*" "foobar") ;=> "foobar" | |
(#"zoo.*" "foobar") ;=> nil | |
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz") |
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
The bridge is now located at https://github.com/fjolnir/TLC |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
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
;; Requires Outlet to run: https://github.com/jlongster/outlet | |
;; | |
;; Run with: `ol main.ol <input-file>` | |
;; | |
;; This is a meta-circular evaluator for a basic Lisp. It is | |
;; mostly taken from SICP 4.1*. I wanted to see if I could write a | |
;; debugger with it. Turns out if I want control over control flow I | |
;; need a register-based interpreter. | |
;; | |
;; * http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1 |
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
// Version 1. Simple recursive function. Blows the stack for large nodes. | |
function replace(node, from, to) { | |
switch (node.type) { | |
case IF: | |
return { | |
type: IF, | |
test: replace(node.test, from, to), | |
then: replace(node.then, from, to), | |
else: replace(node.else, from, to) | |
}; |
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
class Lisp | |
Fs = { | |
:label => lambda {|name,value| Fs[name] = lambda { value } }, | |
:car => lambda {|sexp| sexp.first }, | |
:cdr => lambda {|sexp| sexp.slice(1, sexp.size) }, | |
:cons => lambda {|head,tail| [head] + tail }, | |
:atom => lambda {|sexp| !sexp.is_a?(Array) }, | |
:eq => lambda {|a,b| a == b }, | |
:if => lambda {|cnd,thn,els| cnd ? thn : els } | |
} |
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
#lang racket | |
(provide (struct-out subscription) | |
(struct-out message-handler) | |
(struct-out kernel-mode-transition) | |
make-vm | |
vm? | |
run-vm | |
nested-vm) |