Skip to content

Instantly share code, notes, and snippets.

@RanjanSushant
Created December 24, 2021 12:44
Show Gist options
  • Save RanjanSushant/0b1a9ae87898ca2fdfaa02a5eeb1dfab to your computer and use it in GitHub Desktop.
Save RanjanSushant/0b1a9ae87898ca2fdfaa02a5eeb1dfab to your computer and use it in GitHub Desktop.
codesphere_q_js_demo
//creating the circuit for the bell state
const phiPlus = Q`
H-X#0
I-X#1
`
//rendering the circuit on the page
document.body.appendChild(phiPlus.toDom())
//simulating and reporting the results
const reportArr = phiPlus.report$().split('\n')
//Rendering the result on the page
for(let i = 1; i < reportArr.length - 1; i++) {
const div = document.createElement('div')
div.appendChild(document.createTextNode(reportArr[i]))
document.body.appendChild(div)
document.body.appendChild(document.createElement('br'))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment