From b8d07bd8a4f9ee956ce78111f72fde4b1a05c153 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Fri, 8 Apr 2022 16:59:15 +1000 Subject: [PATCH] Add explaining comment to diff --- packages/squiggle-lang/src/rescript/Utility/E.res | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index 0411bf3c..8e7ec492 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -443,6 +443,8 @@ module A = { let mean = a => sum(a) /. (Array.length(a) |> float_of_int) let random = Js.Math.random_int + // Gives an array with all the differences between values + // diff([1,5,3,7]) = [4,-2,4] let diff = (arr: array): array => Belt.Array.zipBy(arr, Belt.Array.sliceToEnd(arr, 1), (left, right) => right -. left)