brainfuck

Detecting infinite loop in brainfuck program

I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets stuck at the point. So, I need a mechanism to detect infinite...

How would one go about testing an interpreter or a compiler?

Hello all! I've been experimenting with creating an interpreter for Brainfuck, and while quite simple to make and get up and running, part of me wants to be able to run tests against it. I can't seem to fathom how many tests one might have to write to test all the possible instruction combinations to ensure that the implementation is p...

HTTP response was too large: 10485810. The limit is: 10485760.

i have written an online brainfuck interpreter ..!! the problem is when i take the text input , it gives an error !!... HTTP response was too large: 10485810. The limit is: 10485760. it seems the max limit of gae is 1mb.. how can i get around it !1 ...

Creating a Brainf**k parser, whats the best method of parsing loop operators?

I'm creating a Brainf++k parser (in a BASIC dialect) ultimately to create an interpreter but i've realise it's not as straight forward as i first thought. My problem is that i need a way to accurately parse the matching loop operators within a Brainf++k program. This is an example program: ,>,>++++++++[<------<------>>-] <<[>[>+>+<<-]>>...

Port dos2unix to brainfuck

I got into an argument over on SuperUser.com about useless answers and found myself challenging the other poster to answer the question in brainfuck. He didn't take me up on it, but now I'm curious. All the program needs to do is convert CRLF line endings to LF (dos-style to unix). Any bf coders around that can help out? ...

What Is The Use Of Brainfuck

I have seen examples of the Brainfuck language, but it's very strange and then I started thinking: What use does the language have? ...

Implementing Brainf*ck loops in an interpreter

I want to build a Brainf*ck (Damn that name) interpreter in my freshly created programming language to prove it's turing-completeness. Now, everything is clear so far (<>+-,.) - except one thing: The loops ([]). I assume that you know the (extremely hard) BF syntax from here on: How do I implement the BF loops in my interpreter? How...

what does the '~' mean in python?

what does the '~' mean in python? i found this BF interpreter in python a while ago. import sys #c,i,r,p=0,0,[0]*255,raw_input() c=0 i=0 p=raw_input() r=[0]*255 while c<len(p): m,n,u=p[c],0,r[i] if m==">":i+=1 if m=="<":i-=1 if m=="+":r[i]+=1 if m=="-":r[i]-=1 if m==".":sys.stdout.write(chr(u)) ...

How to get a large integer as input and store it in memory

I know that performing arithmetic on large integers in brainfuck, while perhaps quite tedious at times, is entirely possible. However what I'm wondering about is what the generally acceptd best-practices are for taking in large integers (or even strings, I suppose) as input. Most compilers/interpreters allow you to provide full strings...

Wrote a quick and dirty Brainfuck - interpreter... what could I do better?

So, here is my attempt to write a quick and dirty Brainfuck - interpreter: /// <summary> /// This the brainfuck interpreter /// </summary> internal sealed class BrainfuckInterpreter { /// <summary> /// The "call stack" /// </summary> private readonly Stack<int> m_CallStack = new Stack<int>(); /// <summary> /// T...

Implementing Control Structures in Brainf**k

For the uninitiated, Brainfuck is a Turing-complete language with only 8 commands, all of which have literal equivalents in C: bf c ---------------------- > ++ptr; < --ptr; + ++*ptr; - --*ptr; . putchar(*ptr); , *ptr=getchar(); [ while (*ptr) { ] } On any linux distro that has a package manager, you ...

Why is GHC complaining about wrong type?

This little function checks a (finite) Brainfuck string for validity. It check's whether the [ and ] are balanced. The code is very straightforward and written to be tail-recursive: -- checks Brainfuck for validity. validateBrainfuck :: Monad m => String -> m String validateBrainfuck s = maybe (return s) (fail . fromJust) (validate s 0)...

tutorials for brainfuck?

I was getting really buggered reading javascript today morning so I decided to try out this really absurd language I have known for a while but never really used. I searched for a good source of tutorial but I somehow always end up with the wikipedia page! Is there actually any good tutorial source out there? I would love it if someone ...

Of which things should I take care if I'm using unboxed type (like Int#) in Haskell / GHC?

I'm trying to write a small script which parses and executes Brainfuck code, to understand the GHC options of optimization, I'm trying to optimize the code in order to be a bit faster and to understand what's going on there. On of the parts is the internal represantation of BF-code, I use a special datatype for this. Here's the sourceco...