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 cps_prim(f) { | |
return function() { | |
var r = arguments.reverse(); | |
return r[0]( f.apply(this, arguments.slice(1).reverse()) ); | |
} | |
} | |
function _sqrt() { return cps_prim(function(x) { return 6; }); } | |
function _mul(a, b) { return a*b; } |
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
/* sums the digits of the factorial 10 (since not much larger can be held by a double) | |
copyright (c) 2011 darkf | |
use for anything, CC-0 or public domain etc */ | |
#include <stdio.h> | |
#include <string.h> | |
double f(int n){return !n?1:n*f(n-1);} | |
int g(char* b){int x=0,i;for(i=0;i<strlen(b);i++)x+=b[i]-'0';return x;} | |
main(){char b[256];double x=f(10);sprintf(b,"%.0f",x);printf("%d",g(b));} |
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
/* blokvm -- a darkf implementation of blockeduser's terrible vm | |
copyright (c) 2012 darkf */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
/* 3 * 255^2 */ | |
#define BITMAP_SIZE 195075 | |
#define JMP fseek(fp, PC, SEEK_SET); |
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
# mockup of a game-oriented behavior modeling language, v6 (1/13/2012) | |
# copyright (c) 2012 darkf | |
# define player as an object that is both movable, drawable and a rigid body (via tags) | |
player <- Object() | |
player is Movable, RigidBody, Drawable # three tags | |
tiles <- Array2D(64, 64) # 2-dimensional array of size 64x64 for holding map tiles | |
# Array2D is by default tagged with Iterable, Indexable | |
tiles is Drawable # add a Drawable tag so we can treat it as a game object |
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
# mockup of a game-oriented behavior modeling language, v1 (1/14/2012) | |
# copyright (c) 2012 darkf | |
playership <- Sprite(Vec2(64, 64)) # 64x64 sprite | |
enemyship <- Sprite(Vec2(64, 64)) | |
projectiles <- List() # dynamic list | |
on playership:collide b do | |
if b is? enemyship do | |
# collided with enemy ship |
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
This is the virtual machine for a pure OO language based on game creation. | |
It is, at essence, a stack machine. There are no registers. | |
Instructions only have one argument, which can be an integer or a string. | |
Function arguments are pushed in reverse order, C-style. (e.g. x(1,2,3) is 3 2 1 x on the stack) | |
Methods always have at least one argument -- "self", which is just the current object. | |
Instructions: | |
sys_init ; initialize system stuff |
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 Color | |
{ | |
public var r : Int; | |
public var g : Int; | |
public var b : Int; | |
public function new(r=255, g=255, b=255) | |
{ | |
this.r = r; | |
this.g = g; |
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
html | |
body { | |
p "hi there" | |
h1 ":)" | |
} |
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
# copyright 2012 darkf | |
import sys;_,s,h=sys.argv;[open(x,'w').writelines([y for y in open(h)if x.strip()in y])for x in open(s)] |
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
(* Take a tree of expressions in and output the expression tree of the differentiation of it. (or something like that.) | |
Copyright (c) 2012 darkf | |
MIT license | |
*) | |
(* Assignment: http://pastebin.com/tiRVsxNx | |
Graphs: http://f.imgtmp.com/FOVY7.jpg | |
*) | |
type Node = |
OlderNewer