• R/O
  • SSH

Joypy: コミット

This repo is not current. Development has moved from Hg to Git. For the latest code use the "Source Code" tab above to go to the "Thun" git repo or navigate to:
https://osdn.net/projects/joypy/scm/git/Thun


コミットメタ情報

リビジョン4425760ad7e8ed03c50a51bc528e8c8249a2d4c3 (tree)
日時2020-05-21 07:34:30
作者Simon Forman <sforman@hush...>
コミッターSimon Forman

ログメッセージ

Minor cleanup.

変更サマリ

差分

diff -r e8ea90b5c2d1 -r 4425760ad7e8 docs/Newton-Raphson.ipynb
--- a/docs/Newton-Raphson.ipynb Tue May 19 19:39:44 2020 -0700
+++ b/docs/Newton-Raphson.ipynb Wed May 20 15:34:30 2020 -0700
@@ -92,7 +92,7 @@
9292 },
9393 "outputs": [],
9494 "source": [
95- "define('gsra == 1 swap [over / + 2 /] cons [dup] swoncat make_generator')"
95+ "define('gsra 1 swap [over / + 2 /] cons [dup] swoncat make_generator')"
9696 ]
9797 },
9898 {
@@ -182,7 +182,7 @@
182182 "metadata": {},
183183 "outputs": [],
184184 "source": [
185- "define('_within_P == [first - abs] dip <=')"
185+ "define('_within_P [first - abs] dip <=')"
186186 ]
187187 },
188188 {
@@ -203,7 +203,7 @@
203203 "metadata": {},
204204 "outputs": [],
205205 "source": [
206- "define('_within_B == roll< popop first')"
206+ "define('_within_B roll< popop first')"
207207 ]
208208 },
209209 {
@@ -216,7 +216,7 @@
216216 "\n",
217217 "1. Discard a.\n",
218218 "2. Use `x` combinator to generate next term from `G`.\n",
219- "3. Run `within` with `i` (it is a `primrec` function.)\n",
219+ "3. Run `within` with `i` (it is a \"tail-recursive\" function.)\n",
220220 "\n",
221221 "Pretty straightforward:\n",
222222 "\n",
@@ -236,7 +236,7 @@
236236 "metadata": {},
237237 "outputs": [],
238238 "source": [
239- "define('_within_R == [popd x] dip')"
239+ "define('_within_R [popd x] dip')"
240240 ]
241241 },
242242 {
@@ -257,8 +257,8 @@
257257 "metadata": {},
258258 "outputs": [],
259259 "source": [
260- "define('within == x 0.000000001 [_within_P] [_within_B] [_within_R] primrec')\n",
261- "define('sqrt == gsra within')"
260+ "define('within x 0.000000001 [_within_P] [_within_B] [_within_R] tailrec')\n",
261+ "define('sqrt gsra within')"
262262 ]
263263 },
264264 {
@@ -367,14 +367,14 @@
367367 "language_info": {
368368 "codemirror_mode": {
369369 "name": "ipython",
370- "version": 2
370+ "version": 3
371371 },
372372 "file_extension": ".py",
373373 "mimetype": "text/x-python",
374374 "name": "python",
375375 "nbconvert_exporter": "python",
376- "pygments_lexer": "ipython2",
377- "version": "2.7.12"
376+ "pygments_lexer": "ipython3",
377+ "version": "3.8.3"
378378 }
379379 },
380380 "nbformat": 4,
diff -r e8ea90b5c2d1 -r 4425760ad7e8 docs/notebook_preamble.py
--- a/docs/notebook_preamble.py Tue May 19 19:39:44 2020 -0700
+++ b/docs/notebook_preamble.py Wed May 20 15:34:30 2020 -0700
@@ -29,7 +29,7 @@
2929
3030
3131 def J(text, stack=S, dictionary=D):
32- print stack_to_string(run(text, stack, dictionary)[0])
32+ print(stack_to_string(run(text, stack, dictionary)[0]))
3333
3434
3535 def V(text, stack=S, dictionary=D):
@@ -39,8 +39,8 @@
3939 except:
4040 exc = format_exc()
4141 tp.print_()
42- print '-' * 73
43- print exc
42+ print('-' * 73)
43+ print(exc)
4444 else:
4545 tp.print_()
4646
diff -r e8ea90b5c2d1 -r 4425760ad7e8 joy/joy.py
--- a/joy/joy.py Tue May 19 19:39:44 2020 -0700
+++ b/joy/joy.py Wed May 20 15:34:30 2020 -0700
@@ -25,7 +25,7 @@
2525 '''
2626 from __future__ import print_function
2727 from builtins import input
28-from traceback import print_exc, format_exc
28+from traceback import print_exc
2929 from .parser import text_to_expression, ParseError, Symbol
3030 from .utils.stack import stack_to_string
3131
@@ -103,8 +103,7 @@
103103 try:
104104 stack, _, dictionary = run(text, stack, dictionary)
105105 except:
106- exc = format_exc() # Capture the exception.
107- print(exc) # Print the original exception.
106+ print_exc()
108107 except:
109108 print_exc()
110109 print()
diff -r e8ea90b5c2d1 -r 4425760ad7e8 joy/utils/pretty_print.py
--- a/joy/utils/pretty_print.py Tue May 19 19:39:44 2020 -0700
+++ b/joy/utils/pretty_print.py Wed May 20 15:34:30 2020 -0700
@@ -20,22 +20,21 @@
2020 '''
2121 Pretty printing support, e.g.::
2222
23- Joy? 23 18 * 99 +
24- . 23 18 mul 99 add
25- 23 . 18 mul 99 add
26- 23 18 . mul 99 add
27- 414 . 99 add
28- 414 99 . add
29- 513 .
23+ Joy? [23 18 * 99 +] trace
24+ • 23 18 mul 99 add
25+ 23 • 18 mul 99 add
26+ 23 18 • mul 99 add
27+ 414 • 99 add
28+ 414 99 • add
29+ 513 •
3030
3131 513 <-top
3232
3333 joy?
3434
35-On each line the stack is printed with the top to the right, then a ``.`` to
36-represent the current locus of processing, then the pending expression to the
37-left.
38-
35+On each line the stack is printed with the top to the left, then a
36+bullet symbol,``•``, to represent the current locus of processing, then
37+the pending expression to the right.
3938 '''
4039 # (Kinda clunky and hacky. This should be swapped out in favor of much
4140 # smarter stuff.)
@@ -114,8 +113,8 @@
114113 n = len(stack)
115114 if n > max_stack_length:
116115 max_stack_length = n
117- lines.append((n, '%s . %s' % (stack, expression)))
118- return [ # Prefix spaces to line up '.'s.
116+ lines.append((n, '%s • %s' % (stack, expression)))
117+ return [ # Prefix spaces to line up '•'s.
119118 (' ' * (max_stack_length - length) + line)
120119 for length, line in lines
121120 ]
旧リポジトリブラウザで表示