diff --git a/docs/Safety.txt b/docs/Safety.txt new file mode 100644 index 0000000..ce2dbb8 --- /dev/null +++ b/docs/Safety.txt @@ -0,0 +1,23 @@ + + size <- step_zero <- step <- uncons + +Somewhere in there it breaks, e.g. (Nim): + + [cats ...] + joy? size + Unknown: cats + + + +w/ + ++d == [++] dip + +We can define a "safe" version of `size` like so: + + size == 0 swap ? [++d rest ?] loop pop + +But I hate the idea of "safe" here. +Either it's user error for calling `size` on a quoted program, +or we should "safe"en the core words? + +safe version of uncons == [first] dupdip [rest] diff --git a/docs/html/FuncRef.html b/docs/html/FuncRef.html index ad347b4..f417ac8 100644 --- a/docs/html/FuncRef.html +++ b/docs/html/FuncRef.html @@ -206,7 +206,7 @@ expressions, e.g.: ------------------ [a ...]
Cons is a venerable old function from Lisp. -Its inverse operation is [uncons].
combinator built-in
The dip combinator expects a quoted program on the stack and below it
+Its inverse operation is [uncons].
combinator built-in
The dip combinator expects a quoted program on the stack and below it
some item, it hoists the item into the expression and runs the program
on the rest of the stack.
... x [Q] . dip
@@ -224,15 +224,15 @@ Continuation-Passing Style. The dip combinator could "set aside" t
item and replace it after running Q but that means that there is an
"extra space" where the item resides while Q runs. One of the nice
things about CPS is that the whole state is recorded in the stack and
-pending expression (not counting modifications to the dictionary.)combinator
Like [dip] but expects two items.
+pending expression (not counting modifications to the dictionary.)combinator
Like [dip] but expects two items.
... y x [Q] . dipd
-------------------------
... . Q y x
-See [dip].
combinator
Like [dip] but expects three items. :
... z y x [Q] . dip
-----------------------------
... . Q z y x
-See [dip].
The disenstacken function expects a list on top of the stack and makes
+
See [dip].
The disenstacken function expects a list on top of the stack and makes
that the stack discarding the rest of the stack.
1 2 3 [4 5 6] disenstacken
--------------------------------
diff --git a/docs/html/damnit.html b/docs/html/damnit.html
new file mode 100644
index 0000000..23d57ce
--- /dev/null
+++ b/docs/html/damnit.html
@@ -0,0 +1,16 @@
+This works by building a little [while] program and running it:
+ 1 3 [++] • [-- dip] cons [swap] infra [0 >] swap while pop
+ 1 3 [++] [-- dip] • cons [swap] infra [0 >] swap while pop
+ 1 3 [[++] -- dip] • [swap] infra [0 >] swap while pop
+ 1 3 [[++] -- dip] [swap] • infra [0 >] swap while pop
+ dip -- [++] • swap [3 1] swaack [0 >] swap while pop
+ dip [++] -- • [3 1] swaack [0 >] swap while pop
+ dip [++] -- [3 1] • swaack [0 >] swap while pop
+ 1 3 [-- [++] dip] • [0 >] swap while pop
+ 1 3 [-- [++] dip] [0 >] • swap while pop
+ 1 3 [0 >] [-- [++] dip] • while pop
+This is a common pattern in Joy. You accept some parameters from the
+stack which typically include qouted programs and use them to build
+another program which does the actual work. This is kind of like macros
+in Lisp, or preprocessor directives in C.
+
diff --git a/docs/misc/grammar.png b/docs/misc/grammar.png
new file mode 100644
index 0000000..f149f98
Binary files /dev/null and b/docs/misc/grammar.png differ
diff --git a/docs/misc/grammar_extended_integer.png b/docs/misc/grammar_extended_integer.png
new file mode 100644
index 0000000..d1806b0
Binary files /dev/null and b/docs/misc/grammar_extended_integer.png differ
diff --git a/docs/reference/to_html.py b/docs/reference/to_html.py
index 778bc68..8738e22 100644
--- a/docs/reference/to_html.py
+++ b/docs/reference/to_html.py
@@ -45,7 +45,7 @@ for el in used_by.values():
-def foo(to, text, class_='notes'):
+def marken_down(to, text, class_='notes'):
html = markdown.markdown(text, output_format="html5")
html = f'{html}'
try:
@@ -129,6 +129,12 @@ for name, section in sections.items():
del section[i:]
+for name in sections:
+ sections[name] = '\n'.join(sections[name])
+for name in discussions:
+ discussions[name] = '\n'.join(discussions[name])
+
+
def add_definition(to, name):
try:
defi = definitions[name]
@@ -142,11 +148,11 @@ def add_definition(to, name):
b, e = match.span()
if b != start:
to += defi[start:b]
- foo = match.group()
- if foo.isnumeric() or foo == 'true' or foo == 'false':
- to += foo
+ m = match.group()
+ if m.isnumeric() or m == 'true' or m == 'false':
+ to += m
else:
- to.a(foo, href='#' + get_anchor(foo))
+ to.a(m, href='#' + get_anchor(m))
start = e
end = defi[start:]
if end:
@@ -190,7 +196,7 @@ def add_discussion(to, name):
return
to = to.div(class_='discussion_wrapper')
to.h3('Discussion')
- foo(to, '\n'.join(discussion), class_='discussion')
+ marken_down(to, discussion, class_='discussion')
def add_backlinks(to, name):
@@ -244,7 +250,7 @@ with doc.body as b:
if name in basis_functions:
tags.span('built-in', class_='kind')
- foo(d, '\n'.join(section))
+ marken_down(d, section)
add_definition(d, name)
add_discussion(d, name)
@@ -257,8 +263,17 @@ print(html_string, file=open('../html/FuncRef.html', 'w'))
#from bs4 import BeautifulSoup
#print(BeautifulSoup(html_string, 'html.parser').prettify())
-##import pprint
-##pprint.pprint(crosslinks)
+import pprint
+#pprint.pprint(crosslinks)
+
+##def pprint_data():
+## print('sections = ', end='')
+## pprint.pprint(sections)
+## print()
+## print('discussions = ', end='')
+## pprint.pprint(discussions)
+
+
##if non:
## for n in sorted(non):
@@ -271,3 +286,5 @@ E = S - D - basis_functions
print('Def but no ref:', ' '.join(sorted(W)))
print('Ref but no def:', ' '.join(sorted(E)))
+
+##pprint_data()
diff --git a/docs/source/notebooks/Unity_of_times_and_step.md b/docs/source/notebooks/Unity_of_times_and_step.md
new file mode 100644
index 0000000..6db76f4
--- /dev/null
+++ b/docs/source/notebooks/Unity_of_times_and_step.md
@@ -0,0 +1,29 @@
+
+[... [...] [... x] branch] x
+
+
+step [_step0] x
+_step0 _step1 [popopop] [_stept] branch
+_step1 [?] dipd roll<
+_stept [uncons] dipd [dupdipd] dip x
+
+
+times [_times0] x
+_times0 _times1 [popopop] [_timest] branch
+_times1 [dup 0 >] dipd roll<
+_timest [--] dipd [dupdipd] dip x
+
+
+[[A] dipd roll< [popopop] [[B] dipd [dupdipd] dip x] branch] x
+
+
+H == dipd [dupdipd] dip
+J == dipd roll<
+
+[[A] J [popopop] [[B] H x] branch] x
+
+[A] [B]
+[?] [uncons] step
+[dup 0 >] [--] times
+
+
diff --git a/implementations/as_dl.py b/implementations/as_dl.py
new file mode 100644
index 0000000..1e50cf9
--- /dev/null
+++ b/implementations/as_dl.py
@@ -0,0 +1,21 @@
+from html import escape
+from re import sub
+
+
+def j_replace(match):
+ name = escape(match.group(0))
+ return f'{name}'
+
+def j_bod(body):
+ return sub('[^ [\]]+', j_replace, body.strip())
+
+defs = list(open('defs.txt'))
+
+print('')
+
+for d in defs:
+ name, body = d.split(None, 1)
+ name = escape(name)
+ print(f' - {name}
- {j_bod(body)}
')
+
+print('
')