diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-06-25 22:36:45 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-06-25 22:47:33 +1000 |
| commit | 4be1a745174dafb39be76594358ce3f28ec78de0 (patch) | |
| tree | 48d7a0be7cd5768dfc08732b8455fa8c4022dbe6 /src/util.ts | |
| parent | ce159289ba2e141ca472eab06bb5e51b915e0886 (diff) | |
Clean up code in layout.ts and util.ts
Diffstat (limited to 'src/util.ts')
| -rw-r--r-- | src/util.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util.ts b/src/util.ts index 139e668..9a4b2b7 100644 --- a/src/util.ts +++ b/src/util.ts @@ -22,7 +22,7 @@ export function range(len: number): number[] { export function arraySum(array: number[]): number { return array.reduce((x,y) => x+y); } -// Returns an array of increasing evenly-spaced numbers from 'start' to 'end' with size 'size' +// Returns an array of increasing evenly-spaced numbers from 'start' to 'end', with size 'size' export function linspace(start: number, end: number, size: number): number[] { let step = (end - start) / (size - 1); let ar = []; @@ -69,8 +69,8 @@ export function limitVals(arr: number[], min: number, max: number): number[] | n owedChg = 0; } } -// Usable to iterate through possible int arrays with ascending values in the range 0 to maxLen-1, starting with [0] - // eg: With maxLen 3, updates [0] to [0,1], then to [0,2], then [0,1,2] +// Usable to iterate through possible int arrays with ascending values in the range 0 to N, where N < maxLen + // For example, with maxLen 3, passing [0] will update it to [0,1], then [0,2], then [0,1,2] // Returns false when there is no next array export function updateAscSeq(seq: number[], maxLen: number): boolean { // Try increasing last element, then preceding elements, then extending the array |
