Last active
February 14, 2021 15:14
-
-
Save milligramme/6173510 to your computer and use it in GitHub Desktop.
extendscriptだと配列の最初と最後しかみてない
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
#target "indesign" | |
#include "underscore.js" | |
var o = [10, 5, 100, 2, 1000, 99]; | |
var o_ = [1121, 7, 22, 111, 1, 33, 23, 3, 919]; | |
var o__ = [1005, 7, 22, 1, 777]; | |
$.writeln( _.min(o) ); //=> 2 | |
$.writeln( _.max(o) ); //=> 99 ???? | |
$.writeln( _.min(o_) ); //=> 919 ????? | |
$.writeln( _.max(o_) ); //=> 1121 | |
$.writeln( _.min(o__) ); //=> 777 ??? | |
$.writeln( _.max(o__) ); //=> 1005 |
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
#target "indesign" | |
#include "underscore.js" | |
var o = [10, 5, 100, 2, 1000, 99]; | |
// $.writeln(_.min(o)); | |
// $.writeln(Math.min.apply(null, o)); | |
// $.writeln(Math.min(110, 5, 100, 2, 1000, 99)); | |
for (var i = 0; i < 10; i++) { | |
var s = _.shuffle(o); | |
$.writeln(s.toSource()); | |
$.writeln(_.min(s)+ " => 2を期待"); | |
$.writeln(_.max(s)+ " => 1000を期待"); | |
$.writeln(""); | |
} | |
// [99, 10, 5, 100, 1000, 2] | |
// 2 => 2を期待 | |
// 1000 => 1000を期待 | |
// | |
// [99, 1000, 100, 5, 10, 2] | |
// 2 => 2を期待 | |
// 100 => 1000を期待 | |
// | |
// [1000, 10, 99, 5, 100, 2] | |
// 2 => 2を期待 | |
// 1000 => 1000を期待 | |
// | |
// [10, 5, 2, 1000, 99, 100] | |
// 2 => 2を期待 | |
// 100 => 1000を期待 | |
// | |
// [100, 5, 2, 1000, 99, 10] | |
// 10 => 2を期待 | |
// 1000 => 1000を期待 | |
// | |
// [1000, 5, 100, 2, 99, 10] | |
// 10 => 2を期待 | |
// 1000 => 1000を期待 | |
// | |
// [10, 100, 1000, 99, 2, 5] | |
// 5 => 2を期待 | |
// 99 => 1000を期待 | |
// | |
// [2, 5, 100, 1000, 10, 99] | |
// 2 => 2を期待 | |
// 99 => 1000を期待 | |
// | |
// [10, 100, 2, 1000, 99, 5] | |
// 5 => 2を期待 | |
// 99 => 1000を期待 | |
// | |
// [10, 100, 5, 99, 2, 1000] | |
// 2 => 2を期待 | |
// 1000 => 1000を期待 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CS5, CS5.5までは Math.min/max は2引数
CS6以降は可変長引数になっている