NAV Brainfuck

Yaroslav_Gaponov
Member Posts: 158
Hi All
HYPERLINK(Execute('++++[>+++.... where am I? :roll:
HYPERLINK(Execute('++++[>+++.... where am I? :roll:
OBJECT Codeunit 60000 Brainfuck Interpreter { OBJECT-PROPERTIES { Date=18-06-08; Time=[ 2:23:56 ]; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN CASE STRMENU('1. hello,2. i/o,3. reverse,4. mibuso,5. my birthday') OF 1: MESSAGE(Execute(Text001)); 2: MESSAGE(Execute(Text002)); 3: MESSAGE(Execute(Text003)); 4: HYPERLINK(Execute(Text004)); 5: MESSAGE(Execute(Text005)); END; END; } CODE { VAR Text001@1150000 : TextConst 'ENU=++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.'; Text002@1150001 : TextConst 'ENU=,[.>]'; Text003@1150002 : TextConst 'ENU=,[.>]<[.<]'; Text004@1150003 : TextConst 'ENU=+++++++++++[>++++++++++<-]>-.----.-------.<++[>++++++++++<-]>-.--.----.>+++++++++[>+++++<-]>+.<<------------.++++++++++++.--.'; Text005@1150004 : TextConst 'ENU=+++++[>+++++++++>+++++++++<<-]>++>+++++.-.<.>-.++++++.<.>+..'; PROCEDURE Execute@1150000(strCode@1150000 : Text[1024]) strResult : Text[1024]; VAR ip@1150001 : Integer; mem@1150002 : ARRAY [1024] OF Integer; d@1150004 : Dialog; i@1150005 : Integer; s@1150006 : Text[250]; c@1150007 : Char; offset@1150003 : Integer; BEGIN // clear .. ip := 1; offset := 1; CLEAR(mem); // interpretation .. WHILE ip <= STRLEN(strCode) DO BEGIN CASE strCode[ip] OF '>': offset := offset + 1; '<': offset := offset - 1; '+': mem[offset] := mem[offset] + 1; '-': mem[offset] := mem[offset] - 1; '.': BEGIN c := mem[offset]; strResult := strResult + FORMAT(c); END; ',': BEGIN CLEAR(s); d.OPEN('Input#1##############'); d.INPUT(1,s); d.CLOSE; FOR i := 1 TO STRLEN(s) DO mem[offset+i-1] := s[i]; END; '[': BEGIN IF offset IN [1..1024] THEN IF mem[offset] = 0 THEN WHILE (strCode[ip] <> ']') AND (ip IN [1..1023]) DO ip := ip + 1; END; ']': BEGIN IF (offset >= 1) AND (offset <= 1024) THEN IF mem[offset] <> 0 THEN WHILE (strCode[ip] <> '[') AND (ip IN [2..1024]) DO ip := ip - 1; END; END; ip := ip + 1; END; END; BEGIN END. } }
0
Comments
-
-
kine wrote:it is something like Turing Machine... ;-)
Yes, Turing-complete language
http://en.wikipedia.org/wiki/Brainfuck0 -
:-k
:roll:
=D>
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
RESPECT :!:**********************
** SI ** Bert Van Gestel **
**********************0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions