Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading the whole tape #10

Open
patrikfejda opened this issue Apr 6, 2022 · 1 comment
Open

Reading the whole tape #10

patrikfejda opened this issue Apr 6, 2022 · 1 comment

Comments

@patrikfejda
Copy link

patrikfejda commented Apr 6, 2022

Is there some workaround to read the whole tape once the machine run is done (e.g. console log or anything)

Lets run the following unary (11=2, 111=3, 1111=4) calculator A+B:

input: '111111$1111#'
blank: ' '
start state: look_for_1
table:
  look_for_1:
    '$': R
    1: {write: 'X', R: write_1}
  write_1:
    [1, $, '#']: R
    ' ': {write: '1', L: go_to_very_left}
  go_to_very_left:
    ['#', 1, $]: L
    'X': {R: look_for_1}

there is no way we can read what is behind the end:
image

Any idea pls as a workaround for now ?

Maybe this issue would be worth consideration and some proper fix.

Thanks :)

@aepsilon
Copy link
Owner

aepsilon commented Apr 7, 2022

Agreed, it would be useful for longer inputs and outputs. I'm not working on it actively, but let me know if you come up with a workable design in your fork.

In the meantime, this will show the tape as a string in the JS console with a magnifying glass to the left of the tape head:

main.controller.simulator.machine.machine.tape.tape.toString()
'XXXXXX$XXXX🔎#1111111111'

To get an array rather than a string, you can filter and split the string, or concatenate the before and after arrays similar to what Tape.toString() does:

t = main.controller.simulator.machine.machine.tape.tape; t.before.concat(t.after.slice().reverse())
['X', 'X', 'X', 'X', 'X', 'X', '$', 'X', 'X', 'X', 'X', '#', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants