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": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from notebook_preamble import J, V, define"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
|
@ -110,11 +101,17 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": []
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"-0.3819660112501051 -2.618033988749895\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"J('3 1 1 quadratic')"
|
||||
"3 1 1 quadratic"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -219,21 +208,14 @@
|
|||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
"display_name": "Joypy",
|
||||
"language": "",
|
||||
"name": "thun"
|
||||
},
|
||||
"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.7.10"
|
||||
"file_extension": ".joy",
|
||||
"mimetype": "text/plain",
|
||||
"name": "Joy"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
|
|
@ -75,24 +75,9 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"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"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"[z-down] trace"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
import sys
|
||||
from ipykernel.kernelbase import Kernel
|
||||
from joy.library import default_defs, initialize, inscribe
|
||||
from joy.joy import run
|
||||
from joy.utils.stack import stack_to_string
|
||||
from joy.utils.pretty_print import trace
|
||||
from simplejoy import (
|
||||
default_defs,
|
||||
initialize,
|
||||
inscribe,
|
||||
run,
|
||||
stack_to_string,
|
||||
)
|
||||
#from joy.utils.pretty_print import trace
|
||||
|
||||
|
||||
inscribe(trace)
|
||||
#inscribe(trace)
|
||||
|
||||
|
||||
class FileFaker:
|
||||
|
|
@ -35,13 +39,13 @@ class JoyKernel(Kernel):
|
|||
implementation = 'Joypy'
|
||||
implementation_version = '1.0'
|
||||
language = 'Joy'
|
||||
language_version = '0.1'
|
||||
language_version = '0.5'
|
||||
language_info = {
|
||||
'name': 'Joy',
|
||||
'mimetype': 'text/plain',
|
||||
'file_extension': '.joy',
|
||||
}
|
||||
banner = "Echo kernel - as useful as a parrot"
|
||||
banner = "Joy kernel"
|
||||
|
||||
def __init__(self, *a, **b):
|
||||
self.D = initialize()
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ anamorphism ≡ [pop []] swap [dip swons] genrec
|
|||
app1 ≡ grba infrst
|
||||
app2 ≡ [grba swap grba swap] dip [infrst] cons ii
|
||||
app3 ≡ 3 appN
|
||||
appN ≡ [grabN] codi map disenstacken
|
||||
appN ≡ [grabN] codi map reverse disenstacken
|
||||
|
||||
at ≡ drop first
|
||||
|
||||
|
|
@ -307,9 +307,9 @@ def joy(stack, expression, dictionary):
|
|||
'''
|
||||
expr = push_quote(expression) # We keep a stack-of-stacks, see below.
|
||||
while expr:
|
||||
print(
|
||||
f'{stack_to_string(stack)} • {expr_to_string(expr)}'
|
||||
)
|
||||
## print(
|
||||
## f'{stack_to_string(stack)} • {expr_to_string(expr)}'
|
||||
## )
|
||||
term, expr = next_term(expr)
|
||||
if isinstance(term, Symbol):
|
||||
try:
|
||||
|
|
@ -2226,12 +2226,16 @@ def times(stack, expr, dictionary):
|
|||
return stack, expr, dictionary
|
||||
|
||||
|
||||
def default_defs(dictionary):
|
||||
Def.load_definitions(__doc__.splitlines(), dictionary)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
J = interp if '-q' in sys.argv else repl
|
||||
dictionary = initialize()
|
||||
Def.load_definitions(__doc__.splitlines(), dictionary)
|
||||
default_defs(dictionary)
|
||||
try:
|
||||
stack = J(dictionary=dictionary)
|
||||
except SystemExit:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ anamorphism [pop []] swap [dip swons] genrec
|
|||
app1 grba infrst
|
||||
app2 [grba swap grba swap] dip [infrst] cons ii
|
||||
app3 3 appN
|
||||
appN [grabN] codi map disenstacken
|
||||
appN [grabN] codi map reverse disenstacken
|
||||
at drop first
|
||||
average [sum] [size] cleave /
|
||||
b [i] dip i
|
||||
|
|
|
|||
Loading…
Reference in New Issue