Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
:- object(partial_functions).
|
||||
|
||||
:- public(show/0).
|
||||
|
||||
show :-
|
||||
% create the partial functions
|
||||
create_partial_function(f1, PF1),
|
||||
create_partial_function(f2, PF2),
|
||||
% apply the partial functions
|
||||
Sequence1 = [0,1,2,3],
|
||||
call(PF1, Sequence1, PF1Sequence1), output_results(PF1, Sequence1, PF1Sequence1),
|
||||
call(PF2, Sequence1, PF2Sequence1), output_results(PF2, Sequence1, PF2Sequence1),
|
||||
Sequence2 = [2,4,6,8],
|
||||
call(PF1, Sequence2, PF1Sequence2), output_results(PF1, Sequence2, PF1Sequence2),
|
||||
call(PF2, Sequence2, PF2Sequence2), output_results(PF2, Sequence2, PF2Sequence2).
|
||||
|
||||
create_partial_function(Closure, fs(Closure)).
|
||||
|
||||
output_results(Function, Input, Output) :-
|
||||
write(Input), write(' -> '), write(Function), write(' -> '), write(Output), nl.
|
||||
|
||||
fs(Closure, Arg1, Arg2) :-
|
||||
meta::map(Closure, Arg1, Arg2).
|
||||
|
||||
f1(Value, Double) :-
|
||||
Double is 2*Value.
|
||||
|
||||
f2(Value, Square) :-
|
||||
Square is Value*Value.
|
||||
|
||||
:- end_object.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
| ?- partial_functions::show.
|
||||
[0,1,2,3] -> fs(f1) -> [0,2,4,6]
|
||||
[0,1,2,3] -> fs(f2) -> [0,1,4,9]
|
||||
[2,4,6,8] -> fs(f1) -> [4,8,12,16]
|
||||
[2,4,6,8] -> fs(f2) -> [4,16,36,64]
|
||||
yes
|
||||
Loading…
Add table
Add a link
Reference in a new issue