The sqrt/1 predicate wasn't working.
This commit is contained in:
parent
79aa2f972d
commit
afec650c7b
|
|
@ -1,5 +1,6 @@
|
||||||
#GPLC_OPTIONS=--min-size
|
#GPLC_OPTIONS=--min-size
|
||||||
GPLC_OPTIONS=--no-top-level
|
GPLC_OPTIONS=--no-top-level
|
||||||
|
#GPLC_OPTIONS=
|
||||||
|
|
||||||
thun: thun.pl parser.pl defs.pl main.pl math.pl Makefile
|
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
|
gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl main.pl math.pl
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ Main Loop
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
% :- debug.
|
||||||
|
% :- spy(thun).
|
||||||
|
|
||||||
:- initialization(loop).
|
:- initialization(loop).
|
||||||
|
|
||||||
loop :- prompt, line(Line), loop(Line, [], _Out).
|
loop :- prompt, line(Line), loop(Line, [], _Out).
|
||||||
|
|
@ -32,9 +35,8 @@ loop( Line, In, Out) :-
|
||||||
line(NextLine), !,
|
line(NextLine), !,
|
||||||
loop(NextLine, S, Out).
|
loop(NextLine, S, Out).
|
||||||
|
|
||||||
|
|
||||||
do_line(Line, In, Out) :-
|
do_line(Line, In, Out) :-
|
||||||
phrase(joy_parse(E), Line),
|
phrase(joy_parse(E), Line), !,
|
||||||
thun(E, In, Out).
|
thun(E, In, Out).
|
||||||
do_line(_Line, S, S) :- write('Err'), nl.
|
do_line(_Line, S, S) :- write('Err'), nl.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ thun([Combo|E], Si, So) :- combo(Combo, Si, S, E, Eo), thun(Eo, S, So).
|
||||||
|
|
||||||
thun([Unknown|E], Si, So) :-
|
thun([Unknown|E], Si, So) :-
|
||||||
damned_thing(Unknown),
|
damned_thing(Unknown),
|
||||||
write(`wtf? `),
|
write(`huh? `),
|
||||||
write(Unknown), nl,
|
write(Unknown), nl,
|
||||||
So = [[Unknown|E]|Si].
|
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(swap, [A, B|S], [B, A|S]).
|
||||||
func(dup, [A|S], [A, A|S]).
|
func(dup, [A|S], [A, A|S]).
|
||||||
func(pop, [_|S], 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(concat, [A, B|S], [C|S]) :- append(B, A, C).
|
||||||
func(flatten, [A|S], [B|S]) :- flatten(A, B).
|
func(flatten, [A|S], [B|S]) :- flatten(A, B).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue