On Sep 1, 2018, at 0:09, Dan <gros...@gmail.com> wrote:Hi Samer,Thank you for your suggestion.Its good to know about the data flow technique you are describing.There is an "architectural" reason for the many parameters.At the very center of this part of the system is an automaton, which encodes a fairly complex state machine. Initially, I had the state space represented as a series of predicates -- but this caused two problems:1. it was slow because there was a lot of backtracking during each "decision cycle" just to identify the right conditions to move the states forward2. the condition knowledge became quite distributed across many predicates along with various other predicates that checked for valid preconditions and actions that needed performing -- it was hard to analyze the actual state space -- which in itself needs design during development.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.19)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
?- Y = point{x:1,y:2}.put(z,3).
Y = point{x:1, y:2, z:3}. %%% thats a new shallow copy and transformation %%%
?- D = point{x:X}.put(y,2), D =.. L, nl.
L = [C'dict', point, 1, X, 2, y].?- D = point{z:Z}.put(y,2), D =.. L, nl.
L = [C'dict', point, 2, y, 3, Z].?- D = point{x:X,z:Z}.put(y,2), D =.. L, nl.
L = [C'dict', point, 1, X, 2, y, 3, Z].The proof of the pudding is in the eating.
- MIGUEL DE CERVANTES, Don Quixote
:- private is_dict2/2. %%% SmallTalk experiment %%%
is_dict2(D, _) :- var(D), !, fail.
is_dict2(D, floats) :- number(D), !.
is_dict2([_|_], vector) :- !.
is_dict2(D, T) :- !,
is_dict2(D, T).
:- module(floats, [add/3, mul/3]).
:- use_module(library(advanced/dict)).
:- use_module(library(func2)).
X.add(Y) := Z :- Z is X + Y.
X.mul(Y) := Z :- Z is X * Y.
:- module(vector, [mul/3, add/3]).
:- use_module(library(basic/lists)).
:- use_module(library(advanced/dict)).
:- use_module(library(func2)).
X.add(Y) := Z :- maplist(plus, X, Y, Z).
plus(X, Y, Z) :- Z is X+Y.
X.mul(Y) := Z :- maplist(times(Y), X, Z).
times(X, Y, Z) :- Z is X*Y.
:- module(main, [interpolate/4]).
:- use_module(library(advanced/dict)).
:- use_module(library(func2)).
interpolate(K1, X1, X2, Y) :-
K2 is 1-K1,
KX1 = X1.mul(K1),
KX2 = X2.mul(K2),
Y = KX1.add(KX2).
To be continued...
?- interpolate(0.2, 10, 20, X). X = 18.0 ?- interpolate(0.2, [10,5,2], [20,30,10], X). X = [18.0,25.0,8.4]
interpolate(K1, X1, X2, Y) :-
K2 is 1-K1,
KX1 = X1.mul(K1),
KX2 = X2.mul(K2),
Y = KX1.add(KX2).
interpolate(K1, X1, X2, Y) :-
K2 is 1-K1,
Y = X1.mul(K1).add(X2.mul(K2)).
?- listing.
interpolate(K1, X1, X2, Y) :- K2 is 1-K1,
'.'(X1, mul(K1), A), KX1 = A, '.'(X2, mul(K2), B), KX2 = B, '.'(KX1, add(KX2), C), Y = C.
?- listing.
interpolate(K1, X1, X2, Y) :- K2 is 1-K1,
'.'(X1, mul(K1), A), '.'(X2, mul(K2), B), '.'(A, add(B), C), Y = C.Yes essentially the same. But what would be ultra cool,
interpolate(K1, X1, X2, Y) :-
Y = X1*K1+X2*(1-K1).