Jump to content

Execute Brain****/D: Difference between revisions

m
Fixed syntax highlighting.
(Better second D entry)
m (Fixed syntax highlighting.)
 
Line 1:
{{implementation|Brainf***}}{{collection|RCBF}}
===Version 1===
<langsyntaxhighlight lang="d">import core.stdc.stdio, core.stdc.stdlib, std.conv;
 
void brainfuckRun(in dstring code) nothrow {
Line 87:
+++.------.--------.>+.>.");
}
}</langsyntaxhighlight>
 
===Version 2===
Much faster version, code generated at compile-time, run at run-time:
<langsyntaxhighlight lang="d">string ctbf(in string code) pure nothrow {
string r;
foreach (immutable c; code)
Line 261:
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
<<<<<]]>>>]"));
}</langsyntaxhighlight>
LDC2 compiles this with full optimizations in 2.3 seconds, and the BF runs in less than 1.1 seconds.
9,488

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.