I hereby claim:
- I am mmsqe on github.
- I am mavistan (https://keybase.io/mavistan) on keybase.
- I have a public key ASB2GFJDOBUug_zJaQD141-UiFWbsvKk_oQsGHP9gu-kSQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| +(Location *)CalculateBoundary:(CLLocation *)currentLocation | |
| distance:(NSNumber *)distance { | |
| Location *location = [[Location alloc] init]; | |
| float a = [distance floatValue]/Radius; | |
| // convert to radian | |
| float dLat = a/(M_PI/180); | |
| CLLocationCoordinate2D coor = [currentLocation coordinate]; | |
| location.latMax = [NSNumber numberWithFloat: (coor.latitude + dLat)]; | |
| location.latMin = [NSNumber numberWithFloat: (coor.latitude - dLat)]; | |
| float aLat = M_PI*coor.latitude/180; |
| var pyramids = { | |
| data: [], | |
| path: [], | |
| result: [] | |
| }; | |
| pyramids = generatePyramids(3); | |
| function getRandomInt(max) { | |
| return Math.floor(Math.random() * max) + 1; | |
| } |
| // since the inner function uses the same scope as the loop, while data i changes after the loop | |
| // create new function to snapshot it with localI for inner function | |
| function createArrayOfFunctions(y) { | |
| var arr = []; | |
| for (var i = 0; i < y; i++) { | |
| (function(localI) { | |
| arr[i] = function(x) { | |
| return x + localI; | |
| }; | |
| })(i); |
| var results = {}; | |
| var fibonacci = function(n) { | |
| var result = results[n]; | |
| if (result) { | |
| return result; | |
| } | |
| if (n <= 2) { | |
| result = 1; | |
| } else { | |
| result = fibonacci(n - 1) + fibonacci(n - 2); |
since sourceMap uses each item as key, it's O(n) mapping
| var isSubset = function(sourceArray, targetArray) { | |
| var sourceMap = {}; | |
| sourceArray.forEach(function(item) { | |
| sourceMap[item] = true; | |
| }); | |
| for (var i = 0; i < targetArray.length; i++) { | |
| var item = targetArray[i]; | |
| if (!sourceMap[item]) { | |
| return false; | |
| } |