[Joypy-announce] joypy/Joypy: The sqrt/1 predicate wasn't working.

Back to archive index
scmno****@osdn***** scmno****@osdn*****
Mon Aug 12 11:37:16 JST 2019


changeset 329fd7234110 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=329fd7234110
user: Simon Forman <sform****@hushm*****>
date: Sun Aug 11 19:35:05 2019 -0700
description: The sqrt/1 predicate wasn't working.

diffstat:

 thun/gnu-prolog/Makefile |  1 +
 thun/gnu-prolog/main.pl  |  6 ++++--
 thun/gnu-prolog/thun.pl  |  5 +++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diffs (56 lines):

diff -r 7629cb8c1ad4 -r 329fd7234110 thun/gnu-prolog/Makefile
--- a/thun/gnu-prolog/Makefile	Sun Aug 11 18:45:57 2019 -0700
+++ b/thun/gnu-prolog/Makefile	Sun Aug 11 19:35:05 2019 -0700
@@ -1,5 +1,6 @@
 #GPLC_OPTIONS=--min-size
 GPLC_OPTIONS=--no-top-level
+#GPLC_OPTIONS=
 
 thun: thun.pl parser.pl defs.pl main.pl math.pl Makefile
 	gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl main.pl math.pl
diff -r 7629cb8c1ad4 -r 329fd7234110 thun/gnu-prolog/main.pl
--- a/thun/gnu-prolog/main.pl	Sun Aug 11 18:45:57 2019 -0700
+++ b/thun/gnu-prolog/main.pl	Sun Aug 11 19:35:05 2019 -0700
@@ -20,6 +20,9 @@
 
 */
 
+% :- debug.
+% :- spy(thun).
+
 :- initialization(loop).
 
 loop :- prompt, line(Line), loop(Line, [], _Out).
@@ -32,9 +35,8 @@
   line(NextLine), !,
   loop(NextLine, S, Out).
 
-
 do_line(Line, In, Out) :-
-    phrase(joy_parse(E), Line),
+    phrase(joy_parse(E), Line), !,
     thun(E, In, Out).
 do_line(_Line, S,   S) :- write('Err'), nl.
 
diff -r 7629cb8c1ad4 -r 329fd7234110 thun/gnu-prolog/thun.pl
--- a/thun/gnu-prolog/thun.pl	Sun Aug 11 18:45:57 2019 -0700
+++ b/thun/gnu-prolog/thun.pl	Sun Aug 11 19:35:05 2019 -0700
@@ -36,7 +36,7 @@
 
 thun([Unknown|E], Si, So) :-
     damned_thing(Unknown),
-    write(`wtf? `),
+    write(`huh? `),
     write(Unknown), nl,
     So = [[Unknown|E]|Si].
 
@@ -82,7 +82,8 @@
 func(swap, [A, B|S],  [B, A|S]).
 func(dup,     [A|S],  [A, A|S]).
 func(pop,     [_|S],        S ).
-func(sqrt, [A|S], [sqrt(A)|S]).
+
+func(sqrt, [A|S], [B|S]) :- B is sqrt(A).
 
 func(concat, [A, B|S],   [C|S]) :- append(B, A, C).
 func(flatten,   [A|S],   [B|S]) :- flatten(A, B).



More information about the Joypy-announce mailing list
Back to archive index