{"id":1461,"date":"2008-11-12T23:55:00","date_gmt":"2008-11-12T14:55:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=183"},"modified":"2008-11-12T23:55:00","modified_gmt":"2008-11-12T14:55:00","slug":"blogn-183","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=183","title":{"rendered":"Ruby\u306a\u30af\u30e9\u30b9\u3092\u3055\u3055\u3063\u3068\u4f5c\u308b"},"content":{"rendered":"<p>Ruby\u3067\u6570\u5b66\u306e\u554f\u984c\u306b\u6311\u6226\u3057\u3066\u3044\u308b\u4eba\u304c\u3044\u305f\u3002<br \/>\u3088\u304f\u8003\u3048\u308c\u3070LL\u3067\u5909\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u66f8\u304f\u4eba\u3063\u3066\u521d\u3081\u3066\u898b\u305f\u3002<br \/>\u3069\u3046\u3057\u3066\u3082PHP\u3067Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u66f8\u304f\u4eba\u306f\u898b\u305f\u3053\u3068\u3042\u308b\u3051\u3069\u3002<br \/>\u3057\u304b\u3057\u3001Ruby\u3068\u3044\u3046\u3068\u50d5\u306e\u5370\u8c61\u306f\u3053\u308c\u3070\u3063\u304b\u308a\u3002<\/p>\n<pre>(1..100).each do |i|<br \/>  p i<br \/>end<\/pre>\n<p>\u4f55\u304c\u8a00\u3044\u305f\u3044\u304b\u3068\u3044\u3046\u3068each\u30e1\u30bd\u30c3\u30c9\u4fbf\u5229\u3067\u3059\u306d\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\u307e\u3041do\u30d6\u30ed\u30c3\u30af\u306e\u4f7f\u3044\u65b9\u3068\u304b\u306f\u304a\u3082\u3057\u308d\u3044\u3067\u3059\u3088\u306d\u3002<br \/>\u305f\u3060\u3001\u30d6\u30ed\u30c3\u30af\u306e\u7d42\u308f\u308a\u306b\u3044\u3061\u3044\u3061end\u66f8\u304f\u306e\u3081\u3093\u3069\u304f\u3055\u3044\u3068\u304b\u3002<br \/>\u307e\u3041\u3044\u308d\u3044\u308d\u3042\u308b\u306e\u3060\u304c\u3001\u666e\u6bb5C#\u3068\u304bPerl\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u66f8\u304f\u3068\u304d\u3001<br \/>for(1..100) {} \u3068\u307e\u305a\u6253\u3063\u3066\u3057\u307e\u3046\u3001\u305d\u3057\u30661\u6587\u5b57\u623b\u3063\u3066\u4e2d\u8eab\u3092\u66f8\u304f\u3068\u3002<br \/>\u3057\u304b\u3057\u3001end\u3067\u540c\u3058\u3053\u3068\u3092\u3084\u308b\u30683\u6587\u5b57\u3082\u5f8c\u9000\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306a\u3041\u3068\u2026\u5225\u306b\u5927\u3057\u305f\u5dee\u3067\u306f\u306a\u3044\u304b\u3002<br \/>\u307e\u3041\u4eba\u306b\u3088\u3063\u3066\u3044\u308d\u3044\u308d\u3042\u308b\u3060\u308d\u3046\u304c\u3001\u3053\u306e\u8fba\u306f\u304a\u597d\u304d\u306b\u3069\u3046\u305e\u3002<\/p>\n<hr \/>\n<p>\u3044\u308d\u3044\u308d\u898b\u305b\u3066\u3082\u3089\u3063\u3066\u305f\u306e\u3060\u304c\u3001\u3053\u3093\u306a\u3053\u3068\u304c\u3042\u3063\u305f\u3002<br \/>1\u6587\u5b57\u76ee\u300110\u6587\u5b57\u76ee\u3001\u2026\u3001100000\u6587\u5b57\u76ee\u306e\u6587\u5b57\u3092\u53d6\u308a\u51fa\u3057\u305f\u3044\u3068\u3002<br \/>\u3053\u308c\u3092\u7d20\u76f4\u306b\u3084\u308b\u3068\u5927\u5909\u3067\u3059\u306d\u3002<br \/>\u305d\u3053\u3067\u50d5\u306f\u3001\u3053\u308c\u306f\u30af\u30e9\u30b9\u4f5c\u308c\u3070\u3044\u3044\u3067\u3059\u306d\u3068\u601d\u3063\u305f\u308f\u3051\u3060\u3002<br \/>\u3068\u3044\u3046\u308f\u3051\u3067\u3055\u3055\u3063\u3068\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002Ruby\u3067\u30af\u30e9\u30b9\u4f5c\u308b\u306e\u521d\u3081\u3066\u3002<\/p>\n<pre>class Selectstring<br \/>  attr_reader :len , :res;<br \/>  def initialize()<br \/>    @len=0<br \/>    @select=[1,10,100,1000,10000,100000]<br \/>    @res=[]<br \/>  end<br \/>  def append(str)<br \/>    len0=@len+1<br \/>    @len+=str.size<br \/>    @select.each_with_index do |cur,i|<br \/>      if len0<=cur and cur<=@len<br \/>        res[i]=str[cur-len0]<br \/>      end<br \/>    end <br \/>  end<br \/>end<\/pre>\n<p>String\u30af\u30e9\u30b9\u306esize\u30d7\u30ed\u30d1\u30c6\u30a3\u3001length\u30d7\u30ed\u30d1\u30c6\u30a3\u3001\u3069\u3063\u3061\u30821.8\u3067\u306f\u30d0\u30a4\u30c8\u6570\u3092\u8fd4\u3059\u306e\u306d\u3002<br \/>1.9\u3067\u306flength\u306f\u6587\u5b57\u6570\u306b\u306a\u308b\u307f\u305f\u3044\u3060\u3051\u3069\u3002<br \/>\u3055\u3066\u3001\u305d\u308c\u306f\u3068\u3082\u304b\u304f\u3001Ruby\u306e\u5909\u6570\u540d\u306e\u982d\u306b\u4ed8\u3051\u308b@\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u306e\u610f\u5473\u3002<br \/>@@\u3060\u3068\u30af\u30e9\u30b9\u5909\u6570\u3002<br \/>\u306a\u308b\u307b\u3069\u3053\u3046\u3084\u3063\u3066\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u3068\u533a\u5225\u3057\u3066\u308b\u306e\u304b\u2026<br \/>\u3042\u3068\u3001C#\u3067\u3044\u3046\u30d7\u30ed\u30d1\u30c6\u30a3\u306fattr_reader, attr_writer\u3067\u7c21\u6613\u306b\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3002<br \/>\u81ea\u4f5c\u3082\u308f\u308a\u3068\u7c21\u5358\u306b\u3067\u304d\u308b\u3089\u3057\u3044\u3067\u3059\u3002<br \/>each_with_index\u3068\u3044\u3046\u306e\u306f\u9762\u767d\u3044\u3067\u3059\u306d\u3002\u307e\u3041PHP\u306a\u3089for($arr as $idx=>$cur){ }\u3068\u304b\u3067\u3067\u304d\u308b\u3051\u3069\u3002<br \/>1\u3064\u5909\u6570\u7528\u610f\u3057\u3066\u3001\u30eb\u30fc\u30d7\u5185\u3067\u6bce\u5ea6\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3059\u308c\u3070\u3044\u3044\u3053\u3068\u3068\u306f\u3044\u3048\u3001\u3053\u308c\u306f\u4fbf\u5229\u3002<br \/>str[cur-len0]\u3068\u3044\u3046\u64cd\u4f5c\u3060\u304c\u3001\u3053\u308c\u306f\u6587\u5b57\u5217\u306e\u4f55\u756a\u76ee\u304b\u306e\u6587\u5b57\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3059\u3082\u306e\u3089\u3057\u3044\u3002<br \/>\u6587\u5b57\u30b3\u30fc\u30c9\u306a\u3093\u3067\u3059\u3088\u3002<br \/>\u6587\u5b57\u30b3\u30fc\u30c9\u304b\u3089\u6587\u5b57\u306b\u76f4\u3059\u306e\u306fchr\u30e1\u30bd\u30c3\u30c9\u3067\u3067\u304d\u308b\u306e\u3067\u3042\u3089\u304b\u3058\u3081\u3084\u3063\u3066\u304a\u3051\u3070\u3088\u304b\u3063\u305f\u306a\u3068\u304b\u3002<\/p>\n<hr \/>\n<p>\u3055\u3066\u3001\u3053\u308c\u306e\u4f7f\u3044\u65b9\u3060\u304c\u3001<br \/>\u307e\u3041\u7d50\u8ad6\u304b\u3089\u8a00\u3048\u3070\u3001123456789101112\u2026\u3068\u3044\u3046\u7121\u9650\u306b\u7d9a\u304f\u6570\u306e<br \/>1,10,100,1000,10000,100000\u756a\u76ee\u306e\u6570\u3092\u53d6\u308a\u51fa\u3057\u3001\u3053\u308c\u306e\u7a4d\u3092\u53d6\u308b\u3068\u3002<br \/>\u3068\u3044\u3046\u308f\u3051\u3067\u3055\u3063\u304d\u306e\u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u554f\u984c\u3092\u89e3\u304f\u3002<\/p>\n<pre>myss=Selectstring.new()<br \/>j=1<br \/>while myss.len<100000<br \/>  myss.append(j.to_s)<br \/>  j+=1<br \/>end<br \/>p myss.res.inject(1){ |last,cur| last*cur.chr.to_i }<\/pre>\n<p>\u307e\u3041\u3053\u3093\u306a\u611f\u3058\u3002Array\u306einject\u30e1\u30bd\u30c3\u30c9\u3067Perl 6\u306e[*]\u6f14\u7b97\u5b50\u307f\u305f\u3044\u306a\u3053\u3068\u3092\u3084\u3063\u3066\u308b\u3002<br \/>inject\u306f\u3001\u524d\u56de\u306e\u8a08\u7b97\u7d50\u679c\u3068\u4eca\u56de\u306e\u53d6\u308a\u51fa\u3057\u305f\u5024\u3092\u4f7f\u3063\u3066\u306a\u3093\u304b\u5024\u4f5c\u3063\u3066\u3059\u308b\u3084\u3064\u3002<br \/>\u307e\u3041\u3082\u3063\u3068\u308f\u304b\u308a\u3084\u3059\u3044\u8aac\u660e\u304c\u3042\u308b\u3068\u601d\u3046\u306e\u3067\u305d\u308c\u63a2\u3057\u3066\u3002<br \/>\u3061\u306a\u307f\u306b\u3053\u306e\u554f\u984c\u306e\u7b54\u3048\u306f210\u3068\u306a\u3063\u305f\u3002\u6b63\u89e3\u3089\u3057\u3044\u3002<\/p>\n<hr \/>\n<p>\u307e\u3041\u3053\u3093\u306a\u98a8\u306b\u5272\u3068\u4f7f\u3044\u6368\u3066\u306e\u30af\u30e9\u30b9\u3082\u4f5c\u308a\u3084\u3059\u3044\u3067\u3059\u3002<br \/>Python\u306e\u3068\u304d\u3082\u540c\u3058\u3088\u3046\u306a\u3053\u3068\u3092\u3044\u3063\u3066\u305f\u6c17\u304c\u3059\u308b\u3002<br \/>\u305d\u3046\u3044\u3048\u3070Perl 6\u3067\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u3053\u3068\u304c\u3044\u308d\u3044\u308d\u5909\u308f\u308b\u3093\u3060\u3068\u304b\u3002<br \/>\u305d\u308c\u306b\u3088\u3063\u3066\u30af\u30e9\u30b9\u3082\u304b\u306a\u308a\u4f5c\u308a\u3084\u3059\u304f\u306a\u308b\u306f\u305a\u3002<br \/>\u307e\u305f\u8abf\u3079\u3066\u304a\u3053\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ruby\u3067\u6570\u5b66\u306e\u554f\u984c\u306b\u6311\u6226\u3057\u3066\u3044\u308b\u4eba\u304c\u3044\u305f\u3002\u3088\u304f\u8003\u3048\u308c\u3070LL\u3067\u5909\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u66f8\u304f\u4eba\u3063\u3066\u521d\u3081\u3066\u898b\u305f\u3002\u3069\u3046\u3057\u3066\u3082PHP\u3067Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u66f8\u304f\u4eba\u306f\u898b\u305f\u3053\u3068\u3042\u308b\u3051\u3069\u3002\u3057\u304b\u3057\u3001Ruby\u3068\u3044\u3046\u3068\u50d5\u306e\u5370\u8c61\u306f\u3053\u308c\u3070\u3063\u304b\u308a\u3002 (1. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1461","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1461"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1461\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}