Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃRuby дTuring »ú


×î½üÔÚ¿´John E.Hopcroft,Rajeev Motwani,Jeffrey D.Ullman Èý¾ÞͷдµÄIntroduction to Automata Theory,Language,and Computation£¬Ïëдһ¸öTuring »úÑéÖ¤Ò»ÏÂ×Ô¼ºÐ´µÄ״̬תÒƺ¯Êý¶Ô²»¶Ô¡£ÀÁµÃºÜ£¬ÍøÉÏËÑÁ˼¸¸ö²»´íµÄ¡£µ«Ruby Quiz ÉϵÄÕâ¸ö×î¼òµ¥¡£
162 Turing »ú
ÎÊÌâÃèÊö
Quiz
description by James Edward Gray II
Turing »úÊÇÊ®¾ÅÊÀ¼ÍÈýÊ®Äê´úÌá³öµÄÒ»ÖֽṹºÜ¼òµ¥µÄ¼ÆËãÄ£ÐÍ¡£ËäÈ»Ëü±ÈÈç½ñµÄÈκμÆËã»ú¶¼Òª¼òµ¥£¬µ«´óÁ¿Ñо¿±íÃ÷Æä¼ÆËãÄÜÁ¦Ë¿ºÁ²»ÈõÓÚÈκÎÄÜÏëµ½µÄ»úÆ÷£¨µ±È»£¬ÓÃÆðÀ´²»Ì«·½±ã£©¡£
ÕâÖܵÄÈÎÎñÊÇÔį̀Turing »úÀ´ÍæÍæ¡£
һ̨Turing »ú°üÀ¨Èý¸ö¼òµ¥²¿¼þ£º
* Ò»¸ö״̬¼Ä´æÆ÷
* Ò»ÌõÎÞÏÞ³¤µÄÖ½´ø£¬Ö½´ø±»·ÖΪÎÞÊýС¸ñ£¬Ã¿¸ö¸ñ×ÓÄÜÈÝÄÉÒ»¸ö×Ö·û¡£»¹ÓÐÒ»¸ö¶Áдͷ£¬ÔÚÈκÎʱ¿Ì¶¼»áÖ¸ÏòÒ»¸öÈ·¶¨µÄС¸ñ¡£Ö½´øÉÏĬÈÏÊÇ¿Õ×Ö·û¡£
* Ò»×éÓÐÏÞÖ¸Á¡£³ÌÐò¾ÍÊÇÒ»¸ö״̬ǨÒƵĴó±í¸ñ¡£Turing »ú¸ù¾Ý״̬¼Ä´æÆ÷µÄµ±Ç°ÖµºÍ¶ÁдͷËùÖ¸µÄ×Ö·û²éµÃÒ»ÌõÖ¸Áî¡£ÕâÌõÖ¸Áî°üÀ¨¼Ä´æÆ÷µÄÐÂ״̬£¬ÌîÈë¶ÁдͷָÏòµ¥ÔªµÄ×Ö·ûºÍ¶ÁдͷÏÂÒ»²½Òƶ¯µÄ·½Ïò¡£
ΪÁËÈÃÎÒÃǵÄTuring »ú×ã¹»¼òµ¥£¬ÎÒÃǹ涨״̬¼Ä´æÆ÷ÈÝÄɵÄ×ÖÓ¦Äܱ»ÕýÔò±í´ïʽ /\w+/ Æ¥ÅäÉÏ£¬¶øÖ½´øÉϵÄ×Ö·ûÒªÄܱ» /\w/ Æ¥ÅäÉÏ¡£ÁíÍ⣬ÎÒÃǹ涨¿Õ×Ö·ûΪÏ»®Ïß(_)¡£
Turing »úµÄ³ÌÐò¸ñʽÈçÏ£º
CurrentState _ NewState C R
ÉÏÊö¸ñʽÒâ˼ÊÇ£ºÈç¹ûµ±Ç°×´Ì¬ÊÇCurrentState ¶ø¶ÁдͷËùÖ¸µÄ×Ö·ûÊÇ¿Õ×Ö·ûµÄ»°£¬°Ñ״̬ÖÃΪNewState £¬²¢ÓÃ×Ö·ûC Ìæ»»¿Õ×Ö·û£¬È»ºó¶ÁдͷÓÒÒÆÒ»¸ñ¡£ÕâÎå¸ö²¿·ÖдÔÚÒ»ÐÐÀïÃ棬Óÿոñ¸ô¿ª¡£ÔÊÐí³ÌÐòÖгöÏÖµ¥ÐÐ×¢ÊÍ£¬¸ÃÐÐÖо®ºÅ(#)ËùÆðµÄ²¿·ÖΪעÊÍ¡£×¢ÊÍ¡¢¿Õ°×Ðн«±»ºöÂÔ¡£
ÄãµÄTuring »úÓ¦±»³õʼΪ³ÌÐòµÚÒ»ÐÐÖеÄCurrentState¡£µ±È»ËæÄ㣬ÄãÒ²¿ÉÔÚ³ÌÐòÔØÈëʱԤÖúÃÖ½´øµÄÄÚÈÝ£¬µ«È±Ê¡Îª¿Õ×Ö·û¡£µ±³ÌÐòÕÒ²»µ½Ò»ÌõÓ뵱ǰ״̬ºÍ¶ÁдͷËùÖ¸×Ö·û¶ÔÓ¦µÄÖ¸Áîʱ£¬´òÓ¡³öÖ½´øÉÏ´ÓµÚÒ»¸ö·Ç¿Õ×Ö·ûµ½×îºóÒ»¸ö·Ç¿Õ×Ö·ûÖ®¼äµÄÄÚÈÝ£¬È»ºóÍ˳ö¡£
ÏÂÃæÊÇÒ»¸öʾÀý£¬Äã¿ÉÒÔ¿´µ½ÎÒµÄTuring »úÊÇÔõôÔËÐеģº
$ cat palindrome.tm
# Report whether a string of 0 and 1 (ie. a binary
# number) is a palindrome.
look_first 0 go_end_0 _ R
look_first 1 go_end_1 _ R
look_first _ write_es Y R
go_end_0 0 go_end_0 0 R
go_end_0 1 go_end_0 1 R
go_end_0 _ check_end_0 _ L
go_end_1 0 go_end_1 0 R
go_e


Ïà¹ØÎĵµ£º

Ò»²½Ò»²½Ñ§Ruby(Ê®¶þ):RubyÀà

Ò»¡¢ÀàµÄ¶¨Òå¡¢ÀàµÄʵÀý·½·¨ ¶þ¡¢Ìض¨¶ÔÏóµÄ·½·¨ ÔÚRubyÀÎÒÃÇ¿ÉÒÔΪһ¸ö¶ÔÏ󵥶À¶¨Òå·½·¨ Èý¡¢Öض¨Òå·½·¨ ´ÓÏÂÃæ´úÂë¿ÉÒÔ¿´³ö£¬ºóÃæµÄ¶¨Òå»á¸²¸ÇÇ°ÃæµÄ¶¨Òå ËÄ¡¢ÖØдò¿ªÀà RubyÀïÎÒÃÇ¿ÉÒÔÔÙ´ò¿ªÒ»¸öÀ࣬ÏòÕâÀàÌí¼Ó·½·¨£¬ÓеãÏñC#ÀïµÄ·Ö²¿À࣬µ«²»ÓüÓÌرð±ê¼Ç. ÎÒÃÇÒ»°ã²»Òª²ð¿ªÀàµÄ¶¨Ò壬ÒòΪÄÇÑù²»ºÃÀí½ ......

Çå³þVSSÎļþµÄÅú´¦Àí(Ruby°æ)

 
def delVss(path)
  if File.directory?(path)
    for f in d = Dir.open(path)
        fpath = File.join(path, f) 
      if(f!="."&&f!="..")      
    ......

ubuntuÏ´ruby on rails

 Ò» °²×°ruby
$sudo apt-get install ruby irb rdoc
¶þ °²×°gem
1.µ½ÕâÀïÏÂÔØ ,×îºÃÊÇ×îа汾£¬ÎÒµÄ1.3.5
½âѹ£¬Çл»µ½µ±Ç°Ä¿Â¼£¬Ö´ÐÐ$sudo ruby setup.rb
»òÕßÕâÑù£º
$ tar xzvf rubygems-1.3.5.tgz   £¨½âѹ£©
$ cd rubygems-1.3.5     £¨Çл»µ½´ËĿ¼£©
$ sudo ruby setup ......

Óà Ruby ²È²ÈËÄÈË°ï




ÉÏÉÏÖÜÔÚÊéµê¿´µ½Ò»±¾¡¶Ruby
Éè¼Æģʽ¡·£¬¼ñÆðÀ´ 10 ·ÖÖÓ¿´Í꣬ÈÓÁË£¨±ðÎÊÎÒΪʲô……£©
ÏÂÃæÓÃ Ruby
ддÉè¼Æģʽ£¬Ë³±ãÅúÒ»Åú Java ºÍ Gof
¡£
1.Factory
ºÍ Abstract Factory
class
 Factory  
  attr_accessor :product
   ......

Ruby 1.9²»»áɱËÀPython

Ëɱ¾ÐкêÈçÔ¼ÓÚÊ¥µ®½Ú·¢²¼ÁËRuby 1.9¡£¸ù¾ÝRubyµÄ¹ßÀý£¬Ð¡ÊýµãºóÃæµÚһλÈç¹ûÊǵ¥Êý£¬ÄÇô¾Í±íÃ÷ÕâÊÇÒ»¸öʵÑé°æ±¾£¬²»ÍƼöÓÃÓÚ²úÆ·»·¾³¡£Ëùν“²úÆ·»·¾³”£¬¶ÔÓÚÄ¿Ç°µÄRubyÀ´Ëµ£¬»ù±¾ÉϾÍÊÇRuby on Rails¡£´ÓÄ¿Ç°RoRÉçȺµÄ·´Ó³À´¿´£¬È·ÊµÓÐÈËÕýÔÚ³¢ÊÔÓÃRuby 1.9ÅäºÏRoR£¬µ«ÊÇÉÐÊôÍæƱÐÔÖÊ¡£ÎÒѯÎÊÁËһЩ´¦ÔÚÕæÊµÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ