Initial move of code from git repo.
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"3"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"1 2 +"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"9"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sqr"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": []
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"clear"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[\"tommy\" 23 [\"richard\" 48 [] []] [\"jenny\" 18 [] []]] "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] [first]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[first]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] [u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] [first]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[dup] dip"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] [u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] [not] [pop] [[first] dupdip] [[rest rest] dip step]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[not] [pop] roll< [dupdip] cons [[rest rest] dip step]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[u'tommy' 23 [u'richard' 48 [] []] [u'jenny' 18 [] []]] u'tommy' u'richard' u'jenny'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"genrec"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Joypy",
|
||||
"language": "",
|
||||
"name": "joypy"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".joy",
|
||||
"mimetype": "text/plain",
|
||||
"name": "Joy"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
from ipykernel.kernelbase import Kernel
|
||||
from joy.library import initialize
|
||||
from joy.joy import run
|
||||
from joy.utils.stack import stack_to_string
|
||||
|
||||
|
||||
class JoyKernel(Kernel):
|
||||
implementation = 'Joypy'
|
||||
implementation_version = '1.0'
|
||||
language = 'Joy'
|
||||
language_version = '0.1'
|
||||
language_info = {
|
||||
'name': 'Joy',
|
||||
'mimetype': 'text/plain',
|
||||
'file_extension': '.joy',
|
||||
}
|
||||
banner = "Echo kernel - as useful as a parrot"
|
||||
|
||||
def __init__(self, *a, **b):
|
||||
self.D = initialize()
|
||||
self.S = ()
|
||||
super(JoyKernel, self).__init__(*a, **b)
|
||||
|
||||
def do_execute(
|
||||
self,
|
||||
code,
|
||||
silent,
|
||||
store_history=True,
|
||||
user_expressions=None,
|
||||
allow_stdin=False,
|
||||
):
|
||||
self.S = run(code, self.S, self.D)[0]
|
||||
if not silent:
|
||||
stream_content = {
|
||||
'name': 'stdout',
|
||||
'text': stack_to_string(self.S),
|
||||
}
|
||||
self.send_response(self.iopub_socket, 'stream', stream_content)
|
||||
|
||||
return {'status': 'ok',
|
||||
# The base class increments the execution count
|
||||
'execution_count': self.execution_count,
|
||||
'payload': [],
|
||||
'user_expressions': {},
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from ipykernel.kernelapp import IPKernelApp
|
||||
IPKernelApp.launch_instance(kernel_class=JoyKernel)
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"argv": ["python", "-m", "joy_kernel", "-f", "{connection_file}"],
|
||||
"display_name": "Joypy"
|
||||
}
|
||||
Reference in New Issue
Block a user