Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
tangentstorm / words.cpp
Last active December 11, 2015 17:08
c++ experiment : does cin split on any whitespace, or on newline? ( answer : whitespace )
#include <iostream>
#include <string>
int main() {
std::string word;
int i;
std::cout << "enter 3 words: ";
for ( i = 0; i < 3; ++i ) {
@tangentstorm
tangentstorm / trailblazer.py
Created January 29, 2013 18:54
very old prototype version of trailblazer ( 2005 )
#!/bin/env python
"""
trailblazer: a narrative programming tool
(c) copyright 2005 sabren enterprises inc. all rights reserved.
"""
"""
<h1>the trailblazer experiment</h1>
Narrative programming is like literate programming with version
@tangentstorm
tangentstorm / grid.hx
Last active December 14, 2015 04:39
penominos in haxe
import Substance;
class Grid
{
public var data : Array<Array<Int>>;
public var width:Int;
public var depth:Int;
public function new (proto, width:Int=-1, depth:Int=-1)
{
// Copyright (c) 2011 Michal J Wallace and Sean D. Siem
// See the file license.txt for copying permission.
// $Id: Grid.cs 993 2012-10-15 19:56:23Z mwallace $
using System;
using System.Collections.Generic;
using System.Text;
using JsonFx.Json;
namespace AlchementrixCore
#include <iostream>
using namespace std;
void stepIntoMe()
{
cout << "inside the subroutine" << endl;
}
int main()
#include<stdio.h>
// program to challenge the assertion that
// c disallows switching on characters.
int main() {
char ch;
for (ch = 'a'; ch < 'z'; ch++) {
switch(ch) {
case 't': printf("t[angentstorm]"); break;
@tangentstorm
tangentstorm / b4-macros.js
Last active December 14, 2015 07:29
Work in progress : macros for b4a.js ... These are actually more like mini-compilers. Basically the idea is that when you see a word like `.if` , it's going to define `.then` and `.else` on the fly... This way if you encounter an `.else` that is not inside an `.if`, it will be a syntax error. The assembly code should wind up looking a lot more l…
// when asm( ) encounters a word that starts with punctuation,
// it will not try to compile a call to that word, but will instead
// look up the word's definition in the "macro" vocabulary, and
// execute the macro immediately.
//
// The macros are written in javascript.
// semicolon. in forth this would issue a 'return' instruction,
// but in b4, it's used as punctuation. In the default context,
// it doesn't do anything, but it can be used to break long
@tangentstorm
tangentstorm / objpas-lexer.txt
Created February 27, 2013 19:35
Lexer DFA for object pascal
[[a[nd
|rray
|s
|sm]
|b[egin]
|c[ase
|lass
|onst[
|ructor]]
|d[e[structor
# B4 - a bootstrap assembler for Ngaro/RetroVM
# --------------------------------------------------------------
# This is a tiny, pure-binary forth interpreter. Input consists
# of 4-byte sequences, which can either be ngaro instructions or
# space-terminated strings.
# Data area.
# --------------------------------------------------------------
# When ngaro boots up, the instruction pointer is set to zero, which
@tangentstorm
tangentstorm / disks.py
Created March 12, 2013 06:36
Array programming with numpy.
# -*- coding: utf-8 -*-
"""
colliding disks
"""
import numpy as np
import numpy.random as nr
n = 10 # number of discs
w = 100 # width