Groovy ASTå¤æã«ããã³ã³ãã¤ã«æã¡ã¿ããã°ã©ãã³ã°ã«ã¤ãã¦ã調æ»ãç¶ç¶ãã¦ãã¾ããä»æ¥ã¯ãç°¡åãªã³ã¼ããæ¸ãã¦ã¿ã¾ãããã³ã³ãã¤ã«ä¸ã« AST å¤æãè¡ããä»»æã®ã¡ã½ãããã¡ã¢åã§ãã¾ããã¨ãããã使ç¨ä¾ãã @Memoized def fib(n) { if (n <= 1) â¦
Groovy ã§ã¯ãAST ãã«ã¸ã¥ã¢ã«ã«å¤æã§ããã¨èãã¾ããããµã¤ã³ã¼ãããªãã§ãããã¨ãããã¨ã§ããããªã AST å¨ãã調ã¹ã¦ãã¾ããã§ãä¸ã¤çåããint + int ã®è¨ç®ã§ããããã¤ã左辺å¤ã®ã³ã³ããã¹ãã int ãè¦æ±ãã¦ããã®ã«ããªãã§ä¸å Object ã«â¦
æ¯è¼ã¢ããã«ã¤ãã¦èå¯ããã¦ããä¸é£ã®ã¨ã³ããªã«æéãåãã¦ãç§ãæ¯è¼ã«ã¤ãã¦èãã¦ã¿ã¾ããã æ¯è¼ã¢ãã - terazzoã®æ¥è¨ ç¶ã»æ¯è¼ã¢ãã - terazzoã®æ¥è¨ ç¶ã»ç¶ã»æ¯è¼ã¢ããã復è®ç·¨ã - terazzoã®æ¥è¨ ã¾ããèå¯å¯¾è±¡ã¨ãã¦ãæ¯è¼çµæãã¨ãæ¯è¼â¦
scala ã® parallel collection ã¯ãæ®éã® collection ã使ãããã«ä½¿ã£ã¦ããã ãã§ã並åè¨ç®ã®æ©æµãåããããå ´åãå¤ãã®ã§ãããããã§ã¯ãªãå ´åãå¤ãã§ãããã®å ¸åä¾ããã½ã¼ãã§ããå®ã¯ã並åã®ã½ã¼ãã¯ãã¾ã å®è£ ããã¦ãã¾ãããããããèªåâ¦
Scala exercises for beginners ã foldLeft ã§è§£ãã¦ã¿ãã // Exercise 2 def sum(x: List[Int]): Int = x.foldLeft(0){_ + _} // Exercise 3 def length[A](x: List[A]): Int = x.foldLeft(0){(sum, _) => sum + 1} // Exercise 4 def map[A, B](x: List[â¦
akka ã®ä¾é¡ã§ã¯ãarctan(1) ããã¼ã©ã¼ç´æ°å±éãã¦åå¨çãæ±ããã¨ããä¾é¡ãåãä¸ãã¦ãããå ·ä½çã«ã¯ãä¸è¨ã®æ°å¼ã10000é ã㤠Actor ã«å²ãæ¯ã£ã¦ã並åè¨ç®ãã¦ããããã®ãããªç´æ°ã scala ã§ä¸¦åè¨ç®ããæ¹æ³ã¨ãã¦ã¯ãakka ã使ã以å¤ã«ããscâ¦
Scala ã使ã£ã¦ Haskell 風ã®è¨è¿°ããã¦ããä¾ãæã è¦ãããããã©ãå¾¹é 徹尾 Haskell ã«ãªã£ã¦ããä¾ã¯ãã¾ãè¦æããªããã¢ããªã±ã¼ã·ã§ã³ãã¸ãã¯ã ãè¦ãã°åããªãã ããã©ãå®éã®å é¨åä½ã¯å ¨ç¶éã£ã¦ããããããããã¦ãããã©ã¼ãã³ã¹ãè´å½çã«â¦
groovy 1.8 ã§ã¯ãmemoize ã«ãã£ã¦ã¯ãã¼ã¸ã£ã®ã¡ã¢åãåºæ¥ãããã«ãªã£ãããã©ãscala ã ã£ã¦ã§ãããããã¨ããè² ãæãã¿ã¨ã³ããªã æ®éã®èªåã¡ã¢å ãµã¯ã£ã¨ä½ã£ããã®ã(1ã5å¼æ°å¯¾å¿)ãGistã«ä¸ããã®ã§ç°¡åã«ç´¹ä»ãå®è£ ã®ãã¤ã³ãã¯åç´ã§ãä¸è¨â¦
ç´ å æ°å解ã ã®å½¢å¼ã«ãªãæ°ãããã³ã°æ°ã¨ãã*1ããã®æã®åé¡ã¯ããã¯ã Haskell ã§æ¸ãã¨ã¹ãããªãããHamming numbers - Rosetta Code ãã Haskell ã®ã³ã¼ããå¼ç¨ããã hamming = 1 : map (2*) hamming `merge` map (3*) hamming `merge` map (5*)â¦
ã¾ãã¯ãçµæãä¸å³ã«ç¤ºãã¾ãããªããã³ããã¼ã¯ã«ä½¿ç¨ããã³ã¼ãã¯ä¸è¨ã®èª¬æã³ã¼ãã¨ã¯éãããã¥ã¼ãã³ã°æ¸ã¿ã§ããé次平æ¹å¤æã®ã³ã¼ãã¯ãdev68 ããã® groovy å®è£ ããã®ã¾ã¾ scala ã«ç§»æ¤ãã¾ãããã¾ãããã®ã¨ã³ããªããã£ããã¨ãã¦ããã®ã¨ã³â¦
ã¯ããã« ãã£ããããæ°åã®é«éãªç®æ³ã§ãã é次平æ¹å¤æ Binetå ¬å¼ ã«ã¤ãã¦ãç·å½¢ä»£æ°çãªè¦ç¹ãã説æãä¸ãã¦ããã³ããã¼ã¯ãã¦ã¿ã¾ããããªãã©ã¡ãã®æ¹æ³ã«ã¤ãã¦ãã詳ãã説æã¯ä¸ã®ä¸ã«åºåã£ã¦ããã¯ãã§ãããç§ã«ã¨ã£ã¦ãããã®èª¬æã¯å¤©æã®â¦
æè¿ãç¡æèã®ãã¡ã«é 延è©ä¾¡ãåæã¨ããã³ã¼ããæ¸ãããã«ãªã£ã¦ãã¾ããã趣å³ã® scala ã³ã¼ãã°ãããæ¸ãã¦ããå¼å®³ã§ããããããããªé 延è³ã失æ ãããããã¾ãããæ£æ ¼è©ä¾¡åæã®è¨èª(Ruby)ã§ãé 延è©ä¾¡ãæå¾ ããã³ã¼ããæ¸ãã¦ãã¾ããããã°ã©â¦
Scala ã® for å¼ã§è¦é¢ç®ã解ãã¦ããã¨ã³ããªãè¦ã¤ãã人ã Haskell 㨠Groovy ã§è§£ããªãããªã¹ãå å 表è¨ã«ã¤ãã¦èãã¦ããããã®ãããªã¨ã³ããªãè¦ãããã¨ããã¤ãé¢ç½ããªã¼ã¨æå¿ãããã©ãã©ããç§ã¯å®æ¦ã§ä½¿ãããªãã¦ããªããããããã¯ãããâ¦
ãã¡ãã®åé¡ã解ãã¦ã¿ã¾ãããã°ã©ãé£çµã«é¢ããçè«ãå ¨ã使ã£ã¦ããªãã¨ããæå³ã§ãåæã§ããä¸æ¹éè¡ã®ãã¢ãå£ã«åå¨ããæå¾ å¤ã40%ãããã¾ã§ãªãããªãã¨ããªãã¾ããã 35%ãåã£ã¦ããã¨ããã®ã¾ã¾ã§ã¯å³ããããããã¾ãããå帰ã®ä»æ¹ã¨ãã¯â¦
ãé¡ï¼æé帯éè¤ãã§ãã¯ï¼å¿ç¨ç·¨ï¼ - No Programming, No Life ã«é¢ãã¦ã解æ³ã¯ï¼ç¨®é¡ã«å¤§å¥ã§ããããã§ãã 解æ³ã®åé¡ é¢æ£æå»æ¹å¼ ãæé帯ï¼ä½æä½åããä½æä½åã¾ã§ï¼ã«å«ã¾ããæå»ï¼ä½æä½åï¼ã®æå°åä½ã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â¦
ãããããä½è½ãå æ¸ãæãã¦ããã¾ãããï¼ä¾ãã°ãæç« æ§æã®ã¾ããã¨ããã³ãã¥éãªæãã¨ãã