Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
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)
@Heimdell
Heimdell / run-forest-run.js
Last active August 29, 2015 14:06
Run, Forest, run!
// API:
// ===
// helpers:
// -------
// var write = function (what)
// var writeln = function (what)
// var write_spine = function (spine)
:- 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).
@Heimdell
Heimdell / lc.prolog
Last active August 29, 2015 14:08
Lambda calculus 2 js translator, written on Prolog.
%% 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
@Heimdell
Heimdell / 1.ml
Last active August 29, 2015 14:09
Lolger
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 =
import Text.ParserCombinators.Parsec (Parser, parse, many, string)
import Control.Monad (msum, forM_)
program :: Parser ()
program = do
rbr <- opening
many program
string rbr
type Application =
{ style : Size
, current : Int
, list : TodoList
}
type Size =
{ elem : { width : Int, height : Int }
}
#include <iostream>
using namespace std;
#define self (*this)
template <class T>
struct vec
{
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
#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)