32 lines
632 B
Plaintext
32 lines
632 B
Plaintext
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.
|