// Traditional JavaScript Primitives
$1 = [1,2,3,4]
$2 = 'String'
$3 = true
This file contains hidden or 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
| search(List list, int value, int min, int max) { | |
| if(min > max) { | |
| return null; | |
| } | |
| final int mid = (max + min) ~/ 2; | |
| if(value < list[mid]) { | |
| return search(list, value, min, mid - 1); | |
| } |
This file contains hidden or 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
| // Must have be non-empty. | |
| peaks(list) { | |
| if(list.length == 1) { | |
| return list.first; | |
| } | |
| if(list.length == 2) { | |
| return list.reduce((prev, curr) => curr >= prev ? curr : prev); | |
| } | |
This file contains hidden or 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
| List merge(List first, List second) { | |
| if(first.isEmpty) { | |
| return second; | |
| } | |
| if(second.isEmpty) { | |
| return first; | |
| } | |
| if(first.first <= second.first) { |
NewerOlder