Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Forward-difference/Picat/forward-difference.picat
Normal file
31
Task/Forward-difference/Picat/forward-difference.picat
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
go =>
|
||||
L = [90, 47, 58, 29, 22, 32, 55, 5, 55, 73],
|
||||
foreach(I in 1..L.length-1)
|
||||
println([d=I,diffi(L,I)])
|
||||
end,
|
||||
nl,
|
||||
% All differences (a sublist to save space)
|
||||
println(alldiffs(L[1..6])),
|
||||
nl.
|
||||
|
||||
% Difference of the list
|
||||
diff(L) = Diff =>
|
||||
Diff = [L[I]-L[I-1] : I in 2..L.length].
|
||||
|
||||
% The i'th list difference
|
||||
diffi(L,D) = Diff =>
|
||||
Diff1 = L,
|
||||
foreach(_I in 1..D)
|
||||
Diff1 := diff(Diff1)
|
||||
end,
|
||||
Diff = Diff1.
|
||||
|
||||
% all differences
|
||||
alldiffs(L) = Diffs =>
|
||||
Diffs1 = [],
|
||||
Diff = L,
|
||||
foreach(_I in 1..L.length-1)
|
||||
Diff := diff(Diff),
|
||||
Diffs1 := Diffs1 ++ [Diff]
|
||||
end,
|
||||
Diffs = Diffs1.
|
||||
Loading…
Add table
Add a link
Reference in a new issue