Fixed bug in appN
while updating some Jupyter notebooks with the Joypy kernel.
This commit is contained in:
parent
3d1dc6232e
commit
b2a1f40155
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +1,5 @@
|
||||||
{
|
{
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from notebook_preamble import J, V, define"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
|
@ -110,11 +101,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 1,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"define('quadratic == over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2')"
|
"[quadratic over [[[neg] dupdip sqr 4] dipd * * - sqrt pm] dip 2 * [/] cons app2] inscribe"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -126,19 +123,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"-0.3819660112501051 -2.618033988749895\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"J('3 1 1 quadratic')"
|
"3 1 1 quadratic"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -219,21 +208,14 @@
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3 (ipykernel)",
|
"display_name": "Joypy",
|
||||||
"language": "python",
|
"language": "",
|
||||||
"name": "python3"
|
"name": "thun"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"file_extension": ".joy",
|
||||||
"name": "ipython",
|
"mimetype": "text/plain",
|
||||||
"version": 3
|
"name": "Joy"
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.7.10"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
||||||
|
|
@ -75,24 +75,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
" [1 [2 [3 4 25 6] 7] 8] • z-down\n",
|
|
||||||
" [1 [2 [3 4 25 6] 7] 8] • [] swap uncons swap\n",
|
|
||||||
"[1 [2 [3 4 25 6] 7] 8] [] • swap uncons swap\n",
|
|
||||||
"[] [1 [2 [3 4 25 6] 7] 8] • uncons swap\n",
|
|
||||||
"[] 1 [[2 [3 4 25 6] 7] 8] • swap\n",
|
|
||||||
"[] [[2 [3 4 25 6] 7] 8] 1 • \n",
|
|
||||||
"\n",
|
|
||||||
"[] [[2 [3 4 25 6] 7] 8] 1"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"[z-down] trace"
|
"[z-down] trace"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
import sys
|
import sys
|
||||||
from ipykernel.kernelbase import Kernel
|
from ipykernel.kernelbase import Kernel
|
||||||
from joy.library import default_defs, initialize, inscribe
|
from simplejoy import (
|
||||||
from joy.joy import run
|
default_defs,
|
||||||
from joy.utils.stack import stack_to_string
|
initialize,
|
||||||
from joy.utils.pretty_print import trace
|
inscribe,
|
||||||
|
run,
|
||||||
|
stack_to_string,
|
||||||
|
)
|
||||||
|
#from joy.utils.pretty_print import trace
|
||||||
|
|
||||||
|
|
||||||
inscribe(trace)
|
#inscribe(trace)
|
||||||
|
|
||||||
|
|
||||||
class FileFaker:
|
class FileFaker:
|
||||||
|
|
@ -35,13 +39,13 @@ class JoyKernel(Kernel):
|
||||||
implementation = 'Joypy'
|
implementation = 'Joypy'
|
||||||
implementation_version = '1.0'
|
implementation_version = '1.0'
|
||||||
language = 'Joy'
|
language = 'Joy'
|
||||||
language_version = '0.1'
|
language_version = '0.5'
|
||||||
language_info = {
|
language_info = {
|
||||||
'name': 'Joy',
|
'name': 'Joy',
|
||||||
'mimetype': 'text/plain',
|
'mimetype': 'text/plain',
|
||||||
'file_extension': '.joy',
|
'file_extension': '.joy',
|
||||||
}
|
}
|
||||||
banner = "Echo kernel - as useful as a parrot"
|
banner = "Joy kernel"
|
||||||
|
|
||||||
def __init__(self, *a, **b):
|
def __init__(self, *a, **b):
|
||||||
self.D = initialize()
|
self.D = initialize()
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ anamorphism ≡ [pop []] swap [dip swons] genrec
|
||||||
app1 ≡ grba infrst
|
app1 ≡ grba infrst
|
||||||
app2 ≡ [grba swap grba swap] dip [infrst] cons ii
|
app2 ≡ [grba swap grba swap] dip [infrst] cons ii
|
||||||
app3 ≡ 3 appN
|
app3 ≡ 3 appN
|
||||||
appN ≡ [grabN] codi map disenstacken
|
appN ≡ [grabN] codi map reverse disenstacken
|
||||||
|
|
||||||
at ≡ drop first
|
at ≡ drop first
|
||||||
|
|
||||||
|
|
@ -307,9 +307,9 @@ def joy(stack, expression, dictionary):
|
||||||
'''
|
'''
|
||||||
expr = push_quote(expression) # We keep a stack-of-stacks, see below.
|
expr = push_quote(expression) # We keep a stack-of-stacks, see below.
|
||||||
while expr:
|
while expr:
|
||||||
print(
|
## print(
|
||||||
f'{stack_to_string(stack)} • {expr_to_string(expr)}'
|
## f'{stack_to_string(stack)} • {expr_to_string(expr)}'
|
||||||
)
|
## )
|
||||||
term, expr = next_term(expr)
|
term, expr = next_term(expr)
|
||||||
if isinstance(term, Symbol):
|
if isinstance(term, Symbol):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2226,12 +2226,16 @@ def times(stack, expr, dictionary):
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
||||||
|
def default_defs(dictionary):
|
||||||
|
Def.load_definitions(__doc__.splitlines(), dictionary)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
J = interp if '-q' in sys.argv else repl
|
J = interp if '-q' in sys.argv else repl
|
||||||
dictionary = initialize()
|
dictionary = initialize()
|
||||||
Def.load_definitions(__doc__.splitlines(), dictionary)
|
default_defs(dictionary)
|
||||||
try:
|
try:
|
||||||
stack = J(dictionary=dictionary)
|
stack = J(dictionary=dictionary)
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ anamorphism [pop []] swap [dip swons] genrec
|
||||||
app1 grba infrst
|
app1 grba infrst
|
||||||
app2 [grba swap grba swap] dip [infrst] cons ii
|
app2 [grba swap grba swap] dip [infrst] cons ii
|
||||||
app3 3 appN
|
app3 3 appN
|
||||||
appN [grabN] codi map disenstacken
|
appN [grabN] codi map reverse disenstacken
|
||||||
at drop first
|
at drop first
|
||||||
average [sum] [size] cleave /
|
average [sum] [size] cleave /
|
||||||
b [i] dip i
|
b [i] dip i
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue