scheme
æ¸ãçµãã£ã¦æ°ãä»ããã®ã§ããã"palindoromic"ã§ã¯ãªãã¦"palindromic"ã§ãããæç« ã¯ãããã½ã¼ã¹ã³ã¼ãã¾ã§ãã¹ã¦ééã£ãã¤ã¥ãã«ãªã£ã¦ãã¾ãâ¦â¦ãæ©ä¼ãããã°ä¿®æ£ãã¾ãããã¿ã¾ãã(´ã»Ïã»`) ã¨ãããProject Eulerã解ãã¦ããã¨é »ç¹ã«è¦æ±ãããâ¦
ãã¤ãã©ãã(?)ã¤ã³ã¿ã¼ããããæ¼æµãã¦ããã¨ãsomos sequence(以ä¸ãã½ã¢ã¹ã®æ°åã)ãªããã®ãè¦ã¤ãã¾ããããã詳ãããã¨ã¯ãããåç §ãã¦ã»ããã®ã§ãããããããªãã«ç°¡åã«è¦ç´ãã¦ã¿ãã¨ââ4以ä¸ã®æ´æ°kã«ã¤ãã¦æ¬¡ã®ãããªæ¼¸åå¼/æ°åãèãã¾ãâ¦
ã¿ã¤ãã«ã®ã¨ãããCodeIQã®ããã»ã«ã³ãã»ã¤ã¯ã¨ã¤ã·ã§ã³ãåé¡ãã®æ²è¼æéãçµäºããã¨ãããã¨ã§ããããã®æåºã³ã¼ãããããã¦ããããã¨æãã¾ãã使ç¨è¨èªã¯Rubyã1åã®æåºã§éã£ãè¨æ¶ãããã¾ã(èªåæ¡ç¹ãªã®ã§å¿ããã¡)ã ã¢ã«ã´ãªãºã ã«ã¤ãã¦â¦
ãªã¹ãã®è¦ç´ ãæ¤æ»ãã¦è¿°èªã#tãè¿ãè¦ç´ ãæ°ããé¢æ°ââ以ä¸counté¢æ°ã¨ç§°ããââãscheme/srfi/gaucheã«ã¯ãªãããã ã£ãã®ã§ãããããå®è£ ãããã¨ã«ãªã£ãã®ã§ããââãã®éããã¤ãæ¹æ³ãæãã¤ãããããã©ã®æ¹æ³ãå¹ççãªã®ãããããã£ã±ã«è¨æ¸¬ãã¦â¦
ã¾ãã¯ç´ æ°å¤å® ; æå®ãããæ´æ°ãç´ æ°ãã©ãããå¤å®ãããæ»ãå¤ã¯boolã ; 注æã¨ãã¦ã¯æ´æ°ä»¥å¤ãæå®ããªãã§ãã ããã ; (prime? 2) => #t ; (prime? 4) => #f (define (prime? number) (cond ((< number 2) #f) ; è² ã®æ°ãªãã³ã«1ãªãã°ç´ æ°ã§ã¯ãªâ¦
Rubyã§ããã¨ããã®map.with_indexãããªãã¡ãã¤ã³ããã¯ã¹ä»ãmapããSchemeã®ã½ã¼ã¹ã³ã¼ããæ¸ãã¦ããæä¸ã«å¿ è¦ã ã£ãã®ã§ããã¯ãã«ããå®è£ ãã¾ããã ; procã®ç¬¬1å¼æ°ã«ã¤ã³ããã¯ã¹(0..*)ãå ¥ããããªmap ; ãªã¹ãã¯1ã¤ä»¥ä¸æå®ã§ããããã²ã¨ã¤ã§â¦
æå®ãããããªãã¿ãåºåãæåã¨ãã¦æååãåå²ããªã¹ãã«æ ¼ç´ããé¢æ°ââããããsplité¢æ°ãå ¥ç¨ã«ãªããã¨ããããããããæ¸ãã¾ããããã£ãããªã®ã§ããã°ã«ã¯ãã¤ãã¦ããã¾ãã ; 第2å¼æ°ã®æåéåãåºåãæåã¨ãã¦ã第1å¼æ°ã®æååãåºåãâ¦