Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
Last active March 30, 2020 02:52
Show Gist options
  • Save ryan-williams/b2b0ef9365e050da361e37b6150dbc4a to your computer and use it in GitHub Desktop.
Save ryan-williams/b2b0ef9365e050da361e37b6150dbc4a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example `import`ing `scan` directly from this Gist\n",
"## Make sure `ur` is installed:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from sys import executable as python\n",
"!{python} -m pip install -q ur==0.1.3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Import from this Gist:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from gists.b2b0ef9365e050da361e37b6150dbc4a.scan_left import scan"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(this will work from other contexts / is not specific to this Gist)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use away!"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 3, 6, 10, 15, 21, 28, 36, 45]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from operator import add\n",
"scan(add, range(10))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "3.8.1",
"language": "python",
"name": "3.8.1"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment