2012-01-01ãã1å¹´éã®è¨äºä¸è¦§
ä»å¹´ãååãçµãããã¨ãã¦ããã1æã® TODO ã解決ããã 404 Blog Not Found:Algorithm - Suffix Array ã JavaScript ã§åçºæãã¦ã¿ã Suffix Array ã§ã¯ãªã BWT ã®æ¹ãã Groovy ã§å®è£ ãã¦ã¿ã åè http://homepage3.nifty.com/DO/blocksorting.htmâ¦
ããããHaskellãã®ããå¦ã¼ã!ã ã® 10ç« ã®éãã¼ã©ã³ãè¨æ³é»åã Groovy, Scala, Clojure, Scheme ã§æ¸ãã¦ã¿ãã Reverse Polish notation calculator Groovy def solveRPN(expr) { expr.tokenize().inject([]){ acc, v -> "*" == v ? [acc[1] * acc[0]â¦
é ã®ä¸ã®ç°è²ã®ç´°èã CPU ã HDD ã ã£ãã¨ããã ç¥ã£ã¦ãããã¨ãå¢ããã®ã¯ HDD ã«æ¸ãè¾¼ãã ããã¨ãããã¨ã«ãããã ããããããã°ã©ãã³ã°è½åãåä¸ãããã¨ã説æããã®ã¯é£ããã ãªããªã CPU ã¯å¤ãã£ã¦ããªãã®ã ããã èããããã®ã¯ HDD ã®â¦
æè¿è©±é¡ã®ã¿ã¤ãã«ã¯ããã®ããèªãã§ããéä¸ï¼9ç« ã«å ¥ã£ã)ã ãã®è©±ã§ã¯ãªãããã®ã¨ã³ããªã¯ Clojure 㧠Ninety-Nine Prolog Problems ããã£ã¦ããã¨ãã«æãã¤ãããã®ã 1. Prolog Lists - Prolog Site Ninety-Nine Prolog Problems ã Lists ã®ã¨ãâ¦
ãããã Haskell ã®æ¬ãåºçãããã®ã§å¾©ç¿ããã ãããã°ã©ãã³ã° Haskellã ã®ç¬¬8ç« ãä»å㯠Scala(version 2.9.2) ã§æ¸ããScala çã«ä½¿ã£ãæ¹ããããããã®ã§ Option ã Either ãåå¼·ããã Scala ã® API ã¨ä»¥ä¸ãåèã«ããªããæ¸ãã¦ã¿ãã Java â¦
ããã¯ãã¼ã¯ãç¡éãªã¹ãã®ãããªãã®ãªã®ã§ head ãã¤ããã ã¾ã¾ç¶ãã¦ãã㨠Out of Memory ã«ãªãã ãªã®ã§ãæ°å転æã«æ´çãã¦ã¿ãã æ´çã®æ¹æ³ å¤ãæ¹ããé ã«å¤æããã æåããèãã¦ããããã§ã¯ãªãããçµæçã«4ã¤ã«å¥ããã ã«ãã´ã©ã¤ãºãã¦â¦
O'Reilly ã§ã¯ Open Feedback Publishing System ã¨ãã£ã¦å·çä¸ã®æ¸ç±ã«ã³ã¡ã³ãã§ããããã(ãã ã English)ã Online Feedback Publishing System - O'Reilly Media ã¨ãããã㧠Grails ã®æ¬ãåºãã¿ãã(ã¾ã ååãæ¸ããã¦ããªã)ã Online Feedback â¦
WEB+DB PRESS Vol.67 ã®æé·éè¤æåååé¡ããã£ã¦ã¿ãã ããå°ãåã«å®è£ ãã¦ããã®ã ãã© takeWhile å¾ ã¡ãã¦ããéã«ç®çãå¤ãã£ã¦ãã¾ã£ãã Clojure ã Scala ã§ã¯æ¢ã«å®è£ ããã¦ããæ¹ãããããã WEB+DB PRESS Vol.67ã®æé·éè¤æåååé¡ãClojuâ¦
Clojure ç·¨ã«ã¤ã¥ã Scala 編㸠Scala 㯠Haskell ã®å¤ãã®é¢æ°ãç¨æããã¦ããã®ã§ Haskell ããã®æ¸ãæããã®ã«ã¯æå©ã ã def makePair [T](xs: Seq[Seq[T]]) = xs zip xs.tail def comlen [T](p: (Seq[T],Seq[T])) = p.zipped takeWhile(x => x._1 == â¦
Clojure ãå¦ã¶ Groovy 㨠Scala 㯠Java ã®æååããçã¾ãããã®ã ããClojure 㯠Lisp ã®æååãã Java ã«å ¥ã£ã¦ãããã®ã ã é¢æ°ã®å¼ã³åºãã (é¢æ°å å¼æ°1 å¼æ°2 ...) ã¨åç½®è¨æ³ã§æ¸ãããªã¹ãã§ããã¨ãã㯠Lisp ã ããä»ã® Lisp ç³»è¨èªã«æ¯ã¹â¦
1å¹´åãããã«èªãã§ããããããªãã£ããã©ãããããç解ã§ããæ°ãããã®ã§æ¸ãã¦ã¿ãã ãªãé¢æ°ããã°ã©ãã³ã°ã¯éè¦ã *1 John Hughes æ°ã®ä¸»å¼µ ããã°ã©ã ãã¢ã¸ã¥ã¼ã«åããã«ã¯é¢æ°ããã°ã©ãã³ã°ã®ã¹ã¿ã¤ã«ã§æ¸ãã¨ãããã é«éé¢æ°ã使ãã¨æã â¦
ååã®æ¨æ§é ã¨åãããã«ãªã¹ãã表ç¾ããã¨ã©ããªãã®ã? def tree = { [:].withDefault{ owner.call() } } def list = { h, t -> [h, { t?.call() }] } ã¡ãã£ã¨æå³ãéãæ°ããããã©æ°æã¡ã®åé¡ã®ç¯å²ãªã®ã§ç¶ããã h ã¯å é ã®è¦ç´ ã§ãt ã¯è©ä¾¡ããâ¦
Groovy ã§ã¯æ¨æ§é ã次ã®å½¢ã§è¡¨ç¾ã§ãããããã def tree = { [:].withDefault{ owner.call() } } def users = tree() users.harold.username = 'hrldcpr' users.yates.username = 'tim' def json = new groovy.json.JsonBuilder(users).toString() assert â¦
SQL-99 ã§ã¯å帰ã使ããã®ã§ãããã使ã£ã¦ Hamming numbers ãåºåããã ã¾ãã¯ãå帰ã¯ã¨ãªã使ãããã¼ã¿ãã¼ã¹ã調ã¹ã¦ã¿ãã å帰ã¯ã¨ãª - Wikipedia H2 Database ãä¸çªæ軽ã«å°å ¥ã§ããã®ã§ããã使ã£ã¦ã¿ãã å帰ã¯ã¨ãªã®æ¸ãæ¹ H2 Dataabse ã®ãâ¦
O'Reilly ã§ã¯ Open Books ã¨ãã£ã¦ä¸é¨ã®æ¸ç±ãã¾ãã¾ãèªãããããã O'Reilly Open Books Project concurrency ã調ã¹ã¦ãgroovy and concurrency ãè¦ã¦ããã Groovy ã® O'Reilly æ¬ãç®ã«å ¥ãã ããããã°ãã¤ãèªã®æ¬ããã£ããªã¨ãããã¨ã§èª¿ã¹ã¦â¦
Generator ãæã«å ¥ããã®ã§ãåã³ããã³ã°ã®åé¡ã«ææ¦ããã Hamming numbers - Rosetta Code åãããã«å®è£ ããããã«ã¯ itertools ãå¿ è¦ã ã Python documentation ã« Python ã§æ¸ãããä»æ§ãè¼ã£ã¦ããã®ã§ãã®ã¾ã¾å®è£ ããã itertools â Functionsâ¦
ã³ã³ãã¤ã©ããã«æãã¦ããã£ãã def aMethodHasNamedArguments(Map named=[:], Object... args) { println "named=$named, args=$args" } aMethodHasNamedArguments("A", key1:1, "B", key2:2, "C") // named=[key1:1, key2:2], args=[A, B, C] aMethodHaâ¦
åæãã Generator ã java.util.concurrent ããã±ã¼ã¸ã使ã£ã¦æ¸ãã¦ã¿ãã Using BlockingQueue ã¯ããã« http://groovy.codehaus.org/Iterator+Tricks ã®ããã«éåæã®ãã®ã BlockingQueue ã§æ¸ãã¦ã¿ãã def generate(Closure generator) { return â¦
TiddlyWiki ã® Tips ã調ã¹ã¦ããããè¨å®ï¼ä½¿ç¨ãã¦ãããã©ã°ã©ã¤ã³ã¨ãï¼ãå ¬éããã¦ããæ¹ãããã®ã§èªåãå ¬éãã¦ã¿ãã ãTiddlyWikiã ãæ¤ç´¢ - ã¯ã¦ãªããã¯ãã¼ã¯ TiddlyWiki ã¨ã¯ éçºè 㯠Jeremy Ruston æ° HTML ãã¡ã¤ã«1ã¤ã§ã§ãã¦ãã Wiki â¦
ååã® Closure ãããã£ã¨ç°¡åã«ã§ããã ã¨ããã Python ã¨åãã ã£ãã Python ã¨åãæ¹æ³ org.codehaus.groovy.runtime.ScriptBytecodeAdapter ãã // TODO: set sender class public static Object invokeClosure(Object closure, Object[] argumentsâ¦
Python ã§ã¯ object.__call__ ãå®ç¾©ããã¨ãªãã¸ã§ã¯ããå¼ã³åºããããã ã 3.4.5. Emulating callable objects Scala ã§ã apply ã¡ã½ããã§åãããã«ãªãã¸ã§ã¯ããå¼ã³åºããã¨ãã§ããã Groovy ã§åãããã«ããã«ã¯ã©ãããã°ãããã ããããã®åâ¦
ã²ã¼ã ãã¯ããã使ã£ãã²ã¼ã ããã£ã¦ããã ãã¯ããã« 1 ãã 100 ã¾ã§ã®æ°åãæ¸ã缶ã«å ¥ãã¦ããã 缶ãæ¯ã£ã¦ãã10åã¨ãã ãã¦ä¸¦ã¹ãã 両æã®æã使ã£ã¦ãã¯ãããå ¥ãæ¿ããªããæ°åã®é ã«ä¸¦ã¹ãã ä¸å¿ç«¶äºãªãã ãã©ä¸æã«ãã£ãããã¦ããããâ¦
Bruce A. Tate æ°ã®ã7ã¤ã®è¨èª 7ã¤ã®ä¸çããèªãã§ããã æ¤ç´¢ãã¦ã¿ãã¨çµæ§èªã¾ãã¦ããããã ã ã404 Blog Not Found:ã³ã¼ãã«ã¤ãã¦æ¸ãæ¹ãã³ã¼ããæ¸ãããèªã¾ããç¾å®ã ãããã«ãããããã æ¸è©ã§ã¯ãªããèªãã§ã³ã¼ããæ¸ããã¦ããã¨ãããâ¦
æååç §åã®ã¢ã«ã´ãªãºã ã¯ç解ãã¦ãçµæ㯠java.lang.String#indexOf ã¨å¤ãããªãã ãã String#indexOf ã O(NM) ã§ããã®ã«å¯¾ã㦠O(N) ã§å¦çã§ãã*1ã Boyer-Moore algorithm (BMæ³) 㯠KMP æ³ã Z algorithm ã¨åãã O(N) ã ãå¹³åæ¯è¼åæ°ã¯åªâ¦
ç解ã§ããã¨æ¥½ãããã©é£ããã¦ç解ã§ããªããã¨ãå¤ãã ç解ã®ç¨®é¡ã§åé¡ããã¨æ¬¡ã®ããã«ãªãã æ¦è¦ãç解ãã¦ãã (API ã使ãã) ä»çµã¿ãç解ãã¦ãã (å®è£ ã§ãã) æ§ã ãªåé¡ã§ãããé©åã«ä½¿ãã å¤§æµ 1 ã¯ã¾ãä½ã¨ããªãããããããåãã£ã¦ãâ¦
WEB-DB PRESS Vol.66 ã«æååæ¤ç´¢ã®ã¢ã«ã´ãªãºã ãè¼ã£ã¦ããã®ã§ãæ¤ç´¢ãã¦ãããæ°ã¥ããã㨠ä»ã¾ã§ Boyer-Moore ã ã¨æã£ã¦ãããã®ã¯ Boyer-Moore-Horspool ã ã£ã KMP æ³ã®ããã°ã©ã ã¯ã·ã³ãã«ãªã®ã«èªããªã KMP æ³ã«ã¤ãã¦ã¯æ¥æ¬èªã§æ¸ãããããâ¦