This file contains hidden or 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
import Mouse | |
main = drawNodes <~ foldp (flip applyMovement [0]) forest mouseShift | |
forest : Forest Rect | |
forest = [ | |
Rect (-200, 200) (100, 20) `nodes` | |
[ Rect (100, 0) (75, 18) `nodes` | |
[ leaf <| Rect (0, -60) (60, 15) |
This file contains hidden or 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
// API: | |
// === | |
// helpers: | |
// ------- | |
// var write = function (what) | |
// var writeln = function (what) | |
// var write_spine = function (spine) |
This file contains hidden or 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
:- op(400, xfx, d). % so we write "1 d 6" | |
throw(Count d Dice, Throw) :- | |
count(Randoms, Count), % alloc list Randoms of length Count | |
each(random, Randoms), % fill with randoms | |
each(randomToThrow(Dice), Randoms, Throws), | |
sum(Throws, Throw). |
This file contains hidden or 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
%% Here and below, lc = en.wikipedia.org/wiki/Lambda_calculus, the simplest | |
%% functional language possible. | |
%% There are two languages in use here: weak lc & rich lc. | |
%% The only allowed constructions for weak are | |
%% X -> B, "function (X) { return B }" where X is a name and B is valid weak lc | |
%% F @ X, "F(X)" where F & X are valid lc | |
%% Term any term where Term is name or integer |
This file contains hidden or 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
open Printf | |
type logger = { write : writer } | |
and writer = string -> unit | |
let init (writer : writer) : logger = | |
{ write = writer } | |
let set_writer (logger : logger) (writer : writer) : logger = |
This file contains hidden or 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
import Text.ParserCombinators.Parsec (Parser, parse, many, string) | |
import Control.Monad (msum, forM_) | |
program :: Parser () | |
program = do | |
rbr <- opening | |
many program | |
string rbr |
This file contains hidden or 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
type Application = | |
{ style : Size | |
, current : Int | |
, list : TodoList | |
} | |
type Size = | |
{ elem : { width : Int, height : Int } | |
} |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
#define self (*this) | |
template <class T> | |
struct vec | |
{ |
This file contains hidden or 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
datatype ('s, 'a) state = STATE of 's -> 's * 'a | |
type position = | |
{ line : int | |
, pos : int | |
} | |
fun position_to_str {line, pos} = | |
Int.toString line ^ ": " ^ Int.toString pos |
This file contains hidden or 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 | |
(define-syntax-rule (-> args . body) (lambda args . body)) | |
(define atom? (or/c number? symbol? boolean? string?)) | |
(define (transform body return) | |
(trace 'transform-2 body (-> () | |
(if (atom? body) |