Replies: 7 comments 15 replies
-
13211-3 conformity approved |
Beta Was this translation helpful? Give feedback.
-
Honestly, lack of tacit syntax is virtually the only thing preventing prolog from truly being a god-tier language for me. I hate writing code like
when all I needed was D. I know there's library(func) but I really wish it was just the actual language syntax. I saw this idea on binate relational syntax for prolog and thought it was interesting. |
Beta Was this translation helpful? Give feedback.
-
A related 2021 example by Markus @triska: https://news.ycombinator.com/item?id=28966133#28970769 |
Beta Was this translation helpful? Give feedback.
-
I forgot to describe what code in my first post does. It implements simple stack-based language (like Forth, but without loops and less elegant). Every word operates on variables on a stack. Consider following definition: add, [A+B] --> [A,B]. You can read it imperatively if you find it easier: Word |
Beta Was this translation helpful? Give feedback.
-
I guess the other way to do this is
|
Beta Was this translation helpful? Give feedback.
-
It just occured to me, that "functional" style can be easily implemented using delimeted continuations from :- use_module(library(cont)).
:- use_module(library(lists)).
:- op(990, xfx, :=).
triangle_area(X) :-
X := (side_1 * side_2 * sin(angle_between_sides)) / 2.
side_1 :- return(5).
side_2 :- return(4).
angle_between_sides :- return(pi/6).
A * B :- return(A*B).
A + B :- return(A+B).
A / B :- return(A/B).
cos(A) :- return(cos(A)).
sin(A) :- return(sin(A)).
return(X) :- shift(return(X)).
Return := Evaluable :-
callable(Evaluable) ->
Evaluable =.. [F|Args],
maplist((:=), Rets, Args),
Function =.. [F|Rets],
reset(Function, return(X), _), !,
Return is X
; Return is Evaluable. Then just run:
Operator |
Beta Was this translation helpful? Give feedback.
-
I found this paper: https://apps.dtic.mil/sti/tr/pdf/ADA632218.pdf, so it looks like I've re-invented the wheel once again. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Nothing serious, I just find it interesting.
Beta Was this translation helpful? Give feedback.
All reactions