Skip to content

Instantly share code, notes, and snippets.

View be5invis's full-sized avatar

Belleve be5invis

View GitHub Profile
var Ref = function(s){ this.ref = s }
var newt = function(n){
return function(){
return new Ref("_" + (n++))
}
}(0);
function id(x){ return x }
function normalizeTerm(form){ return normalize(form, id) }
function normalize(form, ctx){
@be5invis
be5invis / gist:9377026
Created March 5, 2014 21:29
A draft for some weird language
[semantics [or a b]
[let [ta [evaluate a]]
[if ta [return ta] [return [evaluate b]]]]]
[semantics [while condition body]
[block LOOP_START
[let [continue? [evaluate condition]]
[if continue?
[begin
[evaluate body]
var SequenceRule = function() {
var parts = arguments;
if(!parts.length) return function(phase, onmatch, onfail) {
return onmatch(phase, '')
}
var last = parts[parts.length - 1];
var trailing = function(phase, onmatch, onfail){
last(phase, function(phase1, result){ onmatch(phase1, [result]) }, onfail)
};
for(var j = parts.length - 2; j >= 0; j--) {
@be5invis
be5invis / k-types.txt
Last active December 31, 2015 18:29
Conceptional language + type system
// data types
type[T] Point {
data x : T
data y : T
}
type IntPoint = Point[Integer]
// complex concepts
type[T <= Differable] DifferenceOf {
@be5invis
be5invis / scroll.ahk
Created September 15, 2013 14:05
DPI-aware FocuslessScroll
; Modified by Belleve Invis
; In order to support High DPI environment
; FocuslessScroll by Scoox
; Source: http://www.autohotkey.com/board/topic/6292-send-mouse-scrolls-to-window-under-mouse/?p=398492
; Modifications by Geoff Stokes
;Directives
#NoEnv
#SingleInstance Force
@be5invis
be5invis / explain.js
Last active October 13, 2015 14:57
Javascript Engines DO optimize integer operations.
function bench1(n){
for(var i = 0; i < n; i++) ;
}
function bench2(n){
for(var i = 0.5; i < n; i++) ;
}
function bench3(n){
for(var i = Math.random(); i < n; i++) ;
}
function bench4(n){
<dict>
<key>match</key>
<string>[$*,£¥·‘“〈《「『【〔〖〝﹗﹙﹛$(.[{£¥]*[&#x3000;-&#x9fff;][!%),.:;>?¢¨°·ˇˉ―‖’”„‟†‡›℃∶、。〃〆〈《「『〕〗〞︵︹︽︿﹃﹘﹚﹜!"%'),.:;?]`|}~ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻]*</string>
<key>name</key>
<string>meta.cjkword</string>
</dict>
@be5invis
be5invis / gist:2566627
Created May 1, 2012 09:10
Moescript source map example
function F1$_(){
var Tp$_, Tq$_, T11$_, T12$_;
var ecSchemata$, item$, mktable$, t$;
//MoeMap// var ecSchemata = [yield: fYield, return: fReturn, bind: fBind]
//MoeMap// where
ecSchemata$ = (function F2$_(){
var fBind$, fReturn$, fYield$;
//MoeMap// fReturn = Enumerable function(x):
fReturn$ = Enumerable$({build:function(SCHEMATA$_){return function(x$){
var T4$_, T5$_, T6$_, T7$_;
@be5invis
be5invis / mergeSpaces.moe
Created March 29, 2012 12:29
Answer for Ninputer: merge spaces
def rest(s) = s.slice 1
def mergeSpaces(s) = phase_normal s
where phase_normal(s) = piecewise
when(not s) s
when(s[0] == ' ') s[0] + phase_space rest s
otherwise s[0] + phase_normal rest s
phase_space(s) = piecewise
when(not s) s
when(s[0] == ' ') phase_space rest s
@be5invis
be5invis / enumComp.moe
Created March 24, 2012 09:03
Enumerator comprehension monad
-- Enumerator comprehension monad
var ecSchemata = [yield: fYield, return: fReturn, bind: fBind]
where
fReturn = Enumerable function(x):
if(x != undefined)
enumeration.yield! x
fYield(x) = x
fBind = Enumerable function(list, callback):
for(var x in list)
for(var y in callback x)