Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function maxBy(array, func)
- {
- var results = [];
- for (var key : var element in array)
- {
- results[key] = func(element);
- }
- return array[search(results, arrayMax(results))];
- }
- function maxBy2(array, func)
- {
- var maximum = null;
- for (var element in array)
- {
- (maximum==null)
- ?
- maximum = element
- :
- func(maximum) < func(element)
- ?
- maximum = element
- :
- maximum = maximum; //C'est là que c'est WTF
- }
- return maximum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement