Would it be possibly to make a Picat that has more syntactic--- Synchronet 3.20a-Linux NewsLink 1.114
sugar. Like for example today I write:
foo(X, R, Y, S) =>
(X := X+1; Y := Y+1), R = X, S = Y.
What if I could write:
foo(!X, !Y) =>
(X := X+1; Y := Y+1).
Similar something for predicate goal invokation, including
some query processing along the following lines:
?- X = 0, Y = 0, foo(!X, !Y).
X = 1, Y = 0;
X = 0, Y = 1.
The sum_list example that I made had an evaluable function which is predicate defined. But the foo/2 example with X := X+1 and Y := Y+1 doesn’t use some predicate defined evaluable function.--- Synchronet 3.20a-Linux NewsLink 1.114
One has to check with the Picat Manual. It has a section 1.3 Defining Functions,
But this was never my point, to introduce this feature of Picat. Because
you don’t need it to translate X := X+1. It is tempting to translate it into:
+(!.X, 1, !:X)
But you can also translate X := X+1 into, in terms of Mercury state variables:
!:X is !.X+1
Basically in Picat, every variable is already automatically a state variable. There are papers of Picat that detail the translation
used in Picat. Basically Picat translates to BProlog. Example paper:
Canonicalizing High-Level Constructs in Picat
2.4 Assignments and While Loops https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
The approach is relatively straight forward, every variable is automatically a state variable, but its not automatically a pair. It gets a pair during assignment which is described by Neng-Fa Zhou and Jonathan Fruhman:
Canonicalizing High-Level Constructs in Picat
3.5 Transformation of Assignments
Picat creates a new variable, say X1, to hold the value of X after
the assignment X := X + 1. […] All occurrences of X after the assignment are replaced by X1. […] When encountering X1 := X1 + 2, Picat creates another new variable. Etc… https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
Mild Shock schrieb am Dienstag, 3. Oktober 2023 um 17:33:20 UTC+2:
Would it be possibly to make a Picat that has more syntactic
sugar. Like for example today I write:
foo(X, R, Y, S) =>
(X := X+1; Y := Y+1), R = X, S = Y.
What if I could write:
foo(!X, !Y) =>
(X := X+1; Y := Y+1).
Similar something for predicate goal invokation, including
some query processing along the following lines:
?- X = 0, Y = 0, foo(!X, !Y).
X = 1, Y = 0;
X = 0, Y = 1.
I am already thinking of a name for the new programming language,--- Synchronet 3.20a-Linux NewsLink 1.114
that results from the fusion of Picat and Marcury, basically adding (!)/1
to Picat. Some ideas: Picachu, Swicat, Candy, what else?
Mostlikely instead of translating to BProlog or SWI-Prolog, the new
language can possibly also be translated to Novacore. If the new
language has some momentum, it could be worth providing such
a translation layer. Currently Picat alone and also (=>)/2 alone of SWI-Prolog is not very attractive. Picachu would go a totally different route than Logtalk, instead of adding objects, it adds pseudo imperativity. Mild Shock schrieb am Mittwoch, 4. Oktober 2023 um 17:09:26 UTC+2:
The sum_list example that I made had an evaluable function which is predicate defined. But the foo/2 example with X := X+1 and Y := Y+1 doesn’t use some predicate defined evaluable function.
One has to check with the Picat Manual. It has a section 1.3 Defining Functions,
But this was never my point, to introduce this feature of Picat. Because you don’t need it to translate X := X+1. It is tempting to translate it into:
+(!.X, 1, !:X)
But you can also translate X := X+1 into, in terms of Mercury state variables:
!:X is !.X+1
Basically in Picat, every variable is already automatically a state variable. There are papers of Picat that detail the translation
used in Picat. Basically Picat translates to BProlog. Example paper:
Canonicalizing High-Level Constructs in Picat
2.4 Assignments and While Loops https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
The approach is relatively straight forward, every variable is automatically
a state variable, but its not automatically a pair. It gets a pair during assignment which is described by Neng-Fa Zhou and Jonathan Fruhman:
Canonicalizing High-Level Constructs in Picat
3.5 Transformation of Assignments
Picat creates a new variable, say X1, to hold the value of X after
the assignment X := X + 1. […] All occurrences of X after the assignment are replaced by X1. […] When encountering X1 := X1 + 2, Picat creates another new variable. Etc… https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
Mild Shock schrieb am Dienstag, 3. Oktober 2023 um 17:33:20 UTC+2:
Would it be possibly to make a Picat that has more syntactic
sugar. Like for example today I write:
foo(X, R, Y, S) =>
(X := X+1; Y := Y+1), R = X, S = Y.
What if I could write:
foo(!X, !Y) =>
(X := X+1; Y := Y+1).
Similar something for predicate goal invokation, including
some query processing along the following lines:
?- X = 0, Y = 0, foo(!X, !Y).
X = 1, Y = 0;
X = 0, Y = 1.
How does one do the push back? I think its also on the agenda.--- Synchronet 3.20a-Linux NewsLink 1.114
In DCG a push back need not be a list. It can also be a non-terminal.
If you have the following DCG clause with a push back:
p, q --> r.
Its translated as follows:
p(A, B) :- r(A, C), q(B, C).
So the push back is appended to the goal list of the body,
and the push back has the argument order reversed. This lead me
to an idea, which might be not present in Mercury, not sure, but to
have both !IO and ?IO. A Push back would be translated:
p(!IO) :- r(!IO), q(?IO)
The question mark (?)/2, unlike the exclamation mark (!)/1, has the
pair flipped, providing a mirror relation ship. This could be useful Short- DeadfishNumbers problem, if the state transtions are formulated !IO style, but with the help of ?IO one could search backward from the goal to the start.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 919 |
Nodes: | 10 (1 / 9) |
Uptime: | 71:18:20 |
Calls: | 12,186 |
Calls today: | 1 |
Files: | 186,526 |
Messages: | 2,236,736 |