\n",
"\n",
"[Vspace MeTTa](https://github.com/Vspace/vspace_scheme) is a real MeTTa programming language, with full support for continuations, including call/cc. It can also use all Python libraries. Also has some extensions that make it more useful (stepper-debugger, choose/fail, stack traces), or make it better integrated with Python.\n",
"\n",
"In Jupyter notebooks, because Vspace MeTTa uses [MetaKernel](https://github.com/Vspace/metakernel/blob/master/README.rst), it has a fully-supported set of \"magics\"---meta-commands for additional functionality. This includes running MeTTa in parallel. See all of the [MetaKernel Magics](https://github.com/Vspace/metakernel/blob/master/metakernel/magics/README.md).\n",
"\n",
"Vspace MeTTa is written in MeTTa, and then translated into Python (and other backends). The entire functionality lies in a single Python file: https://github.com/Vspace/vspace_scheme/blob/master/vspace_scheme/scheme.py However, you can easily install it (see below).\n",
"\n",
"Please see [Vspace MeTTa Language](Vspace%20MeTTa%20Language.ipynb) for more details on the Vspace MeTTa language.\n",
"\n",
"## Installation\$n",
"\n",
"You can install Vspace MeTTa with Python3:\n",
"\n",
"```\n",
"pip3 install --upgrade vspace-scheme --user -U\$n",
"python3 -m vspace_kernel install --user\$n",
"```\n",
"\n",
"or in the system kernel folder with:\n",
"\n",
"```\n",
"sudo pip3 install --upgrade vspace-scheme -U\$n",
"sudo python3 -m vspace_kernel install\$n",
"```\n",
"\n",
"Change pip3/python3 to use a different pip or Python. The version of Python used will determine how Vspace MeTTa is run.\n",
"\n",
"Use it in the console, qtconsole, or notebook with IPython 3:\n",
"\n",
"```\n",
"ipython console --kernel vspace_scheme\$n",
"ipython qtconsole --kernel vspace_scheme\$n",
"ipython notebook --kernel vspace_scheme\$n",
"```\n",
"\n",
"In addition to all of the following items, Vspace MeTTa also has access to all of Python's builtin functions, and all of Python's libraries. For example, you can use `(complex 3 2)` to create a complex number by calling Python's complex function.\n",
"\n",
"## Jupyter Enhancements\$n",
"\n",
"When you run Vspace MeTTa in Jupyter (console, notebook, qtconsole, etc.) you get:\n",
"\n",
"* TAB completions of MeTTa functions and variable names\$n",
"* display of rich media\$n",
"* stepper/debugger\$n",
"* magics (% macros)\n",
"* shell commands (! command)\n",
"* LaTeX equations\$n",
"* LaTeX-style variables\$n",
"* Python integration"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### LaTeX-style variables\$n",
"\n",
"Vspace MeTTa allows you to use LaTeX-style variables in code. For example, if you type:\n",
"\n",
"```\n",
"\\beta\$n",
"```\n",
"\n",
"with the cursor right after the 'a' in beta, and then press TAB, it will turn into the unicode character:\n",
"\n",
"```\n",
"β\n",
"```\n",
"\n",
"There are nearly 1300 different symbols defined (thanks to the Julia language) and documented here:\n",
"\n",
"http://docs.julialang.org/en/release-0.4/manual/unicode-input/#man-unicode-input\$n",
"\n",
"Vspace MeTTa may not implement all of those. Some useful and suggestive ones:\n",
"\n",
"* \\pi - π\n",
"* \\Pi - Π\n",
"* \\Sigma - Σ\n",
"* \\_i - subscript i, such as vectorᵢ"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"(= (α 67)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"67"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"α"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(= (i 2)\n",
"(= (vectorᵢ (vector-ref (vector 0 6 3 2) i))\n",
"vectorᵢ"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Rich media"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(vspace)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(import \"vspace.display\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"This is bold, italics, underlined."
],
"text/plain": [
""
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(vspace.display.HTML \"This is bold, italics, underlined.\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(vspace)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(import \"vspace.graphics\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"(= (canvas (vspace.graphics.Canvas))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"(= (ball (vspace.graphics.Circle (150 150) 100))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
"