The sqrt/1 predicate wasn't working.

This commit is contained in:
Simon Forman 2019-08-11 19:35:05 -07:00
parent 79aa2f972d
commit afec650c7b
3 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -20,6 +20,9 @@ Main Loop
*/
% :- debug.
% :- spy(thun).
:- initialization(loop).
loop :- prompt, line(Line), loop(Line, [], _Out).
@ -32,9 +35,8 @@ loop( Line, In, Out) :-
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.

View File

@ -36,7 +36,7 @@ thun([Combo|E], Si, So) :- combo(Combo, Si, S, E, Eo), thun(Eo, S, So).
thun([Unknown|E], Si, So) :-
damned_thing(Unknown),
write(`wtf? `),
write(`huh? `),
write(Unknown), nl,
So = [[Unknown|E]|Si].
@ -82,7 +82,8 @@ func(cons, [A, B|S], [[B|A]|S]).
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).