-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement haversine; test dan's images
ref #10
- Loading branch information
1 parent
4da2d9b
commit 038416b
Showing
5 changed files
with
35 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
'use strict'; | ||
|
||
// total wizard! thanks! | ||
// https://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays-in-javascripts | ||
const isArray = (elementInQuestion) => Array.isArray(elementInQuestion); | ||
const flattener = (elementsToFlatten) => { | ||
return elementsToFlatten.reduce((flatElements, element) => { | ||
return flatElements.concat(isArray(element) ? flattener(element) : element); | ||
}, []); | ||
} | ||
|
||
|
||
/** | ||
* flattens array of nested elements | ||
* | ||
* @param {array} nested array of (potentially nested array) elements | ||
* @return {array} flattened array of elements in nested | ||
*/ | ||
exports.flatten = (nested) => { | ||
return nested.reduce((flatt, el) => { | ||
return flatt.concat(Array.isArray(el) ? flatten(el) : el) | ||
|
||
}); | ||
} | ||
exports.flatten = (nestedElements) => flattener(nestedElements) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters