Skip to content

Instantly share code, notes, and snippets.

@matthewfl
Created July 26, 2010 04:39
Show Gist options
  • Select an option

  • Save matthewfl/490189 to your computer and use it in GitHub Desktop.

Select an option

Save matthewfl/490189 to your computer and use it in GitHub Desktop.
function BF (code, get, print) {
eval("var i=0,d={0:0};"+code.replace(/[^\[\]\-\+\,\.\<\>]/g, "").replace(/\]/g, "}").replace(/\[/g, "while(d[i]) {").replace(/\-/g, "d[i]--;").replace(/\+/g, "d[i]++;").replace(/\</g, "i--;d[i]=d[i]?d[i]:0;").replace(/\>/g, "i++;d[i]=d[i]?d[i]:0;").replace(/\,/g, "d[i]=get();").replace(/\./g, "print(d[i]);"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment