[Joypy-announce] joypy/Joypy: 7 new changesets

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
Thu Aug 8 15:37:05 JST 2019


changeset a46b3e66c32b in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=a46b3e66c32b
user: Simon Forman <sform****@hushm*****>
date: Sun Jul 21 17:25:22 2019 -0700
description: Refactor a bit.
changeset 70c8c61a6348 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=70c8c61a6348
user: Simon Forman <sform****@hushm*****>
date: Sun Jul 21 17:55:19 2019 -0700
description: Build a list of the moves taken.
changeset 6b7fb58939dd in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=6b7fb58939dd
user: Simon Forman <sform****@hushm*****>
date: Sun Jul 21 17:56:34 2019 -0700
description: Remove write_state/5.
changeset e0bb7270735a in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=e0bb7270735a
user: Simon Forman <sform****@hushm*****>
date: Sun Jul 21 18:48:11 2019 -0700
description: Minor cleanup.
changeset 3684eb1c812d in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=3684eb1c812d
user: Simon Forman <sform****@hushm*****>
date: Mon Jul 22 10:04:32 2019 -0700
description: Bits of formatting.
changeset d01587221105 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=d01587221105
user: Simon Forman <sform****@hushm*****>
date: Mon Jul 22 10:25:34 2019 -0700
description: Comparisions are literals too.

Also a bunch of reformatting.

Maybe I can modify the term_expansion/2 to also write the literal/1 clauses for math and comps?
changeset 7763457c8c8b in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=7763457c8c8b
user: Simon Forman <sform****@hushm*****>
date: Wed Aug 07 23:36:38 2019 -0700
description: merge

diffstat:

 joy/gui/textwidget.py |    3 +-
 joy/gui/utils.py      |   10 ++-
 joy/gui/world.py      |   10 +--
 thun/TLA.pl           |  156 ++++++++++++++++++++++++++++++++++++++++---------
 thun/metalogical.pl   |   29 ++++++++-
 thun/thun.pl          |   87 ++++++++++++++++++++++-----
 6 files changed, 235 insertions(+), 60 deletions(-)

diffs (truncated from 446 to 300 lines):

diff -r 2c9153571cee -r 7763457c8c8b joy/gui/textwidget.py
--- a/joy/gui/textwidget.py	Sun Jul 21 14:13:48 2019 -0700
+++ b/joy/gui/textwidget.py	Wed Aug 07 23:36:38 2019 -0700
@@ -49,7 +49,8 @@
 from joy.utils.stack import stack_to_string
 
 from .mousebindings import MouseBindingsMixin
-from .world import World, is_numerical
+from .utils import is_numerical
+from .world import World
 
 
 def make_gui(dictionary):
diff -r 2c9153571cee -r 7763457c8c8b joy/gui/utils.py
--- a/joy/gui/utils.py	Sun Jul 21 14:13:48 2019 -0700
+++ b/joy/gui/utils.py	Wed Aug 07 23:36:38 2019 -0700
@@ -7,7 +7,15 @@
 
 
 COMMITTER = 'Joy <auto-****@examp*****>'
-DEFAULT_JOY_HOME = '~/.joypy'
+DEFAULT_JOY_HOME = expanduser(join('~', '.joypy'))
+
+
+def is_numerical(s):
+  try:
+    float(s)
+  except ValueError:
+    return False
+  return True
 
 
 def home_dir(path):
diff -r 2c9153571cee -r 7763457c8c8b joy/gui/world.py
--- a/joy/gui/world.py	Sun Jul 21 14:13:48 2019 -0700
+++ b/joy/gui/world.py	Wed Aug 07 23:36:38 2019 -0700
@@ -28,14 +28,7 @@
 from joy.parser import Symbol
 from joy.utils.stack import stack_to_string
 from joy.utils.types import type_check
-
-
-def is_numerical(s):
-  try:
-    float(s)
-  except ValueError:
-    return False
-  return True
+from .utils import is_numerical
 
 
 class World(object):
@@ -121,7 +114,6 @@
 
 class StackDisplayWorld(World):
 
-  
   def __init__(self, repo, filename, rel_filename, dictionary=None, text_widget=None):
     self.filename = filename
     stack = self.load_stack() or ()
diff -r 2c9153571cee -r 7763457c8c8b thun/TLA.pl
--- a/thun/TLA.pl	Sun Jul 21 14:13:48 2019 -0700
+++ b/thun/TLA.pl	Wed Aug 07 23:36:38 2019 -0700
@@ -37,50 +37,146 @@
 
 
 
-type_ok(Small, Big) :- Small in 0..3, Big in 0..5.
-
-initi :- die_hard(0, 0, _, _).
-
-next_dh(Small, Big, S, B) :-
-    B #\= 4,
-    type_ok(Small, Big),
-    die_hard(Small, Big, Si, Bi),
-    write(Small), write(" "), write(Big), write(" -> "), write(Si), write(" "), writeln(Bi),
-    (Bi = 4 -> true ; next_dh(Si, Bi, S, B)).
-next_dh(_, _, _, 4).
 
 
 
-% die_hard(Small, Big, S, B).
-die_hard(Small, Big, 3, Big) :- Small #\= 3, writeln("fill small").  % Fill small.
-die_hard(Small, Big, Small, 5) :- Big #\= 5, writeln("fill big").  % Fill big.
 
-die_hard(Small, Big, 0, Big) :- Small #> 0, writeln("empty small").  % empty small.
-die_hard(Small, Big, Small, 0) :- Big #> 0, writeln("empty big").  % empty big.
 
-die_hard(Small, Big, 0, B) :-  % small to big.
-    Big #< 5, Small #> 0,
-    Small + Big #=< 5,
-    B is Small + Big, writeln("small to big").    
-die_hard(Small, Big, S, 5) :-  % small to big.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+type_ok(Small, Big) :- Small in 0..3, Big in 0..5.
+
+
+next_dh(Moves) :- next_dh(0, 0, Moves).
+
+next_dh(Small, Big, [[Move, Si, Bi]|Moves]) :-
+    type_ok(Small, Big),
+    die_hard(Move, Small, Big, Si, Bi),
+    (Bi = 4 -> Moves = [] ; next_dh(Si, Bi, Moves)).
+
+
+die_hard( fill_small, Small, Big, 3, Big) :- Small #< 3.
+die_hard(   fill_big, Small, Big, Small, 5) :- Big #< 5.
+die_hard(empty_small, Small, Big, 0, Big) :- Small #> 0.
+die_hard(  empty_big, Small, Big, Small, 0) :- Big #> 0.
+
+die_hard(small_to_big, Small, Big, S, B) :-
     Big #< 5, Small #> 0,
-    Small + Big #> 5,
-    N is 5 - Big,
-    (N #< Small -> S is Small - N ; S=0), writeln("small to big").    
+    small_to_big(Small, Big, S, B).
 
-die_hard(Small, Big, S, 0) :-  % big to small.
+die_hard(big_to_small, Small, Big, S, B) :-
     Small #< 3, Big #> 0,
+    big_to_small(Small, Big, S, B).
+
+
+big_to_small(Small, Big, S, 0) :-
     Small + Big #=< 3,
-    S is Small + Big, writeln("big to small").    
+    S #= Small + Big.
 
-die_hard(Small, Big, 3, B) :-  % big to small.
-    Small #< 3, Big #> 0,
+big_to_small(Small, Big, 3, B) :-
     Small + Big #> 3,
-    N is 3 - Small,
-    (N #< Big -> B is Big - N ; B=0), writeln("big to small").    
+    B #= Big - (3 - Small).
+
+
+small_to_big(Small, Big, 0, B) :-
+    Small + Big #=< 5,
+    B #= Small + Big.
+
+small_to_big(Small, Big, S, 5) :-
+    Small + Big #> 5,
+    S #= Small - (5 - Big).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 /*
 
+With some manual reflow of the list for presentation...
+
+?- call_with_depth_limit(next_dh(Moves), 11, _).
+Moves = [
+    [fill_big, 0, 5],
+    [big_to_small, 3, 2],
+    [empty_small, 0, 2],
+    [big_to_small, 2, 0],
+    [fill_big, 2, 5],
+    [big_to_small, 3, 4]
+    ] ;
+true.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 call_with_depth_limit(next_dh(0, 0, S, B), 12, REsult).
 
 find...
diff -r 2c9153571cee -r 7763457c8c8b thun/metalogical.pl
--- a/thun/metalogical.pl	Sun Jul 21 14:13:48 2019 -0700
+++ b/thun/metalogical.pl	Wed Aug 07 23:36:38 2019 -0700
@@ -10,7 +10,7 @@
 
 % Meta-logical print trace.
 % (Could also be captured in a list or something instead.)
-tmi(thun(E, Si, _)) :- portray_clause(Si-E), fail.
+tmi(thun(E, Si, _)) :- frump(Si, E), fail.
 
 tmi(Goal) :-
     checky(Goal),
@@ -24,6 +24,33 @@
     Goal \= number(_),
     Goal \= !.
 
+
+format_state(Stack, Expression, Codes) :-
+    reverse(Stack, RStack),
+    phrase(format_stack(RStack), RStackCodes),
+    phrase(format_stack(Expression), ExpressionCodes),
+    append(RStackCodes, [32, 46, 32|ExpressionCodes], Codes).
+
+
+frump(Stack, Expression) :-
+    format_state(Stack, Expression, Codes),
+    maplist(put_code, Codes), nl.
+
+% do(In) :- phrase(format_stack(In), Codes), maplist(put_code, Codes).
+
+% Print Joy expressions as text.
+
+format_stack(Tail)  --> {var(Tail)}, !, [46, 46, 46].
+format_stack([T])   --> format_term(T), !.
+format_stack([T|S]) --> format_term(T), " ", format_stack(S).
+format_stack([])    --> [].
+
+format_term(N) --> {number(N), number_codes(N, Codes)}, Codes.
+format_term(A) --> {  atom(A),   atom_codes(A, Codes)}, Codes.
+format_term([A|As]) --> "[", format_stack([A|As]), "]".
+
+
+
 /*
 
 [debug]  ?- tmi(thun([1, 2, swap], Si, So)).
diff -r 2c9153571cee -r 7763457c8c8b thun/thun.pl
--- a/thun/thun.pl	Sun Jul 21 14:13:48 2019 -0700
+++ b/thun/thun.pl	Wed Aug 07 23:36:38 2019 -0700
@@ -1,5 +1,5 @@
 %
-%    Copyright © 2018 Simon Forman
+%    Copyright © 2018, 2019 Simon Forman
 %
 %    This file is part of Thun
 %
@@ -23,10 +23,12 @@
 
 
 /*


More information about the Joypy-announce mailing list
アーカイブの一覧に戻る