2011-03-01ãã1ã¶æéã®è¨äºä¸è¦§
å æ¥ãæé帯éè¤ãã§ã㯠ã®åé¡ã Scala ã§è§£ãã¦ã¿ãã®ã§ããããã®å¿ç¨ç·¨ãåºé¡ããã¾ããããªãã¨ããã客æ§ããä»æ§å¤æ´ãè¨ã渡ããã¾ãããã§ãã¨ãï¼ï¼ï¼ï¼ããã¼ãããã¼ããããã«è¨ã£ã¦ãã¼ãã¹ãã²ãã¼ãããã¼ï¼ï¼ï¼ä»åã¯ç¹ã«è¦æã¯ããã¾ãâ¦
ãé¡ï¼æé帯éè¤ãã§ã㯠- No Programming, No Life ã Scala ã§è§£ãã¦ã¿ã¾ãããã失æãããããããªãå¦çããè¨è¿°ããéã«ãJava ã§ã¯ä¾å¤ã使ãã¨æãã¾ãããScalaã§ã¯ãOption ã使ãã¨ããé¸æè¢ãããã¾ããããã§ãä»åã®çæ¡ã¯ãä¾å¤ã§ã¯ãªãã¦â¦
ã¡ãã£ã¨æ©ãã ããã©ãã¾ã¨ããªè§£æ³ãèãã¤ããã¨ãã§ãããåºæ¬çã«ã¯ç¯©æ¹å¼ã®ã¢ã«ã´ãªãºã ã object Prob216 { def solve { val N = 50000000 //10000 val nToT: Int => Long = n => 2L * n * n - 1 val tSeq = Array.tabulate(N + 1)(nToT) for { n <- â¦
ããã°ã©ãã³ã°åé¡ãµã¤ãProject Eulerã®ç¬¬216åã«ããããªåé¡ãåºãã1 èªç¶æ° n ã«ã¤ãã¦ã2*n2-1 ãç´ æ°ã¨ãªããã®ã®åæ°ãæ±ããæ®éã«ç´ æ°å¤å®ããã¨è¨ç®æéããããï¼ä¸æéãããï¼ï¼ã®ã§å·¥å¤«ããã¢ã«ã´ãªãºã ã§è§£ããã¨ããã®ãåºé¡æå³ã¨æããâ¦
scala 㧠collection ã®è¦ç´ ã®åè¨ãæ±ããæ¹æ³ã«ã¤ãã¦ãæ¯è¼æ¤è¨ããã¦ããã Scala åç®å®é¨(Hishidama's Scala sum Memo) Numeric[T]ãèªåã§å®è£ ã㦠sum ã使ããããã¨ãããã¼ããããæããã£ãããã¿ãããªãã§ããå帰ã®æ¯è¼ãé ããªããVector/Wâ¦
ãããããä½è½ãå æ¸ãæãã¦ããã¾ãããï¼ä¾ãã°ãæç« æ§æã®ã¾ããã¨ããã³ãã¥éãªæãã¨ãã