ÏÂÃæÊÇÊä³öÒ»¸öСÓÚ100µÄFibnancciÊýÁУº
class test1
def Fib(max)
i1,i2 = 1,1
while i1 <= max
yield i1
i1,i2=i2,i1+i2
end
end
end
Fib(100){|f| print f," "}
ÓÉÓÚÓе㿴²»¶®£¬ÏÖÔÚÎÒ¸ÄÒ»ÏÂ
class test2
def test2.Fib
i1,i2 = 1,1
i1,
i2=i2, ££È¥µô¾Í±¨´í
i1+i2
end
end
ÎÒÏëÎʵÄÊÇ£º
1.ÔÚtest2ÀïÃæFibµÄ·µ»ØÖµÊÇÔõôËãµÄ£¿ÊDz»ÊÇ[i1,i1+i2]?Ϊʲôȥµôi2=i2»á¾Í±¨´í£¿
2.test1µÄwhileÑ»·ÊÇÔõôִÐеģ¿ÎÒµÄÏë·¨ÊÇ
µÚÒ»´ÎÑ»·,i1=1
yield 1
[1,2]
µÚ¶þ´ÎÑ»·,i1=1
yield 1
[1,3]
µÚÈý´ÎÑ»·,i1=1......²»¶Ô¾¢ÁË...
yield 1
[1,4]
..........
²Åѧruby£¬Ï°¹ßÁËc#ºÍjavaʽµÄÓï·¨£¬¾õµÃrubyÓï·¨ÕæËûÄïµÄ¹îÒì¡£¡£¡£
i1,i2=i2,i1+i2
ÀàËÆ£ºi1=i2;
i2=i1+i2;
rubyµÄº¯Êý£¬Èç¹ûûÓÐÃ÷È··µ»ØÖµ£¬¾Í·µ»Ø×îºóÒ»¸ö±í´ïʽµÄÖµ£¬
test2ÀïÃæFibÀïÊÇ
i1,
i2=i2, ££È¥µô¾Í±¨´í
i1+i2
ÎÒÕâ±ßÖ´ÐÐÆðÀ´ÊÇ12£¬¼´ÏÈ´òÓ¡i1£¬ºó´òÓ¡i2
test1µÄwhileÑ»·
µÚÒ»´Î
yield 1
[1, 2]
µÚ¶þ´Î
yield 1
Ïà¹ØÎÊ´ð£º
±¾ÈËÓеãC££¸újavaµ××Ó£¬»ØÍ·Ö±½ÓÀ´Ñ§ROR¡£
Ôõô¸Ð¾õROR¾ÍÄÇô¶ñÐÄÈË£¬µ«ÓÖºÜÏëѧºÃ£¬ÆÈÓÚ¸÷·½ÃæÑ¹Á¦Ò²Ö»ÄÜѧϰROR¡£Ñ§ÁË´ó¸ÅÓÐÁ½¸öÔ°ɣ¬¿ÉÎÒ×ܸоõ×Ô¼ºÃŶ¼Ã»Èë¡¡Ì«¶àµÄÉËÐĵϰ¾Í²»Ïë¶à˵ÁË£¬Ö»Ï£Íû¿´µ½µÄ¸ß ......
¸øJavascriptºÍRuby¿ª¸öÂÛ̳רÀ¸°É!
¸øJavascriptºÍRuby¿ª¸öÂÛ̳רÀ¸°É!
¸øJavascriptºÍRuby¿ª¸öÂÛ̳רÀ¸°É!
JavascriptÓÐרÀ¸µÄ£ºhttp://forum.csdn.net/SList/JavaScript
×ð¾´µÄÓû§deping_chen£¬ÄúºÃ£º ......
HTML code:
<%= link_to_if_authorized l(:field_search_title), {:controller => 'books', :action => 'search', :project_id => @project, :title => @title} %>
<%= text_field_tag 't ......
Ò»¸öͬѧ£¬¸Õ¸Õ´óѧ±ÏÒµ£¬µ½º¼ÖݵÄÒ»¼ÒÈÕÆó×öÍâ°ü£¬ÊÇÓõÄruby£¬ÔÂнһ¿ªÊ¼¾Í£¤8000ÁË£¬ÉÏÒ»Äêµ½ÄǵÄʦÐÖ¶¼ÉÏÍòÁË£¬ÎªÊ²Ã´×öphpÖ»ÓÐÄÇô2~3k£¿
ÒòΪ¶®rubyµÄÉÙ£¬ÎÒÃÇÕâ±ß»¹ÓÐ1.5WµÄÄØ
ÎïÒÔϡΪ¹ó
php,.net
ËÈ ......