Giter Site home page Giter Site logo

Comments (3)

kostya avatar kostya commented on May 30, 2024

this is strange, i not see any bug in implementation.

from benchmarks.

kostya avatar kostya commented on May 30, 2024

i think some bug in bottles.bf file, i find another example: https://raw.githubusercontent.com/andrewtholt/4th/1574fc7e3ed1a3a4d6085fca19469c125ae3f390/4th/apps/bf/bottles.b, this works ok

from benchmarks.

brk avatar brk commented on May 30, 2024

Using bf.py from the brainfuck2 directory:

$ python2 bf.py BOTTLES.BF
99 Bottles of beer on the wall
99 Bottles of beer
[...]
91 Bottles of beer on the wall
91 Bottles of beer
Take one down and pass it around
^C

Do you get different results?

The semantics of brainfuck are given on the Wikipedia page by translation to snippets of C code. In particular, [ and ] corresponds to a while-loop.

bf2c.hs does literally that: it generates snippets of C code for each character of brainfuck input.

$ runhaskell bf2c.hs < BOTTLES.BF > gen.c
$ gcc gen.c -o gen.exe
$ ./gen.exe
99 Bottles of beer on the wall
99 Bottles of beer
Take one down and pass it around
98 Bottles of beer on the wall
[...]
1 Bottle of beer on the wall
1 Bottle of beer
Take one down and pass it around
0 Bottles of beer on the wall

$

The linked BOTTLES.BF file produces different output in the two implementations. That means that either the Python interpreter has a subtle bug, or there's a bug in the translation into C code, right?

from benchmarks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.