Published
Edited
Oct 5, 2020
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
output
Insert cell
Insert cell
tape2 = [... word]
Insert cell
transitions_array = d3.csvParse(transitions)
Insert cell
dot_notation = {
let t = transitions_array[2];
// return t.state + " -> " + t.new_state + '[label="' + '"';
let result = `${t.state} -> ${t.new_state} [label="${t.read} → ${t.write !== "" ? t.write + "," : ""} ${t.move}"]`
return result;
}
Insert cell
function transition_to_dot(t){
let result = `${t.state} -> ${t.new_state} [label="${t.read == " " ? "␣" : t.read} → ${t.write !== "" ? t.write + "," : ""} ${t.move}"]`;
return result;
}
Insert cell
function transition_to_text(t){
let result = `When in state ${t.state} and reading symbol ${t.read}: change the state to ${t.new_state},${t.write !== "" ? " write " + t.write + ",": ""} and move ${t.move == "R" ? "right" : "left"}.`;
return result;
}
Insert cell
transition_to_text(transitions_array[2])
Insert cell
transition_to_dot(transitions_array[2])
Insert cell
Insert cell
transitions_array.find(d => d.state == "q6" && d.read == "#")
Insert cell
find_transition = function(s, r) {
return transitions_array.find(d => d.state == s && d.read == r);
}
Insert cell
find_transition("q6", "#")
Insert cell
Insert cell
next_configuration({"tape": tape,
"state": "q1",
"head_position": 0,
"log": []})
Insert cell
tape = [... '00#00']
Insert cell
initial_configuration = ({"tape": tape,
"state": "q1",
"head_position": 0,
"log": []})
Insert cell
next_configuration(initial_configuration)
Insert cell
Insert cell
compute(initial_configuration)
Insert cell
log_i
Insert cell
tape_string = tape_with_head(log_i).join('')
Insert cell
exemplo_log = output.configuration.log[2]
Insert cell
function tape_with_head(d){
return d.tape.map((e,i) => i == d.head_position ? `[${e}]` : ` ${e} `)
}
Insert cell
tape_with_head(exemplo_log)
Insert cell
output = compute({"tape": tape2,
"state": "q1",
"head_position": 0,
"log": []})
Insert cell
// output.configuration.log.map(d => d.tape.join('')).join('\n')
Insert cell
log = output.configuration.log
Insert cell
Insert cell
split_tape(log[3])
Insert cell
Insert cell
dot = require("@observablehq/graphviz@0.2")
Insert cell
import {text} from "@jashkenas/inputs"
Insert cell
import {Scrubber} from "@mbostock/scrubber"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more