{"id":706,"date":"2016-05-21T23:02:33","date_gmt":"2016-05-21T14:02:33","guid":{"rendered":"http:\/\/www.biscrat.com\/blog\/?p=706"},"modified":"2024-03-19T03:32:46","modified_gmt":"2024-03-18T18:32:46","slug":"linq-tjs","status":"publish","type":"post","link":"https:\/\/biscrat.com\/blog\/linq-tjs\/","title":{"rendered":"linq.tjs\u516c\u958b\u3057\u307e\u3057\u305f"},"content":{"rendered":"<p>TJS\u3067LINQ to Objects\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u30e9\u30a4\u30d6\u30e9\u30ealinq.tjs\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/github.com\/sakano\/linq.tjs\">https:\/\/github.com\/sakano\/linq.tjs<\/a><\/p>\n<p>LINQ to Objects\u306fC#\u306e\u5f37\u529b\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u64cd\u4f5c\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002foreach\u3059\u3089\u306a\u3044tjs\u3067\u306ffor\u6587\u3092\u56de\u3059\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001linq.tjs\u3067\u306f\u3088\u308a\u7c21\u6f54\u306b\u8907\u96d1\u306a\u51e6\u7406\u3092\u8a18\u8ff0\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u5409\u91cc\u5409\u91cc2\/Z\u3069\u3061\u3089\u3067\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<h2>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<ol>\n<li><a href=\"https:\/\/github.com\/sakano\/linq.tjs\/releases\">release\u30da\u30fc\u30b8<\/a>\u304b\u3089Source code\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/li>\n<li>linq\u30d5\u30a9\u30eb\u30c0\u306b\u5165\u3063\u3066\u3044\u308blinq.tjs, linq_utility.tjs, linq__order.tjs, linq_generate.tjs\u3092\u81ea\u5206\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a9\u30eb\u30c0\u306b\u5165\u308c\u307e\u3059\u3002<\/li>\n<li><a href=\"https:\/\/github.com\/wtnbgo\/scriptsEx\">\u6700\u65b0\u306eScriptsEx.dll<\/a>\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u5409\u91cc\u5409\u91cc\u3068\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u306b\u5165\u308c\u307e\u3059\u3002<\/li>\n<li>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306blinq.tjs\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nScripts.execStorage(&quot;linq.tjs&quot;);\n<\/pre>\n<\/li>\n<\/ol>\n<h2>\u4f7f\u7528\u4f8b<\/h2>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.range(1, 10)\n    .where(function(x) { return x % 2 == 0;})\n    .select(function(x) { return x * 2; })\n    .forEach(function(x) { System.inform(x); });\n\/\/ 4,8,12,16,20 \u304c\u8868\u793a\u3055\u308c\u308b\n<\/pre>\n<p>\u4f7f\u3044\u65b9\u306fC#\u306eLINQ\u3068\u5168\u304f\u540c\u3058\u3067\u3059\u3002\u7c21\u5358\u306b\u8aac\u660e\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3057\u307e\u3059\u3002<br \/>\n1. Enumerable.range(1, 10)\u30671\uff5e10\u306e\u6574\u6570\u3092\u751f\u6210<br \/>\n2. .where(function(x) { return x % 2 == 0;}) \u3067\u5076\u6570\u306e\u307f\u62bd\u51fa<br \/>\n3. .select(function(x) { return x * 2; }) \u3067\u62bd\u51fa\u3057\u305f\u5076\u6570\u30922\u500d<br \/>\n4. .forEach(function(x) { System.inform(x); }); \u3067\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u8868\u793a<\/p>\n<h2>\u6587\u5b57\u5217\u95a2\u6570<\/h2>\n<p>function(x) { return \uff5e; }\u304c\u9b31\u9676\u3057\u3044\u306e\u3067<a href=\"https:\/\/neue.cc\/2009\/04\/04_145.html\">linq.js<\/a>\u3092\u898b\u7fd2\u3063\u3066\u6587\u5b57\u5217\u3067\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n&#8220;XXX => YYY&#8221;\u3092&#8221;function(XXX) { return YYY; }&#8221;\u306b\u5909\u63db\u3059\u308b\u3060\u3051\u3067\u3059\u304c\u7d50\u69cb\u4fbf\u5229\u3067\u3059\u3002\u5148\u306e\u4f8b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.range(1, 10)\n    .where(&quot;x =&gt; x % 2 == 0&quot;)\n    .select(&quot;x =&gt; x * 2&quot;)\n    .forEach(&quot;x =&gt; System.inform(x);&quot;);\n\/\/ =&gt;,4,8,12,16,20\n<\/pre>\n<p>\u3055\u3089\u306b\u7701\u7565\u3057\u3066YYY\u90e8\u5206\u306e\u307f\u3067\u3082\u4f7f\u3048\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u306f\u7b2c1\u5f15\u6570\u304c&#95;\u3001\u7b2c2\u5f15\u6570\u304c&#95;2\u3001\u7b2c3\u5f15\u6570\u304c&#95;3\u3001&#8230;\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a&#8221;function(&#95;, &#95;2, &#95;3, &#95;4, &#95;5, &#95;6, &#95;7, &#95;8, &#95;9) { return YYY; }&#8221;\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.range(1, 10)\n    .where(&quot;_ % 2 == 0&quot;)\n    .select(&quot;_ * 2&quot;)\n    .forEach(&quot;System.inform(_);&quot;);\n\/\/ =&gt;,4,8,12,16,20\n<\/pre>\n<h2>\u5f15\u6570\u306e\u53d7\u3051\u6e21\u3057<\/h2>\n<p>tjs\u306b\u306fjavascript\u3068\u7570\u306a\u308a\u30ec\u30ad\u30b7\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u3064\u307e\u308afunction\u306e\u4e2d\u3067\u5916\u306b\u3042\u308b\u5909\u6570\u304c\u53c2\u7167\u3067\u304d\u305aLINQ\u3092\u4f7f\u3046\u4e0a\u3067\u975e\u5e38\u306b\u4e0d\u4fbf\u3067\u3059\u3002\u306a\u306e\u3067select\u3084where\u306a\u3069\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u5f15\u6570\u306b\u3068\u308b\u95a2\u6570\u3067\u306f\u3001\u901a\u5e38\u306e\u5f15\u6570\u306e\u5f8c\u308d\u306b\u6e21\u3055\u308c\u305f\u5f15\u6570\u3092\u305d\u306e\u307e\u307e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306b\u6e21\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306farg\u3084caption\u3068\u3057\u3066\u5f15\u6570\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u3059\u3002index\u306f\u3053\u3053\u3067\u306f\u4f7f\u3063\u3066\u3044\u307e\u305b\u3093\u304c\u73fe\u5728\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u3067\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.range(1, 10)\n    .where(&quot;x, index, arg =&gt; x % arg == 0&quot;, 2)\n    .select(&quot;x, index, arg =&gt; x * arg&quot;, 2)\n    .forEach(&quot;x, index, caption =&gt; System.inform(x, caption);&quot;, &quot;\u7d50\u679c\u8868\u793a&quot;);\n\/\/ =&gt;,4,8,12,16,20\n<\/pre>\n<h2>Enumerable.from<\/h2>\n<p>Enumerable.from\u306b\u914d\u5217\u3001\u8f9e\u66f8\u914d\u5217\u3001\u6587\u5b57\u5217\u3092\u6e21\u3059\u3068LINQ\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u914d\u5217\u306e\u5834\u5408\u306f\u305d\u308c\u305e\u308c\u306e\u8981\u7d20\u304c\u9806\u756a\u306b\u5217\u6319\u3055\u308c\u308b\u3060\u3051\u3067\u3059\u3002\u307e\u305f\u3001toArray()\u3092\u4f7f\u3046\u3068\u5217\u6319\u4e2d\u306e\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u914d\u5217\u306b\u5909\u63db\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nvar array = Enumerable.from(&#x5B;10, 20, 30])\n    .select(&quot;x =&gt; x * x&quot;)\n    .toArray();\n\/\/ array\u306f&#x5B;100, 400, 900]\u306b\u306a\u308b\n<\/pre>\n<p>\u8f9e\u66f8\u306e\u5834\u5408\u306fkey\u306b\u30ad\u30fc\u3001value\u306b\u305d\u306e\u5024\u304c\u5165\u3063\u305f\u8f9e\u66f8\u914d\u5217\u3068\u3057\u3066\u5217\u6319\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.from(%&#x5B;&quot;hoge&quot; =&gt; 100, &quot;moge&quot; =&gt; 200])\n    .forEach(function(x) {\n        System.inform(@&quot;\u30ad\u30fc:${x.key}, \u5024:${x.value}&quot;);\n    });\n\/\/ &quot;\u30ad\u30fc:hoge, \u5024:100&quot;\n\/\/ &quot;\u30ad\u30fc:moge, \u5024:200&quot;\n\/\/ \u3068\u8868\u793a\u3055\u308c\u308b\u3002\n<\/pre>\n<p>\u6587\u5b57\u5217\u306e\u5834\u5408\u306f\u5148\u982d\u304b\u3089\uff11\u6587\u5b57\u305a\u3064\u5217\u6319\u3055\u308c\u307e\u3059\u3002toString()\u3067\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nvar str = Enumerable.from(&quot;StRinG&quot;)\n    .where(&quot;_ == _.toUpperCase()&quot;) \/\/ \u5927\u6587\u5b57\u306e\u307f\u62bd\u51fa\n    .toString();\n\/\/ str\u306fSRG\u306b\u306a\u308b\u3002\n<\/pre>\n<h2>Enumerable.extendTo<\/h2>\n<p>LINQ\u3092\u983b\u7e41\u306b\u4f7f\u3046\u5834\u5408\u3001Enumerable.from\u3092\u6bce\u56de\u547c\u3073\u51fa\u3059\u306e\u306f\u9762\u5012\u3067\u3059\u3002\u4eca\u306e\u3068\u3053\u308d\u914d\u5217\u9650\u5b9a\u3067\u3059\u304c\u3001\u4e00\u5ea6Enumerable.extendTo(Array);\u3092\u547c\u3073\u51fa\u305b\u3070\u914d\u5217\u304b\u3089select\u306a\u3069\u306e\u95a2\u6570\u3092\u76f4\u63a5\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.extendTo(Array);\n\nvar array = &#x5B;1,2,3,4,5];\narray = array.select(&quot;_ * 10&quot;).toArray();\n\/\/ array\u306f&#x5B;10,20,30,40,50]\u306b\u306a\u308b\n<\/pre>\n<h2>\u95a2\u6570\u4e00\u89a7<\/h2>\n<p>C#\u306eLINQ to Objects\u306b\u3042\u308b\u95a2\u6570\u306f\u5168\u3066\u79fb\u690d\u6e08\u307f\u3067\u3059\u3002\u305d\u306e\u4ed6\u306b\u3082Interactive Extensions\u3084linq.js\u306a\u3069\u304b\u3089\u5fc5\u8981\u305d\u3046\u306a\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30af\u30a8\u30ea\u95a2\u6570\u4e00\u89a7<\/p>\n<blockquote><p>\naggregate, aggregateWithSeed, all, any, average, buffer, concat, contains, count, defaultIfEmpty, distinct, do, elementAt, elementAtOrDefault, except, first, firstOrDefault, forEach, force, groupBy, groupJoin, indexOf, innerJoin, intersect, isEmpty, last, lastOrDefault, max, min, orderBy, orderByDescending, outerJoin, repeat, reverse, scan, scanWithSeed, select, selectMany, sequenceEqual, single, singleOrDefault, skip, skipWhile, startsWith, sum, take, takeWhile, thenBy, thenByDescending, toArray, toDictionary, toLookup, toString, trace, union, where, zip\n<\/p><\/blockquote>\n<p>\u751f\u6210\u95a2\u6570\u4e00\u89a7<\/p>\n<blockquote><p>\nEnumerable.from, Enumerable.empty, Enumerable.range, Enumerable.repeat, Enumerable.return, Enumerable.matches, Enumerable.random, Enumerable.randomInt, Enumerable.generate\n<\/p><\/blockquote>\n<h2>Enumerable.matches<\/h2>\n<p>linq.tjs\u72ec\u81ea\u306e\u95a2\u6570\u3068\u3057\u3066Enumerable.matches\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002TJS\u3067\u306fRegExp\u30af\u30e9\u30b9\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3048\u307e\u3059\u304c\u7656\u304c\u3042\u3063\u3066\u3044\u307e\u3044\u3061\u4f7f\u3044\u3065\u3089\u3044\u3067\u3059\u3002Enumerable.matches\u3067\u306f\u6b63\u898f\u8868\u73fe\u306e\u30de\u30c3\u30c1\u7d50\u679c\u3092\u6271\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: tjs; title: ; notranslate\" title=\"\">\nEnumerable.matches(\/(&#x5B;a-zA-Z]+)=(&#x5B;0-9]+)\/g, &quot;foo=100 bar=200&quot;)\n    .forEach(function (matches) {\n        System.inform(@&quot;0:${matches&#x5B;0]}, 1:${matches&#x5B;1]}, 2:${matches&#x5B;2]}&quot;);\n    });\n\/\/ &quot;0:foo=100, 1:foo, 2:100&quot;\n\/\/ &quot;0:bar=200, 1:bar, 2:200&quot;\n\/\/ \u304c\u8868\u793a\u3055\u308c\u308b\n<\/pre>\n<p>\u7b2c1\u5f15\u6570\u306f\u4f7f\u7528\u3059\u308b\u6b63\u898f\u8868\u73fe\u3067\u3059\u3002g\u30d5\u30e9\u30b0\u306f\u5fc5\u9808\u3067\u3059\u3002\u7b2c2\u5f15\u6570\u306f\u6b63\u898f\u8868\u73fe\u306e\u5bfe\u8c61\u3068\u306a\u308b\u6587\u5b57\u5217\u3067\u3059\u3002<br \/>\n\u3053\u306e\u3088\u3046\u306b\u3059\u308b\u3068<a href=\"http:\/\/krkrz.github.io\/docs\/tjs2\/j\/contents\/regexp.html#id309\">RegExp.matches<\/a>\u306e\u7d50\u679c\u304c\u5217\u6319\u3055\u308c\u307e\u3059\u3002\u3082\u3046\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u306e\u306bfor\u6587\u306f\u5fc5\u8981\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TJS\u3067LINQ to Objects\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u30e9\u30a4\u30d6\u30e9\u30ealinq.tjs\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u3002 https:\/\/github.com\/sakano\/linq.tjs LINQ to Objects\u306fC#\u306e\u5f37\u529b\u306a\u30b3\u30ec\u30af [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,13,12],"tags":[16,23,4,2],"class_list":["post-706","post","type-post","status-publish","format-standard","hentry","category-c","category-tjs","category-krkr","tag-c","tag-linq","tag-tjs","tag-2"],"_links":{"self":[{"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/posts\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/comments?post=706"}],"version-history":[{"count":28,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/posts\/706\/revisions"}],"predecessor-version":[{"id":992,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/posts\/706\/revisions\/992"}],"wp:attachment":[{"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/categories?post=706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biscrat.com\/blog\/wp-json\/wp\/v2\/tags?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}