Skip to content

Instantly share code, notes, and snippets.

@cgranade
Created August 14, 2019 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgranade/ee913899e0b40e8ee8cd43b82632a454 to your computer and use it in GitHub Desktop.
Save cgranade/ee913899e0b40e8ee8cd43b82632a454 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"Bar\"]",
"text/html": [
"<ul><li>Bar</li></ul>"
],
"text/plain": [
"Bar"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"newtype Bar = (NotData: Int[]);"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"Boom\",\"Example\"]",
"text/html": [
"<ul><li>Boom</li><li>Example</li></ul>"
],
"text/plain": [
"Boom, Example"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"open Microsoft.Quantum.Arrays;\n",
"function Example() : Bar[] {\n",
" return Mapped(Bar, [[1, 2], [3, 4, 5], new Int[0], [16]]);\n",
"}\n",
"\n",
"function Boom() : Int {\n",
" let bars = Example();\n",
" return bars[0]::NotData[0];\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "1",
"text/plain": [
"1"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%simulate Boom"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"Foo\"]",
"text/html": [
"<ul><li>Foo</li></ul>"
],
"text/plain": [
"Foo"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"newtype Foo = (Data: Int[]);"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"Boom\",\"Example\"]",
"text/html": [
"<ul><li>Boom</li><li>Example</li></ul>"
],
"text/plain": [
"Boom, Example"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"open Microsoft.Quantum.Arrays;\n",
"function Example() : Foo[] {\n",
" return Mapped(Foo, [[1, 2], [3, 4, 5], new Int[0], [16]]);\n",
"}\n",
"\n",
"function Boom() : Int {\n",
" let foos = Example();\n",
" return foos[0]::Data[0];\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%simulate Boom"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Q#",
"language": "qsharp",
"name": "iqsharp"
},
"language_info": {
"file_extension": ".qs",
"mimetype": "text/x-qsharp",
"name": "qsharp",
"version": "0.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment