More work on Ref doc, & stuff.
This commit is contained in:
parent
d833f1a3e9
commit
eb665f2b50
|
|
@ -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]
|
||||
|
|
@ -206,7 +206,7 @@ expressions, e.g.:
|
|||
------------------
|
||||
[a ...]
|
||||
</code></pre></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>Cons is a <a href="https://en.wikipedia.org/wiki/Cons#Lists">venerable old function from Lisp</a>.
|
||||
Its inverse operation is [uncons].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#uncons" class="func_name">uncons</a></div><div class="backlinks"><h3>Used By</h3><a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#ccons" class="func_name">ccons</a> <a href="#codi" class="func_name">codi</a> <a href="#grabN" class="func_name">grabN</a> <a href="#map" class="func_name">map</a> <a href="#nulco" class="func_name">nulco</a> <a href="#pow" class="func_name">pow</a> <a href="#reco" class="func_name">reco</a> <a href="#swons" class="func_name">swons</a> <a href="#unit" class="func_name">unit</a></div></div><hr><div><h2 id="dinfrirst" class="func_name">dinfrirst <a href="#dinfrirst" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Specialist function (that means I forgot what it does and why.)</p></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition"><a href="#dip">dip</a> <a href="#infrst">infrst</a></div></div><div class="backlinks"><h3>Used By</h3><a href="#nullary" class="func_name">nullary</a></div></div><hr><div><h2 id="dip" class="func_name">dip <a href="#dip" class="self_link">¶</a></h2><p><span class="kind">combinator</span> <span class="kind">built-in</span></p><div class="notes"><p>The <code>dip</code> combinator expects a quoted program on the stack and below it
|
||||
Its inverse operation is [uncons].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#uncons" class="func_name">uncons</a></div><div class="backlinks"><h3>Used By</h3><a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#ccons" class="func_name">ccons</a> <a href="#codi" class="func_name">codi</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#" class="func_name">dipddd</a> <a href="#grabN" class="func_name">grabN</a> <a href="#map" class="func_name">map</a> <a href="#nulco" class="func_name">nulco</a> <a href="#pow" class="func_name">pow</a> <a href="#reco" class="func_name">reco</a> <a href="#swons" class="func_name">swons</a> <a href="#unit" class="func_name">unit</a></div></div><hr><div><h2 id="dinfrirst" class="func_name">dinfrirst <a href="#dinfrirst" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Specialist function (that means I forgot what it does and why.)</p></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition"><a href="#dip">dip</a> <a href="#infrst">infrst</a></div></div><div class="backlinks"><h3>Used By</h3><a href="#nullary" class="func_name">nullary</a></div></div><hr><div><h2 id="dip" class="func_name">dip <a href="#dip" class="self_link">¶</a></h2><p><span class="kind">combinator</span> <span class="kind">built-in</span></p><div class="notes"><p>The <code>dip</code> 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. </p>
|
||||
<pre><code> ... x [Q] . dip
|
||||
|
|
@ -224,15 +224,15 @@ Continuation-Passing Style. The <code>dip</code> combinator could "set aside" t
|
|||
item and replace it after running <code>Q</code> but that means that there is an
|
||||
"extra space" where the item resides while <code>Q</code> 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.)</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#anamorphism" class="func_name">anamorphism</a> <a href="#and" class="func_name">and</a> <a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#b" class="func_name">b</a> <a href="#codi" class="func_name">codi</a> <a href="#dinfrirst" class="func_name">dinfrirst</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupd" class="func_name">dupd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#enstacken" class="func_name">enstacken</a> <a href="#grba" class="func_name">grba</a> <a href="#ii" class="func_name">ii</a> <a href="#infra" class="func_name">infra</a> <a href="#map" class="func_name">map</a> <a href="#or" class="func_name">or</a> <a href="#over" class="func_name">over</a> <a href="#popd" class="func_name">popd</a> <a href="#popopd" class="func_name">popopd</a> <a href="#quoted" class="func_name">quoted</a> <a href="#shift" class="func_name">shift</a> <a href="#b75cae41e7f9ba4ab72cc1c5ec83aa5313ea180fae61bc25370ce4e4b540c3c7" class="func_name">spiral_next</a> <a href="#stackd" class="func_name">stackd</a> <a href="#swapd" class="func_name">swapd</a> <a href="#unquoted" class="func_name">unquoted</a> <a href="#" class="func_name">unstack</a></div></div><hr><div><h2 id="dipd" class="func_name">dipd <a href="#dipd" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects two items.</p>
|
||||
pending expression (not counting modifications to the dictionary.)</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#anamorphism" class="func_name">anamorphism</a> <a href="#and" class="func_name">and</a> <a href="#d5856351bbc14599e687dac105150e8a919b21477f3c00386405228caac1e43a" class="func_name">app2</a> <a href="#b" class="func_name">b</a> <a href="#codi" class="func_name">codi</a> <a href="#dinfrirst" class="func_name">dinfrirst</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupd" class="func_name">dupd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#enstacken" class="func_name">enstacken</a> <a href="#grba" class="func_name">grba</a> <a href="#ii" class="func_name">ii</a> <a href="#infra" class="func_name">infra</a> <a href="#map" class="func_name">map</a> <a href="#or" class="func_name">or</a> <a href="#over" class="func_name">over</a> <a href="#popd" class="func_name">popd</a> <a href="#popopd" class="func_name">popopd</a> <a href="#quoted" class="func_name">quoted</a> <a href="#shift" class="func_name">shift</a> <a href="#b75cae41e7f9ba4ab72cc1c5ec83aa5313ea180fae61bc25370ce4e4b540c3c7" class="func_name">spiral_next</a> <a href="#stackd" class="func_name">stackd</a> <a href="#swapd" class="func_name">swapd</a> <a href="#unquoted" class="func_name">unquoted</a> <a href="#" class="func_name">unstack</a></div></div><hr><div><h2 id="dipd" class="func_name">dipd <a href="#dipd" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects two items.</p>
|
||||
<pre><code> ... y x [Q] . dipd
|
||||
-------------------------
|
||||
... . Q y x
|
||||
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#codi">codi</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#cmp" class="func_name">cmp</a> <a href="#dupdd" class="func_name">dupdd</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#ifte" class="func_name">ifte</a> <a href="#popdd" class="func_name">popdd</a> <a href="#popopdd" class="func_name">popopdd</a></div></div><hr><div><h2 id="dipdd" class="func_name">dipdd <a href="#dipdd" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects three items. :</p>
|
||||
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#codi">codi</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div><div class="backlinks"><h3>Used By</h3><a href="#cmp" class="func_name">cmp</a> <a href="#dipdd" class="func_name">dipdd</a> <a href="#" class="func_name">dipddd</a> <a href="#dupdd" class="func_name">dupdd</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#ifte" class="func_name">ifte</a> <a href="#popdd" class="func_name">popdd</a> <a href="#popopdd" class="func_name">popopdd</a></div></div><hr><div><h2 id="dipdd" class="func_name">dipdd <a href="#dipdd" class="self_link">¶</a></h2><p><span class="kind">combinator</span> </p><div class="notes"><p>Like [dip] but expects three items. :</p>
|
||||
<pre><code> ... z y x [Q] . dip
|
||||
-----------------------------
|
||||
... . Q z y x
|
||||
</code></pre></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div></div><hr><div><h2 id="disenstacken" class="func_name">disenstacken <a href="#disenstacken" class="self_link">¶</a></h2><p></p><div class="notes"><p>The <code>disenstacken</code> function expects a list on top of the stack and makes
|
||||
</code></pre></div><div class="definition_wrapper"><h3>Definition</h3><div class="definition">[<a href="#dip">dip</a>] <a href="#cons">cons</a> <a href="#dipd">dipd</a></div></div><div class="discussion_wrapper"><h3>Discussion</h3><div class="discussion"><p>See [dip].</p></div></div><div class="crosslinks"><h3>See Also</h3><a href="#dip" class="func_name">dip</a> <a href="#dipd" class="func_name">dipd</a> <a href="#dupdip" class="func_name">dupdip</a> <a href="#dupdipd" class="func_name">dupdipd</a> <a href="#infra" class="func_name">infra</a></div></div><hr><div><h2 id="disenstacken" class="func_name">disenstacken <a href="#disenstacken" class="self_link">¶</a></h2><p></p><div class="notes"><p>The <code>disenstacken</code> function expects a list on top of the stack and makes
|
||||
that the stack discarding the rest of the stack.</p>
|
||||
<pre><code> 1 2 3 [4 5 6] disenstacken
|
||||
--------------------------------
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<div class="discussion"><p>This works by building a little [while] program and running it:
|
||||
1 3 [++] • [-- dip] cons [swap] infra [0 >] swap while pop <br>
|
||||
1 3 [++] [-- dip] • cons [swap] infra [0 >] swap while pop <br>
|
||||
1 3 [[++] -- dip] • [swap] infra [0 >] swap while pop <br>
|
||||
1 3 [[++] -- dip] [swap] • infra [0 >] swap while pop
|
||||
dip -- [++] • swap [3 1] swaack [0 >] swap while pop <br>
|
||||
dip [++] -- • [3 1] swaack [0 >] swap while pop <br>
|
||||
dip [++] -- [3 1] • swaack [0 >] swap while pop <br>
|
||||
1 3 [-- [++] dip] • [0 >] swap while pop <br>
|
||||
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.</p></div>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
|
|
@ -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'<div class="{class_}">{html}</div>'
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
from html import escape
|
||||
from re import sub
|
||||
|
||||
|
||||
def j_replace(match):
|
||||
name = escape(match.group(0))
|
||||
return f'<a href="#{name}">{name}</a>'
|
||||
|
||||
def j_bod(body):
|
||||
return sub('[^ [\]]+', j_replace, body.strip())
|
||||
|
||||
defs = list(open('defs.txt'))
|
||||
|
||||
print('<dl>')
|
||||
|
||||
for d in defs:
|
||||
name, body = d.split(None, 1)
|
||||
name = escape(name)
|
||||
print(f' <dt id="{name}">{name}</dt> <dd>{j_bod(body)}</dd><br>')
|
||||
|
||||
print('</dl>')
|
||||
Loading…
Reference in New Issue