I hereby claim:
- I am duosrx on github.
- I am duosrx (https://keybase.io/duosrx) on keybase.
- I have a public key whose fingerprint is E7BB 0DC5 2071 C340 14A0 68DE 477F 5091 D9BC 863D
To claim this, I am signing this object:
import scala.util.parsing.combinator.RegexParsers | |
object BF extends App { | |
val raw = "+foobar+++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | |
val program = BFParser.parseAll(BFParser.program, raw).get | |
val vm = new VM(program) | |
vm.run | |
} | |
trait Command |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Main where | |
import Network (listenOn, withSocketsDo, accept, PortID(..), Socket) | |
import Control.Concurrent (forkIO) | |
import Control.Exception (handle, IOException) | |
import Control.Monad (liftM) | |
import System.IO (hSetBuffering, hPutStr, hClose, hGetContents, BufferMode(..), Handle, readFile) | |
import Debug.Trace |
I hereby claim:
To claim this, I am signing this object:
use std::char::from_u32; | |
use std::str::from_char; | |
#[deriving(Eq, Show)] | |
pub enum Command { | |
Add(int), | |
Move(int), | |
Output, | |
LoopIn, | |
LoopOut, |
package main | |
import ( | |
"crypto/rand" | |
"encoding/hex" | |
"encoding/json" | |
"fmt" | |
"github.com/garyburd/redigo/redis" | |
"io" | |
"time" |
set a, data | |
jsr strlen | |
set b, a | |
set a, data | |
jsr reverse | |
jsr print | |
set PC, end | |
; reverse the string in place at [a], of len b | |
:reverse |
# Partial Scheme interpreter | |
# Heavily inspired by Peter Norvig's Lispy (http://norvig.com/lispy.html) | |
# TODO: add more datatypes (strings, floats) | |
# TODO: allow multiple arguments, like (+ 1 2 3 4 5) | |
class Env < Hash | |
def initialize(ks = [], vs = [], outer = nil) | |
@outer = outer | |
ks.zip(vs).each {|item| store(item[0], item[1])} |
# 1.8 | |
> 1.to_a | |
[1] | |
> 1.respond_to?(:to_a) | |
true | |
> a,b = 10 | |
[10] | |
> a | |
[10] | |
> b |
# Befunge-93 interpreter (http://en.wikipedia.org/wiki/Befunge) | |
class BefungeParser | |
attr_accessor :stack, :program, :px, :py, :direction, :debug_mode | |
Binary_ops = ['*', '+', '-', '/', '%'] | |
def initialize(code) | |
@stack = [] | |
@program = [] | |
@px = 0 |
# A very simple Brainfuck interpreter | |
class BFParser | |
attr_accessor :memory, :loop_out, :loop_in, :code_size, :code | |
def initialize(code, stack_size = 10000) | |
@memory = [0] * stack_size | |
@code = code.split(//) | |
@code_size = code.length | |
@loop_in = [] |