{"id":1446,"date":"2008-10-27T23:57:00","date_gmt":"2008-10-27T14:57:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=167"},"modified":"2008-10-27T23:57:00","modified_gmt":"2008-10-27T14:57:00","slug":"blogn-167","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=167","title":{"rendered":"\u67d4\u8edf\u306aPerl\u306e\u30ea\u30b9\u30c8\u3001\u5805\u7269\u306ePython\u306e\u30ea\u30b9\u30c8"},"content":{"rendered":"<p>\u4ee5\u524dC#\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u305f\u3068\u304d\u3001double\u3092\u7528\u3044\u30660\u3067\u5272\u308c\u3070\u7121\u9650\u5927\u306b\u306a\u3063\u3066\u305f\u3002<br \/>\u3053\u308c\u306f\u7d50\u69cb\u3059\u3054\u3044\u3053\u3068\u3067\u3059\u3088\u306d\u3002\u3082\u3061\u308d\u3093int\u3067\u306f0\u9664\u7b97\u306fDivideByZeroException\u306e\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3059\u308b\u3002<br \/>\u50d5\u306f\u3001\u3053\u306e\u53d6\u308a\u6271\u3044\u81ea\u4f53\u306f\u6b63\u3057\u3044\u3068\u601d\u3046\u3002<br \/>\u3068\u3044\u3046\u306e\u3082\u6d6e\u52d5\u5c0f\u6570\u70b9\u3068\u3044\u3046\u306e\u306f\u3001\u307e\u3041\u3074\u3063\u305f\u308a\u306e\u5024\u306b\u306a\u3089\u3093\u3053\u3068\u304c\u591a\u3044\u306e\u3088\u306d\u3002<br \/>\u4f8b\u3048\u3070\u30011.00005-1.00004\u306e\u8a08\u7b97\u7d50\u679c\u306f1.00000000001e-005\u3068\u306a\u3063\u305f\u3002<br \/>\u3055\u3089\u306b\u3053\u306e\u7d50\u679c\u3088\u308a1e-5\u3092\u5f15\u304f\u3068\u30016.55112222065e-017\u3068\u3044\u3046\u5168\u304f\u610f\u5473\u306e\u306a\u3044\u6570\u5b57\u304c\u51fa\u3066\u304f\u308b\u3002<br \/>\u305d\u3046\u3044\u3046\u3053\u3068\u3092\u8003\u3048\u308c\u3070\u3001\u7b49\u3057\u3044\u306f\u305a\u306e\u6570\u3067\u3082==\u3067\u6bd4\u8f03\u3059\u308c\u3070\u9055\u3046\u3068\u8a00\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u3057\u3001<br \/>\u3072\u3087\u3063\u3068\u3059\u308b\u30680\u306b\u8fd1\u3044\u3051\u30690\u3067\u306f\u306a\u3044\u6570\u5b57\u304c0\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u3002<br \/>\u307e\u3041\u305d\u3046\u3044\u3046\u6570\u5b57\u3067\u5272\u308b\u3068\u304d\u3001\u4e0d\u6b63\u306a\u884c\u70ba\u3067\u3042\u308b0\u9664\u7b97\u304b\u3001\u6b63\u5f53\u306a0\u306b\u304d\u308f\u3081\u3066\u8fd1\u3044\u6570\u5b57\u3067\u306e\u9664\u7b97\u304b<br \/>\u308f\u304b\u3089\u306a\u3044\u306a\u3089\u3068\u3001\u7121\u9650\u5927\u3092\u8fd4\u3059\u3068\u3002\u305d\u3046\u601d\u3044\u307e\u3059\u3051\u3069\u3002<br \/>\u540c\u69d8\u306e\u3053\u3068\u306fPerl\u3001Python\u3067\u306f\u901a\u7528\u3057\u307e\u305b\u3093\u3088\u3002Ruby\u3067\u306fC#\u540c\u69d8\u3002<br \/>IronPython\u3067\u306f\u4e00\u822c\u7684\u306aPython\u540c\u69d8\u4f8b\u5916\u304c\u51fa\u308b\u306e\u3067\u3001<br \/>0\u306e\u5834\u5408\u306f\u52d5\u4f5c\u3092\u5909\u3048\u3066\u89e3\u6c7a\u3057\u305f\u3002<\/p>\n<hr \/>\n<p>Perl\u3067\u3053\u3093\u306a\u4e0d\u6c17\u5473\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<pre>my $arr=[];<br \/>$arr->[5]=100;<br \/>print \"$_ : $arr->[$_]\\n\" foreach(0..$#$arr);<\/pre>\n<p>\u307e\u3041\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306a\u306e\u306f\u3042\u3093\u307e\u308a\u6c17\u306b\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<br \/>\u521d\u3081\u9577\u30550\u306e@$arr\u306b\u6025\u306b5\u756a\u306e\u5024\u3092\u4ee3\u5165\u3055\u308c\u305f\u3089\u3001\u3069\u3046\u306a\u308b\u304b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\u5c11\u306a\u304f\u3068\u3082\u9577\u30556\u306a\u3044\u3068\u3060\u3081\u306a\u306e\u3067\u3001\u9577\u30550\u304b\u30896\u307e\u3067\u4f38\u3070\u3057\u307e\u3059\u3088\u3068\u3002<br \/>\u305d\u306e\u4f38\u3070\u3057\u305f\u5206\u306f\u5168\u90e8undef\u304c\u5165\u3063\u3066\u307e\u3059\u3088\u3068\u3002<br \/>\u307e\u3041\u4e0d\u6c17\u5473\u306a\u4ed5\u7d44\u307f\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u3082\u306e\u3050\u3055\u306a\u4eba\u306b\u306f\u3042\u308a\u304c\u305f\u3044\u3053\u3068\u3067\u3059\u3002<\/p>\n<pre>my $obj1;<br \/>$obj1->[1]=20;<br \/>$obj1->[0]=10;<br \/>print join ',',@$obj1;<\/pre>\n<p>\u4e0a\u306e\u52d5\u4f5c\u306f\u304b\u306a\u308a\u4e0d\u6c17\u5473\u3002\u30b9\u30ab\u30e9\u30fc\u3092\u30ea\u30b9\u30c8\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306e\u3088\u3046\u306b\u53d6\u308a\u6271\u3046\u3060\u3051\u3067\u3001<br \/>\u52dd\u624b\u306b\u30ea\u30b9\u30c8\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u306a\u3063\u3066\u308b\u3068\u3002\u30cf\u30c3\u30b7\u30e5\u3082\u540c\u69d8\u3002<br \/>\u3053\u3053\u307e\u3067\u304f\u308b\u3068\u4f55\u304c\u4f55\u306a\u306e\u304b\u308f\u304b\u3089\u3093\u3002\u304d\u3061\u3093\u3068my\u4f7f\u3046\u5206\u306b\u306f\u4fbf\u5229\u304b\u3082\u3002<\/p>\n<hr \/>\n<p>\u3055\u3066\u3001\u540c\u69d8\u306e\u3053\u3068\u3092Python\u3067\u3084\u308d\u3046\u306a\u3093\u3066\u8003\u3048\u3061\u3083\u3060\u3081\u3067\u3059\u3002<br \/>\u5f53\u7136\u3067\u3059\u3002Perl\u304c\u5909\u306a\u3060\u3051\u3067\u3059\u3002<br \/>Python\u3067\u306f\u3001\u30ea\u30b9\u30c8\u306e\u6dfb\u5b57\u304c\u7bc4\u56f2\u5916\u3068\u304b\u3001\u8f9e\u66f8\u306e\u30ad\u30fc\u304c\u306a\u3044\u3068\u304b\u3001\u305d\u3093\u306a\u306e\u3067\u3082\u4f8b\u5916\u3002<\/p>\n<pre>mylist=[]<br \/>mylist[0]=10 # IndexError: index out of range: 0<br \/>mylist={}<br \/>mydict['tom']=20<br \/>print mydict['ken'] # KeyError: ken<\/pre>\n<p>\u4ee5\u4e0a\u306e\u901a\u308a\u3067\u3059\u3002<br \/>Perl\u306a\u3089\u7bc4\u56f2\u5916\u3060\u308d\u3046\u304cundef\u51fa\u3059\u3060\u3051\u306a\u3093\u3067\u3059\u3088\u306d\u3002<br \/>\u3051\u3069undef\u3068\u3044\u3046\u5024\u3092\u30ea\u30b9\u30c8\u3001\u30cf\u30c3\u30b7\u30e5\u306e\u5024\u306b\u5165\u308c\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u3002<br \/>\u305d\u3046\u306a\u308b\u3068\u3001exists\u95a2\u6570\u3067\u8abf\u3079\u306a\u3044\u3068\u533a\u5225\u304c\u3064\u304b\u3093\u3002<br \/>\u305d\u306e\u70b9Python\u306e\u53d6\u308a\u6271\u3044\u306f\u9069\u5f53\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<hr \/>\n<p>\u307e\u3041\u3057\u304b\u3057Perl\u3060\u3068\u975e\u5e38\u306b\u3044\u3044\u52a0\u6e1b\u306a\u53d6\u308a\u6271\u3044\u3067\u3082\u4fbf\u5229\u306b\u52d5\u304f\u306e\u306b\u3001\u56f0\u3063\u305f\u3002<br \/>\u4e0a\u306e mylist[0]=10 \u306f\u3069\u3046\u66f8\u3051\u3070\u3044\u3044\u306e\u304b\u3068\u3044\u3046\u306e\u306f\u5c11\u3057\u8003\u3048\u305f\u3002<br \/>\u307e\u3041\u3001\u3053\u3046\u3044\u3046\u306e\u306f mylist.append(10) \u3068\u3059\u308b\u306e\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002<br \/>\u305f\u3060\u3001\u6b20\u756a\u3068\u304b\u306b\u306f\u5bfe\u5fdc\u3067\u304d\u306a\u3044\u3088\u306d\u3002<\/p>\n<pre>while len(mylist)<=10:<br \/>  mylist.append(None)<br \/>mylist[10]=20<\/pre>\n<p>\u3053\u308c\u306f\u3069\u3046\u306a\u3093\u3060\u308d\u3002\u78ba\u304b\u306b\u6b20\u756a\u5bfe\u7b56\u306b\u306f\u306a\u3063\u305f\u3051\u3069\u3002<br \/>\u7d50\u8ad6\u304b\u3089\u8a00\u3048\u3070\u3001\u6b20\u756a\u4f5c\u3089\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u3001append\u3067\u5f8c\u308d\u306b\u5f8c\u308d\u306b\u9023\u306d\u3066\u3044\u304f\u3068\u3002<br \/>\u3069\u3046\u3082\u305d\u3046\u3059\u308b\u306e\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002<br \/>\u3061\u306a\u307f\u306bRuby\u306fPerl\u3068\u304b\u306a\u308a\u985e\u4f3c\u3057\u305f\u53d6\u308a\u6271\u3044\u3002\u3055\u3059\u304c\u306b\u52dd\u624b\u306b\u914d\u5217\u306b\u306a\u3063\u305f\u308a\u306f\u306a\u3044\u3051\u3069\u3002<\/p>\n<hr \/>\n<p>\u4e0a\u306e\u3088\u3046\u306a\u4e8b\u60c5\u3067\u304b\u306a\u308a\u82e6\u52b4\u3055\u305b\u3089\u308c\u305f\u3002<br \/>\u521d\u3081\u3001mylist[0]=10\u306e\u3088\u3046\u306a\u8a18\u8ff0\u306e\u3069\u3053\u304c\u60aa\u3044\u306e\u304b\u3068\u601d\u3063\u305f\u3002<br \/>len(mylist)\u304c0\u3060\u3068\u30010\u756a\u306e\u9818\u57df\u3059\u3089\u5b58\u5728\u3057\u306a\u3044\u306e\u306d\u3002<br \/>Perl\u3084\u3063\u3066\u308b\u3068\u3001push\u3068\u3044\u3046\u306e\u306f\u4fbf\u5229\u306a\u3082\u306e\u3068\u3044\u3046\u5370\u8c61\u3060\u304c\u3001<br \/>Python\u306b\u304a\u3044\u3066\u306fappend\u306f\u5fc5\u9808\u3067\u3042\u308b\u3001\u3068\u8a00\u3048\u308b\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u3002<br \/>\u3055\u3059\u304c\u3001\u3044\u308d\u3044\u308d\u3084\u308a\u65b9\u304c\u3042\u308bPerl\u3067\u3059\u306d\u3068\u304b\u3001\u305d\u3046\u3082\u601d\u3044\u307e\u3059\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524dC#\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u305f\u3068\u304d\u3001double\u3092\u7528\u3044\u30660\u3067\u5272\u308c\u3070\u7121\u9650\u5927\u306b\u306a\u3063\u3066\u305f\u3002\u3053\u308c\u306f\u7d50\u69cb\u3059\u3054\u3044\u3053\u3068\u3067\u3059\u3088\u306d\u3002\u3082\u3061\u308d\u3093int\u3067\u306f0\u9664\u7b97\u306fDivideByZeroException\u306e\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3059\u308b\u3002\u50d5\u306f\u3001\u3053\u306e\u53d6\u308a\u6271\u3044 [&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-1446","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1446","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=1446"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1446\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}