BlockSorting ã Groovy ã§
ä»å¹´ãååãçµãããã¨ãã¦ããã1æã® TODO ã解決ããã
Suffix Array ã§ã¯ãªã BWT ã®æ¹ãã
Groovy ã§å®è£ ãã¦ã¿ã
åè
- http://homepage3.nifty.com/DO/blocksorting.htm
- BlockSorting - 西尾泰和のはてなダイアリー
- 続・BlockSorting(BWT) - 西尾泰和のはてなダイアリー
- BlockSorting を Squeak Smalltalk で - Smalltalkのtは小文字です
Ruby çããã®ã¾ã¾ Groovy ã¸
def encode(src) { int n = src.size() def srcsrc = src + src def vars = (0..<n).collect{ srcsrc[it..<it+n] } def code = vars.sort(true).collect{ it[-1] } return [code.join(), vars.indexOf(src)] } def decode(code, int index) { int n = code.size() def pairs = [code.toList(), 0..<n].transpose() // stable sort def sorted = pairs.sort{ a, b -> a[0] <=> b[0] ?: a[1] <=> b[1] } def result = [] n.times{ result << sorted[index][0] index = sorted[index][1] } return result.join() } assert encode("abracadabra") == ["rdarcaaaabb", 2] assert decode("rdarcaaaabb", 2) == "abracadabra"
BWT ã¨ã¯ï¼
Burrows-Wheeler Transform ã®ç¥ã§ãããã¯ã½ã¼ãã¨ãå¼ã°ãã¦ããã¿ããã
å§ç¸®åã«è¡ãå¤æå¦ç㧠BWT èªä½ã¯å§ç¸®ããªãããå§ç¸®ããããããã«ä¸¦ã¹æ¿ãã¦ãããã
å
ç¨å®è£
ãããã®ã使ã£ã¦ç¢ºèªãã¦ã¿ãã
assert encode("abcabc") == ["ccaabb", 0] assert encode("abccba") == ["bacacb", 1]
1ã¤ç®ã®ããã«ãã¿ã¼ã³ã«åããããªãã¿ã¼ã³ã表ããã¨å¤æå¾é£ç¶ããããã«ãªãã
2ã¤ç®ã®ãããªå ´åã¯ã°ãã°ãã®ã¾ã¾ã
ä¸æè°ãªãã¨ã«ãã®å¤æå¾ã®æååã¨æ°å¤ããå
ã®æååã¸æ»ããã¨ãã§ããã
ã©ãã㦠decode ã§ããã®ãï¼
Wikipedia ã®èª¬æãåãããããã®ãã£ã¡ãèªãã æ¹ããããã
ããã§ã¯ãä¾ã¨ãã¦ãããªãæ°ãããã "abcde" ãå¤æããæ§åãè¦ã¦ããã
å·¡åè¡åãã¤ããã
def matrix = [ "abcde", "eabcd", // 1è¡ç®ã rotate 1 "deabc", // 2è¡ç®ã rotate 1 "cdeab", // 3è¡ç®ã rotate 1 "bcdea" // 4è¡ç®ã rotate 1 ]
第1åã§ã½ã¼ãããã
第1åã§ã½ã¼ãããã¨ãæçµå㯠e,a,b,c,d ã§ããã
ããã encode ã®æ»ãå¤ã§ãã1ã¤ã®æ»ãå¤ã®æ°å¤ã¯å
ã®æååã®è¡ã¤ã³ããã¯ã¹ãè¿ãã¦ããã
assert matrix.sort{ it[0] } == [ "abcde", "bcdea", "cdeab", "deabc", "eabcd" ] assert encode("abcde") == ["eabcd", 0]
ä»ã®åã§ãã½ã¼ããã¦ã¿ãã
å·¡åãã¦ããã®ã§ã½ã¼ãããåã®1ã¤åã®å㯠e,a,b,c,d ã§ããã
// 第2åã§ã½ã¼ãããã¨ã第1å㯠e,a,b,c,d ã§ãã assert matrix.sort{ it[1] } == [ "eabcd", "abcde", "bcdea", "cdeab", "deabc", ] // 第3åã§ã½ã¼ãããã¨ã第2å㯠e,a,b,c,d ã§ãã // 第4åã§ã½ã¼ãããã¨ã第3å㯠e,a,b,c,d ã§ãã // 第5åã§ã½ã¼ãããã¨ã第4å㯠e,a,b,c,d ã§ãã
ãã®æ§è³ªã使ã£ã¦ãæçµåã®æååããå·¡åè¡åãã½ã¼ãããç¶æ
ãã¤ãããã¨ãã§ããã
// 1. 第1åã e,a,b,c,d ã«ãã第2åãã½ã¼ããããæååã«ãã matrix = [ "ea...", "ab...", "bc...", "cd...", "de...", ] // 2. 第1åã§ã½ã¼ããããæçµåã¯ãe,a,b,c,d ã«ãªãã¯ã matrix = [ "ab..e", "bc..a", "cd..b", "de..c", "ea..d", ] // 3. å ¨è¡ rotate 1 ããã° 1. ã«æ»ã
å·¡åè¡åãã½ã¼ãããç¶æ
ã®ä½çªç®ã«å
ã®æååããããã¯ããããªãã®ã§ã¤ã³ããã¯ã¹ã使ãã
ã½ã¼ãã1åã ãã«ãã
å ç¨ã®å·¥ç¨ããã®ã¾ã¾å®è£ ãã㨠n åã®ã½ã¼ããå¿ è¦ã«ãªã
def process1(input) { def n = input.size() def output = [[]] * n n.times { output = [input, output].transpose().sort{ it[0] }.collect{ h, t -> [h, *t] } } return output }
åãæååãã½ã¼ããã¦ããã®ã§ããã¹ã¦ã®ã½ã¼ãã¯åãå¤æã«ãªãã
å·¡åãã¦ããã®ã§ãã以éãæ¢ã«ã½ã¼ãããã¦ãããã¨ãéè¦ã§ããã
ãã®ããã½ã¼ãã¯å¸¸ã«å®å®ã½ã¼ãã«ãªãã
ã½ã¼ãã§è¡ãè¡ã®å
¥ãæ¿ãã transform ã«è¦ãã¦ããã°ã½ã¼ãã¯1åã§æ¸ãã
def process2(input) { def n = input.size() def output = [[]] * n def transform = [input, 0..<n].transpose().sort{ a, b -> a[0] <=> b[0] ?: a[1] <=> b[1] }.transpose()[1] n.times { output = [input, output].transpose() output = (0..<n).collect{ output[transform[it]] }.collect{ h, t -> [h, *t] } } return output }
æçµçãªè¡çªå·ãåãã£ã¦ããã°ããã®è¡ã ãå¤æããããã«ã§ããã
// trace ã¯å¯¾è±¡è¡ã ãã®å¦çãè¡ã def process3(input) { def n = input.size() def transform = [input, 0..<n].transpose().sort{ a, b -> a[0] <=> b[0] ?: a[1] <=> b[1] }.transpose()[1] def trace = { i -> def result = [] n.times{ i = transform[i] result << input[i] } return result } return (0..<n).collect{ trace(it) } } assert process1("rdarcaaaabb" as List) == process2("rdarcaaaabb" as List) assert process1("rdarcaaaabb" as List) == process3("rdarcaaaabb" as List)
decode æã«ã¯è¡çªå·ãåããã®ã§ãã®è¡ã ã追ããããã°ããã
ããã§æåã«å®è£
ããå¦çã®æå³ãåãã£ãã
è¡çªå·ã®ä»£ããã«çµç«¯æåã使ãå®è£
æååã®æå¾ã«çµç«¯ã示ãæåãå ãã¦ããã°ã復å
ããè¡åããæå¾ãçµç«¯æåã®æååãå
ã®æååã§ããã¨åããã
ãã ããçµç«¯ã示ãæåã¯å
ã®æååã«å«ã¾ãã¦ããªããã¨ã
è±èªçã® Wikipedia ã«è¼ã£ã¦ãããã®ã Groovy ã§å®è£ ãã¦ã¿ãã
SEP = '\0' def bwt(s) { assert !s.contains(SEP) s += SEP def table = (0..<s.size()).collect{ s[it..-1] + s[0..<it] }.sort(true) return table.collect{ it[-1] }.join() } def ibwt(r) { def table = [""] * r.size() r.size().times { table = (0..<r.size()).collect{ r[it] + table[it] }.sort() } return table.find{ it[-1] == SEP }.replaceFirst(~/.$/, "") } assert "cacao" == ibwt(bwt("cacao"))
åè
Reverse Polish notation calculator
ããããHaskellãã®ããå¦ã¼ã!ã ã® 10ç« ã®éãã¼ã©ã³ãè¨æ³é»åã Groovy, Scala, Clojure, Scheme ã§æ¸ãã¦ã¿ãã
Groovy
def solveRPN(expr) { expr.tokenize().inject([]){ acc, v -> "*" == v ? [acc[1] * acc[0], *acc.drop(2)] : "+" == v ? [acc[1] + acc[0], *acc.drop(2)] : "-" == v ? [acc[1] - acc[0], *acc.drop(2)] : [v as double, *acc] }[0] } assert solveRPN("10 4 3 + 2 * -") == -4.0 assert solveRPN("2 3.5 +") == 5.5 assert solveRPN("90 34 12 33 55 66 + * - +") == -3947.0 assert solveRPN("90 34 12 33 55 66 + * - + -") == 4037.0 assert solveRPN("90 3.8 -") == 86.2 assert solveRPN("") == null
0, 1 ã®é ãªã pop ã§ã対å¿ã§ãããã ãã1, 0 ã®é ã«åç
§ããªããã°ãªããªãã®ã§ drop ã¨çµã¿åãããã
æå³ã¯ãªãã空æåã渡ãããã null ãè¿ãããã«ãã¦ã¿ãã
é¢é£ããã¡ã½ããã®åä½ã
groovy:000> "".tokenize() ===> [] groovy:000> "".split() ===> [Ljava.lang.String;@83f700d groovy:000> [].head() ERROR java.util.NoSuchElementException: Cannot access first() element from an empty List at groovysh_evaluate.run (groovysh_evaluate:2) ... groovy:000> [][0] ===> null
Scala
val solveRPN: String => Double = _.split(' ').foldLeft(List.empty[Double]){ case (x::y::ys, "*") => (y * x)::ys case (x::y::ys, "+") => (y + x)::ys case (x::y::ys, "-") => (y - x)::ys case (xs, number) => number.toDouble::xs }.head assert( solveRPN("10 4 3 + 2 * -") == -4.0 ) assert( solveRPN("2 3.5 +") == 5.5 ) assert( solveRPN("90 34 12 33 55 66 + * - +") == -3947.0 ) assert( solveRPN("90 34 12 33 55 66 + * - + -") == 4037.0 ) assert( solveRPN("90 3.8 -") == 86.2 )
Scala ã¯ãã¿ã¼ã³ããããããã®ã§ Haskell ã¨å¤ãããªãã
14ç« ã« Maybe ã使ã£ãå®å
¨çãããã®ã§ Scala ãªããã£ã¡ãå®è£
ããã¹ãã ã£ããããããªãã
空æåã«ã対å¿ãã¦ããªãã
split ãæ²è
ã ã£ãã
scala> "".split(' ') res0: Array[String] = Array("") scala> "".split("\\s+") res1: Array[java.lang.String] = Array("") scala> """\s+""".r.split("") res2: Array[String] = Array("") scala> """\S+""".r.findAllIn("") res3: scala.util.matching.Regex.MatchIterator = empty iterator
Clojure
(defn solve-rpn [expr] (defn f [[x y & ys :as s] w] (cond (= "*" w) (cons (* y x) ys) (= "+" w) (cons (+ y x) ys) (= "-" w) (cons (- y x) ys) :else (cons (Double/parseDouble w) s))) (->> expr (re-seq #"\S+") (reduce f []) first)) (assert (= (solve-rpn "10 4 3 + 2 * -") -4.0) ) (assert (= (solve-rpn "2 3.5 +") 5.5) ) (assert (= (solve-rpn "90 34 12 33 55 66 + * - +") -3947.0) ) (assert (= (solve-rpn "90 34 12 33 55 66 + * - + -") 4037.0) ) (assert (= (solve-rpn "90 3.8 -") 86.2) ) (assert (= (solve-rpn "") nil) )
ãã¿ã¼ã³ãããã¯ãªããåé
æç¸ãããã®ã§ããã使ã£ãã
nil èæ§ãããã®ã§å¼æ°ã®æç¹ã§åé
ãã¦ããã
user=> (clojure.string/split "" #"\s+") [""] user=> (re-seq #"\S+" "") nil user=> (first nil) nil user=> (first []) nil
Scheme
(define (solve-rpn expr) (define (f v acc) (cond ((equal? "*" v) (cons (* (cadr acc) (car acc)) (cddr acc))) ((equal? "+" v) (cons (+ (cadr acc) (car acc)) (cddr acc))) ((equal? "-" v) (cons (- (cadr acc) (car acc)) (cddr acc))) (else (cons (string->number v) acc)))) (car (fold f '() (string-split expr #/\s+/)))) (solve-rpn "10 4 3 + 2 * -") ;=> -4 (solve-rpn "2 3.5 +") ;=> 5.5 (solve-rpn "90 34 12 33 55 66 + * - +") ;=> -3947 (solve-rpn "90 34 12 33 55 66 + * - + -") ;=> 4037 (solve-rpn "90 3.8 -") ;=> 86.2 (solve-rpn "") ;=> #f
ã¾ã ãã©ããªé¢æ°ãããã®ãããç¥ããªãã
ä»é¢¨ãª API Doc ã欲ããã
gosh> (string-split "" #/\s+/) ("") gosh> (string->number "") #f gosh> (car '()) *** ERROR: pair required, but got () gosh> (use srfi-1) #<undef> gosh> (reduce + 10 '(1 2 3)) 6 gosh> (reduce + 10 '()) 10
çµããã«
ç°¡åããã«æãããæ¸ãã¦ã¿ãã¨ããããæ°ã¥ããã¨ããã£ãã
è¨èªã«ãã£ã¦å¾®å¦ã«éãã®ã§æ³¨æãããã
2012-06-11 追è¨
Clojure çã® f ã¯ãã¼ã«ã«é¢æ°ã«ããã¤ããã ã£ããã°ãã¼ãã«ããåç
§ã§ãã¦ãã¾ã£ãã
defn ã§ã¯ãªã letfn ã使ã£ã¦ f ãå®ç¾©ããããã«ä¿®æ£ããã
(defn solve-rpn [expr] (letfn [(f [[x y & ys :as s] w] (cond (= "*" w) (cons (* y x) ys) (= "+" w) (cons (+ y x) ys) (= "-" w) (cons (- y x) ys) :else (cons (Double/parseDouble w) s)))] (->> expr (re-seq #"\S+") (reduce f []) first))) (assert (= (solve-rpn "10 4 3 + 2 * -") -4.0) ) (assert (= (solve-rpn "2 3.5 +") 5.5) ) (assert (= (solve-rpn "90 34 12 33 55 66 + * - +") -3947.0) ) (assert (= (solve-rpn "90 34 12 33 55 66 + * - + -") 4037.0) ) (assert (= (solve-rpn "90 3.8 -") 86.2) ) (assert (= (solve-rpn "") nil) )
å¦ç¿
é ã®ä¸ã®ç°è²ã®ç´°èã CPU ã HDD ã ã£ãã¨ããã
ç¥ã£ã¦ãããã¨ãå¢ããã®ã¯ HDD ã«æ¸ãè¾¼ãã ããã¨ãããã¨ã«ãããã
ããããããã°ã©ãã³ã°è½åãåä¸ãããã¨ã説æããã®ã¯é£ããã
ãªããªã CPU ã¯å¤ãã£ã¦ããªãã®ã ããã
èããããã®ã¯ HDD ã®ä¸ããä¼¼ã¦ããã³ã¼ããæ¤ç´¢ãããã¨ã ã
HDD ã«è²¯ãè¾¼ãã ã³ã¼ãã®éãå¢ããã»ã©ããã°ã©ãã³ã°ã§ããç¯å²ã¯åºããã
ããããã³ã¼ãã®éãå¢ããã»ã©ããã°ã©ãã³ã°é度ãé
ããªã£ã¦ãã¾ãããã ã
ããã¯è¦³æ¸¬çµæã¨ä¸è´ããªãã
ãããåºç¯å²ã®ç¥èãæã£ã¦ãã人ã®æ¹ãããã°ã©ãã³ã°ãéãæ°ãããã
CPU ã HDD ãåªç§ãªäººããããã¨ã¯ãããããèªåèªèº«ã§ãç¥èãåºãã£ãæ¹ãéããªã£ã¦ãã®ã§ãã¼ãçãªåé¡ã§ã¯ãªãããã ã
èªç¥å¿çå¦ã®ç¥æµãåãã
岡æ¬æµ©ä¸æ°ã® ãä¸éã®æ³åã ãèªãã ã¨ãããç¥è㯠ã宣è¨åç¥èã 㨠ãæç¶ãåç¥èã ã®2種é¡ã«åãããããããã
- 宣è¨åç¥èã¯ãåå¨ç㯠3.14 ã®ãããªä¸è¬çã« ãç¥èã ã¨å¼ã°ãããã®
- æç¶ãåç¥èã¯ãè¨èã§ã¯è¨ã表ããªã ãæç¶ãã ãå«ãã ãã®
æè½ã®ç¿å¾ã«ã¯ãã®ä¸¡æ¹ãå¿ è¦ã§ãããããå¹çããè¨æ¶ãæ¤ç´¢ãå©ç¨ã§ããããã«ãªããã¨ãä¸éãæå³ããã
ã§ã¯åå¿è
ã¨ä¸ç´è
ã®éãã¯ä½ãªã®ãï¼
ã¾ãè³ã«ã¯å¶ç´ããã£ã¦ãè³ã«åå¨ããã¯ã¼ãã³ã°ã¡ã¢ãªã¯7åãããã®å¡ã§åºãå
¥ãããªããã°ãªããªãã
ä¸ç´è
ã¯ç¥èãå¡ã«å¤æããæ¹æ³ã®ç¨®é¡ãè±å¯ã§ããã¤å¡ãå°ããã§ããã大ããã§ãããããã®ã§åå¿è
ããåºãå
¥ãããããã
åå¿è
ã¯ã¯ã¼ãã³ã°ã¡ã¢ãªã®ãã£ã«ã¿ã§ã¯ãããããã®ãããããåãæè½çµé¨ã§å¾ããããã®ãå¤ãã£ã¦ããã
ããã¾ã§ãæ¸ç±ã®2ç« ã«æ¸ããã¦ããå
容
ã©ããããéãã®ã ãããï¼
å¡ã®èªèã®éãã¯ãã«ã¹ãããæ°ã® ã決å®åãéããã ã«æ¸ããã¦ããã
人éãè¨ç®åã§ã³ã³ãã¥ã¼ã¿ã«å¯¾æã§ããã®ã¯ãæå³ã®ããåä½ã«ã¾ã¨ãã¦çµåãã®æ°ãæ¸ãããããã ããã ã
ãã¾ãå¡ãæ±ããã°ç·å½¢çãªéãã§ã¯ãªããªã¼ãã¼ã®éããå¾ãããã
ããããã§ã¹ã¯ä½æèªãããã§åæã決ã¾ãããã§ã¯ãªãããã ã
åãå±é¢ãè¦ã¦é»ãæå©ã¨ãã人ã¨ç½ãæå©ã¨ãã人ã«åãããã
è¨ç®åã¨å¤æåã¯å¥ã®è»¸ãããã
ãè¨ç®åã®åªå£ã§å¤æãã人ã決ããããã¨ã¯ãå®è¦ãæã£ã¦ããããé·ãã§æ±ºããããã¨ã¨ä¼¼ã¦ããã*1
ããã°ã©ãã³ã°èªä½ã¯å¤§æµçãã®ããåé¡ãæ±ã£ã¦ãã(å®è£
ãããæ©è½ãè¨ç®ãããå¤ããã)ã¯ãã
ããããã¨ãã¯ãå¡ãæ±ãè½åãéè¦ã¨ãªã£ã¦ããã
ã¦ãµã¤ã³ã»ãã«ãé¸æã¯å¹³åãã2åéãããã§ã¯ãªãã1çªéããããã°ã©ãã³ã°éãã¯å®éã©ãããããªã®ã ãããï¼
ããã¯é£ããåé¡ãããã
ããããã¢ã«ã´ãªãºã ã®ãªã¼ãã¼ã¨åãããã«èããã¨ãã¯ããã¾ãå¡ãæ±ãããã¨ããã¤ã³ãã«ãªãããã ã
å¡ãæ±ãåä½ãå¤ããã¨ããã§ãªã¼ãã¼ãå¤ããããããã§ã¯ãªãããæ±ãåä½ãå¤ããããªããã°ã°ãªã¼ãã¼ã¯å¤ãããªãã
ç¥èã®å¡ã®æ±ãæ¹
ãããç¥ãããã
ä¸ç´è
ããæãããã¨ãããã
ãããã¯ãã®2ã¤ã»ããã§èããã ã¨ã ããã£ã¡ããè¦ãæ¹æ³ãããã ã¿ããã«ã
ããã§ãªãå ´åã¯ãä¸ç´è
ã®åãå£ãã¿ã¦èªåã§èãããããªãã
ãå¡ãå°ããåãåãã¦ãããªã ã¨ãããã¨ã¯åãã£ã¦ããã©ããã¦ãã®åä½ãªã®ãã¯åãããªãã£ããããã
ãªã¼ãã¼ã®éããæç¶ãåç¥èã®å ´åãããã®ã§å¿
ãããèãã¦åããã¨ã¯éããªãã
ä¸ã®ä¸ã«ã¯æ¬éå£ã®ä½¿ãæã®ããã«ç¥èã®å¡ã ãã¾ããã¤ã¾ãã¬ç©ãæ¬ã£ã¦ãã¾ã£ãã ã¨ç°¡åã«æ±ãã人ãããã
ãã®ãããªäººã¯å¤§æµã®ãã¨ãé
延å¦ç¿æ³ã§éã«åããä¸æ¹ãæ¬éå£ãæã£ã¦ããªã人ã¯ã©ãããé åºã§å¦ã¶ã¹ããï¼
æã£ã¦ãã人ãããã©ãããã°ãªã¼ãã¼ãå¤ããã®ããä»ã®ãªã¼ãã¼ã§ååãªãã®ã¯ä½ãã¨ãããã¨ãæèãã¦é¸æããæ¹ãããã®ã ããã
è¦ç©ãããããã§ã¯ãªãã®ã§æèããããå
·ä½çãªæ¹æ³ãæãã¤ããªãã
ããªãé¢æ°ããã°ã©ãã³ã°ãå¦ã¶ã®ãï¼ã ã¨ãã質åã«å¯¾ããå人çãªçãã¯ããç¥ããªãåãå£ãããããã ã ã
ãã¡ããé¢æ°ããã°ã©ãã³ã°ä»¥å¤ã«ã«ãæ°ããåãå£ã¯åå¨ããã®ã§ãã£ã¡ãåªå
ããã¨ããé¸æãèããããã
å¿
ããã使ãããå¦ã¶ããã§ã¯ãªãããä»å¾æµè¡ãããã ããã§ããªãã
ãç¾å¨ç¥ã£ã¦ããè¨èªã§å®è£
ã§ãã¦ããã®ã«ãªãï¼ã ã¨èãã人ã¯ãç¾å¨ã®ãªã¼ãã¼ã§ä»å¾ãéã«åãã®ãèããå¿
è¦ãããã¯ãã ã
ä»ã¯ããããã Haskell ãã®ããå¦ã¼ã!ã ãèªãã§ããã
æ¬ã«ãªã£ã¦ããã®ã ãã宣è¨åç¥èã¨ãã¦æ¸ããã¦ããã
ããããæè¡ã¨ãã¦ä¸¡è¼ªã¨ãªãæç¶ãåç¥èãç§ã¯ã¾ã å¾ããã¦ããªãã
å¾ããã¦ããªãè¨ã訳ãèãã¦ãããããªãã¨ã«ãªã£ã¦ãã¾ã£ãã
ãåãã¦ã®äººã®ããã® LISPã ãèªãã ã¨ããå帰ã§èãããã¨ã«è¦å´ããã
ãã®ã¨ãã¯ãããåèã«ããªããèªãã§ãã£ã¦ä½ã¨ã14ç« ã¾ã§èªãã ã
ãã®çµé¨ãããã®ã§ãä»åãæçµçã«ç解ã§ããã ãããããã®æè¦ã§èªãã§ããã
ã¨ãããããæç¶ãåç¥èãå¾ãããããã«è¨ç·´ããªããã°ãªããªãã
追è¨
ãæ°å¦ã¬ã¼ã« ã¬ãã¢çè«ããèªã¿å§ããã
ããªãã»ã©ï¼ç¢ºãã«å¯¾ç§°å¼ãä¿æ°ã§è¡¨ãã¦ãã¾ããããã©ã¡ããã¯å¼ã確èªãã¦è¨ã£ããã対称å¼ã¯ãã¤ã§ããã®ããã«ä¿æ°ã§è¡¨ãããã§ããâ¦â¦ã¨ããã§ãããããå¤å½¢ã£ã¦ããªãã»ã©ï¼ã£ã¦æããã§ãããèªåã§ã¯æãã¤ãããã«ããã¾ãããã©ããããã§ããããã«ãªããã§ãããã
ãç·´ç¿ãã¨ãã«ã«ãããå³çããã
ãããã§ããâ¦â¦ãã¨ããã©ã¡ãããè¨ã£ãã
ããã©ããã¯ã©ããã風ã«ç·´ç¿ãããã°ããããèãã¦ãããããªæ°ãããã®ã ãâ¦
ããããããã©ããã¨ããã°ç·å½ããªã®ã ãã表ãä½ã£ã¦ããã°ããã¨æã£ãã
ãã«ã«ããã使ã£ããã¨ããããã¯ããã¯ãä¸è¦§è¡¨ã«ãã¦ããã¦æ¯åæ¤ç´¢ã
ç¥èã®å¡ãå¤æ¬¡å
ãã¼ãã«ã§ã¢ããªã³ã°ãã¦ããã°ããã ããªã®ãï¼
æªç¥ã®åã追å ãããå ´åã¯ä»æ¹ããªããã追å ãããã¨ãã«ä»ã®è»¸ã¨ã®äº¤ç¹ãã©ããªãã®ããåããã
ããããã°ããªãé¢æ°ããã°ã©ãã³ã°ã¯éè¦ããã§ãâæ°ãããã¼ã¿åãå®ç¾©ããã¨ãã«ãã®åãå¦çããé«éé¢æ°ãæ¸ãã¹ãã§ããâã¨æ¸ããã¦ããã
2012-06-04 追è¨
çºæ³æ³ã¨ã
- TRIZ――10分以内に「それ、どうやって実現するか」を思いつく方法 (1/3) - ITmedia エンタープライズ
- 体系的な知識・技術を身につけるための学習法について - Kentaro Kuribayashi's blog
ã³ã¼ãã£ã³ã°ã«ç½®ãæãããã©ããªãã®ã ããï¼
ããã°ã©ã ç 20Q ã欲ããã
ãã¼ã¿ã¯ããããã§ããï¼ãã¼ã¿ã«ã©ã³ãã ã¢ã¯ã»ã¹ã§ãã¾ããï¼ã¨ãçãã¦ããã¨ããã°ã©ã ãè¿ã£ã¦ããã
ããèããã¨ã¿ã°ãéè¦ã§ãåå¼·ã®è³ªã¨éã®è³ªã¯ãã®ããã®ã¿ã°ã足ãã¦ãããã©ããã ã¨æã£ãã
åæ°ã ãåå¼·ãããæ¤ç´¢ã®ãã¨èãã¦ã¿ã°ä»ããªããã ãã ããã¿ã°ãä»ãã¦ãã¦ãéããªããã ãã ããã
ã§ãéåæãªãã
æç¶ãåç¥èãå¾ãããªãã®ã¯ã宣è¨åç¥èã«ååãªã¿ã°ãä»ãã¦ãªãã®ã§ãä»ã®ç¥èã¨ã®é£åã§ããªãç¶æ
ãªãã ã¨æãã
ãã¡ã³ã¯ã¿ã¼ããã©ãã¿ã°ä»ããããããã®ãããåãããªããããã©ã使ãã®ãåãããªãã
ã¿ã°ä»ãã§ããã°ä»ã¾ã§åãã¿ã°ã使ã£ã¦ããç®æããã¡ã³ã¯ã¿ã¼ã§ç½®ãæãããã¨ãã§ããã
ãã ãåãããªãçç±ãåãã£ã¦ãåãã£ããã¨ã«ã¯ãªããªãã
*1:å½ç¶è¨ç®åã§è§£æ±ºããåé¡ã¯éã
Learn you a Clojure for Great Groovy!
æè¿è©±é¡ã®ã¿ã¤ãã«ã¯ããã®ããèªãã§ããéä¸ï¼9ç« ã«å
¥ã£ã)ã
ãã®è©±ã§ã¯ãªãããã®ã¨ã³ããªã¯ Clojure 㧠Ninety-Nine Prolog Problems ããã£ã¦ããã¨ãã«æãã¤ãããã®ã
Ninety-Nine Prolog Problems ã Lists ã®ã¨ããã ããç¾å¨ Groovy, Haskell, Scala, Prolog, Clojure ã§è§£ããã*1
Lists ã®ååã®ã¯ã©ã¤ããã¯ã¹ã¯ encode-direct 辺ãã ã Groovy ã«è¼ã¹ã¦ Clojure ã¯ç°¡æ½ã«æ¸ãã¦ãã¾ãã
;; 1.13 (defn encode-direct [s] (for [[n c] (map (juxt count first) (partition-by identity s))] (if (= 1 n) c [n c]) )) (assert (= [[4 \a] \b [2 \c] [2 \a] \d [4 \e]] (encode-direct "aaaabccaadeeee") ))
ãã㯠Haskell ã® group é¢æ°ã«ããããã®ã Clojure ã«åå¨ããããã ã
Prelude> :m + Data.List Prelude Data.List> group "aaaabccaadeeee" ["aaaa","b","cc","aa","d","eeee"]
ã¤ã¾ã 1.09 ã® pack ã Clojure ã§ã¯
- åèï¼partition-by - clojure.core | ClojureDocs - Community-Powered Clojure Documentation and Examples
;; 1.09 (defn pack [s] (partition-by identity s)) (assert (= [[\a \a \a \a] [\b] [\c \c] [\a \a] [\d] [\e \e \e \e]] (pack "aaaabccaadeeee") ))
ã§ãGroovy ã§ã¯ *2
// 1.09 def pack(list) { if (!list) return [] list = list.reverse() list.tail().inject([[list.head()]]){ acc, v -> acc.head()[0] == v ? [[v,*acc.head()],*acc.tail()] : [[v],*acc] } } assert ["aaaa","b","cc","aa","d","eeee"] == pack("aaaabccaadeeee".toList())*.join()
Groovy ã«ã Collection#split ã¨ããåãã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ã¡ã½ãããåå¨ãããæ¯ãèããéãã
Groovy ã® split ã¯ãå¼æ°ã®ã¯ãã¼ã¸ã£ã§ true 㨠false ã«åé¡ãã¦ããã®ã«å¯¾ã
Clojure ã® partition-by ã¯ãå¼æ°ã®ã¯ãã¼ã¸ã£ã§å¤æããçµæã1ã¤åã®ã°ã«ã¼ãã¨åããã©ããã§åé¡ãã¦ããã
ããã¯ä¾¿å©ã ããã¤ããªã partition-by ãå®è£ ããã¨ããã ã Clojure ã¯ãªã¼ãã³ãªã®ã§è²¸ãã¦ããããã¨ã«ããã*3
@Grab(group='org.clojure', module='clojure', version='1.4.0') @Grab(group='org.apache.commons', module='commons-lang3', version='3.1') import clojure.lang.Compiler import clojure.lang.Symbol import clojure.lang.RT import static org.apache.commons.lang3.StringUtils.removeEnd import static org.apache.commons.lang3.StringUtils.splitByCharacterTypeCamelCase def methodMissing(String name, args) { def names = splitByCharacterTypeCamelCase(name)*.toLowerCase() if (names[0] == "is") { names = names.tail() names[-1] = names[-1] + "?" } return Compiler.eval(Symbol.create(names.join("-"))).invoke(*args) } def propertyMissing(String name) { // Why? // Caused by: java.lang.RuntimeException: Unable to resolve symbol: out in this context if (name == "out") return System.out return Compiler.eval(Symbol.create(name)) } def pack(s) { partitionBy(identity, s) } def encode1(s) { map(juxt(count, first), pack(s)) } def encode2(list) { pack(list).collect{ [it.size(),it.head()] } } assert ["aaaa", "b", "cc", "aa", "d", "eeee"] == pack("aaaabccaadeeee")*.join() assert [[4,'a'], [1,'b'], [2,'c'], [2,'a'], [1,'d'], [4,'e']] == encode1("aaaabccaadeeee") assert [[4,'a'], [1,'b'], [2,'c'], [2,'a'], [1,'d'], [4,'e']] == encode2("aaaabccaadeeee") assert isZero(0) // Why? // groovy.lang.MissingPropertyException: No such property: lang for class: clojure // assert 'a' == clojure.lang.RT.first("abc") assert 'a' == RT.first("abc")
encode1 㯠Groovy ã§ã encode2 ã®ããã«æ¸ããã®ã§ã¡ãªãããããããã§ã¯ãªããä»ã®é¢æ°ãåãããã¾ããã¨ãããã¨ã§æ¸ãã¦ã¿ãã
propertyMissing ã®æ¯ãèããããåãã£ã¦ããªãã®ã§ Why? ã2ç®æçºçãã¦ããã
clojure.lang.RT ã®ã¡ã½ãããªãç´æ¥å¼ã³åºããã¨ãå¯è½ãªããã ã
Symbol ãæ¯åçæã㦠eval ãã¦ãããããã¯ãã£ãã·ã¥ã«ä¿æãã¦ããããããããªãã
æ¹åç¹ã¯ããã¨æãã Clojure ã®é¢æ°ã¯ Groovy ããç°¡åã«å¼ã³åºããããã¨ãããã¨ãè¨ãããã£ãã
é¢æ°åãã¼ãµã¼
ãããã Haskell ã®æ¬ãåºçãããã®ã§å¾©ç¿ããã
ãããã°ã©ãã³ã° Haskellã ã®ç¬¬8ç« ãä»å㯠Scala(version 2.9.2) ã§æ¸ãã
Scala çã«ä½¿ã£ãæ¹ããããããã®ã§ Option ã Either ãåå¼·ããã
Scala ã® API ã¨ä»¥ä¸ãåèã«ããªããæ¸ãã¦ã¿ãã
- Java で Either モナド - xuwei-k's blog
- Modegramming Style: Scala Tips / Option - Index
- Modegramming Style: Scala Tips / Either - Index
ã¾ãã¯ãã¿ã¼ã³ãããã§
ã»ã¨ãã©å¤ãããªãã¯ãã ããæ¸ç±ããã Code ã® Parsing.lhs 㨠parser.lhs ã®æ¹ãåèã«ããã
object Parsers { type P[A] = Seq[Char] => Option[(A,Seq[Char])] implicit def parserWrapper[A](p: P[A]) = new { def >>=[B](f: A => P[B]): P[B] = inp => parse(p, inp) match { case None => None case Some((v,out)) => parse(f(v), out) } def +++(q: P[A]): P[A] = inp => parse(p, inp) match { case None => parse(q, inp) case x => x } } def parse[A](p: P[A], inp: Seq[Char]): Option[(A,Seq[Char])] = p(inp) def unit [A](v: A): P[A] = inp => Some((v,inp)) def failure[A] : P[A] = inp => None def item : P[Char] = inp => inp match { case Seq() => None case Seq(v,out@_*) => Some((v,out)) } def many [A](p: P[A]): P[Seq[A]] = many1(p) +++ unit(Seq.empty) def many1[A](p: P[A]): P[Seq[A]] = p >>= (v => many(p) >>= (vs => unit(v+:vs))) def token[A](p: P[A]): P[A] = space >>= (_ => p >>= (v => space >>= (_ => unit(v)))) val sat: (Char => Boolean) => P[Char] = p => item >>= (x => if (p(x)) unit(x) else failure) val digit = sat(_.isDigit) val lower = sat(_.isLower) val upper = sat(_.isUpper) val alpha = sat(_.isLetter) val alphanum = sat(_.isLetterOrDigit) val char: Char => P[Char] = x => sat(_ == x) val string: String => P[String] = { case "" => unit("") case x => char(x.head) >>= (_ => string(x.tail) >>= (_ => unit(x))) } val ident = lower >>= (x => many(alphanum) >>= (xs => unit(x+:xs))) val nat = many1(digit) >>= (xs => unit(xs.mkString.toInt)) val int = (char('-') >>= (_ => nat >>= (n => unit(-n)))) +++ nat val space = many(sat(_.isWhitespace)) >>= (_ => unit()) val identifier = token(ident) val natural = token(nat) val integer = token(int) val symbol: (String => P[String]) = xs => token(string(xs)) } import Parsers._ lazy val expr: P[Int] = term >>= (t => (symbol("+") >>= (_ => expr >>= (e => unit(t+e))) ) +++ unit(t)) lazy val term: P[Int] = fact >>= (f => (symbol("*") >>= (_ => term >>= (t => unit(f*t))) ) +++ unit(f)) lazy val fact: P[Int] = (symbol("(") >>= (_ => expr >>= (e => symbol(")") >>= (_ => unit(e)))) ) +++ natural val eval = (xs: String) => parse(expr, xs.toSeq) match { case Some((n, Seq())) => n case Some((_, out)) => sys.error("unused input " + out.mkString) case None => sys.error("invalid input") } assert( eval("2*3+4") == 10 ) assert( eval("2*(3+4)") == 14 ) assert( eval("2 * (3 + 4)") == 14 )
Option ã®ã¡ã½ããã使ã
ãã¿ã¼ã³ãããã¯ä¸è¦§æ§ã«ããããã®ã ããã©ã Option ã§ãã¿ã¼ã³ãããããå ´åã«æ±ºã¾ã£ãå½¢ãç¾ããã
ãã®é¨åã® None => None ã¯ä½åº¦ãæ¸ãã¦ããã¨é£½ãã¦ãã...å¤å
def >>=[B](f: A => P[B]): P[B] = inp => parse(p, inp) match { case None => None case Some((v,out)) => parse(f(v), out) }
ã¨ããããã§çç¥ãã¦ãã¾ãã
def >>=[B](f: A => P[B]): P[B] = inp => parse(p, inp).flatMap{ case (v,out) => parse(f(v), out) }
Some ãæ¸ããªã代ããã« flatMap ã§ã¤ãªããã ãã
ããä¸ã¤ã®æ¹ã x => x 㯠Some(y) => Some(y) ãªã®ã§ä½ãã¡ã½ãããããããã
def +++(q: P[A]): P[A] = inp => parse(p, inp) match { case None => parse(q, inp) case x => x }
ããããOption ã® API ãæ¢ãã¦ã¿ããããã¨æãããã®ããªãã£ãã
def +++(q: P[A]) : P[A] =
inp => parse(p, inp).toLeft(parse[A](q, inp)).fold(Option(_), identity)
toLeft ã§ä¸æ¦ Either ã«å¤æãã¦å度 fold 㧠Option ã«æ»ãã¦ããã
ãããã None => None ã®å ´å㯠flatMap ã§æ¸ãã®ã§ã¡ã½ããã«ããã°ãããã
ãã以å¤ã®å ´åã¯æåãã Either ã使ãã®ã ããã
Either ã®ã¡ã½ããã使ã
ãã¼ãµã¼ã®æ»ãå¤ã Either åã«å¤æ´ããã
ã¾ãã¯ãã¿ã¼ã³ãããã§
type P[A] = Seq[Char] => Either[Unit,(A,Seq[Char])] implicit def parserWrapper[A](p: P[A]) = new { def >>=[B](f: A => P[B]): P[B] = inp => parse(p, inp) match { case Left(_) => Left() case Right((v,out)) => parse(f(v), out) } def +++(q: P[A]): P[A] = inp => parse(p, inp) match { case Left(_) => parse(q, inp) case x => x }
None ã Left ã«ãSome ã Right ã«å¤ãã£ãã ã
ããã Either ã®ã¡ã½ããã使ãããã«å¤æ´ãã¦ã¿ãã
implicit def parserWrapper[A](p: P[A]) = new { def >>=[B](f: A => P[B]): P[B] = inp => parse(p, inp).right flatMap{ case (v,out) => parse(f(v), out) } def +++ (q: P[A]) : P[A] = inp => parse(p, inp).left flatMap{ case _ => parse(q, inp) } }
両æ¹ã¨ã flatMap ã«ãªãã®ã§èªã¿ãããã
.right ã .left 㯠ãRight ã ã£ãããããLeft ã ã£ãããã¨èªããã
ãã¼ãµã¼ãçæãã¦ããé¨åãå¤æ´ããªãã¦ã¯ãªããªãã
ãããç´ ç´ã« None ã Left ã« Some ã Right ã«æ¸ãæããã ãã
def unit [A](v: A): P[A] = inp => Right((v,inp)) def failure[A] : P[A] = inp => Left() def item : P[Char] = inp => inp match { case Seq() => Left() case Seq(v,out@_*) => Right((v,out)) }
item 㯠Seq ã§ãã¿ã¼ã³ããããã¦ãããããããã¿ã¼ã³ãããã§ãªãããã¨ãã§ããã
def item : P[Char] = inp => if (inp.isEmpty) Left() else Right((inp.head,inp.tail))
ããã« Either ã®ã¡ã½ããã使ã£ã¦
def item : P[Char] = inp => Either.cond(!inp.isEmpty, (inp.head,inp.tail), ())
å·¦ã Right ã§å³ã Left ãªã®ã§å°ããããããã
for å¼ã使ã
調ã¹ã¦ãããã第8ç« ã Scala ã§å®è£ ããã¦ããæ¹ãããã
- http://www.ayutaya.com/dev/scala/haskell-parser-generator
- http://svc.ayutaya.com/wordpress/2011/04/22/scala-haskell-parser-generato/
ãã¼ãµã¼ã« map 㨠flatMap ãå®è£
ããã¦ããã° for å¼ã使ãããããã
object Parsers { type P[A] = Seq[Char] => Either[Unit,(A,Seq[Char])] implicit def parserWrapper[A](p: P[A]) = new { def flatMap[B](f: A => P[B]): P[B] = inp => parse(p, inp).right flatMap{ case (v,out) => parse(f(v), out) } def map [B](f: A => B) : P[B] = inp => parse(p, inp).right flatMap{ case (v,out) => Right((f(v),out)) } def +++ (q: P[A]) : P[A] = inp => parse(p, inp).left flatMap{ case _ => parse(q, inp) } } def parse[A](p: P[A], inp: Seq[Char]) = p(inp) def unit [A](v: A): P[A] = inp => Right((v,inp)) def failure[A] : P[A] = inp => Left() def item : P[Char] = inp => Either.cond(!inp.isEmpty, (inp.head,inp.tail), ()) def many [A](p: P[A]): P[Seq[A]] = many1(p) +++ unit(Seq.empty) def many1[A](p: P[A]): P[Seq[A]] = for (v <- p; vs <- many(p)) yield v+:vs def token[A](p: P[A]): P[A] = for (_ <- space; v <- p;_ <- space) yield v val sat: (Char => Boolean) => P[Char] = p => for (x <- item; y <- if (p(x)) unit(x) else failure) yield(y) val digit = sat(_.isDigit) val lower = sat(_.isLower) val upper = sat(_.isUpper) val alpha = sat(_.isLetter) val alphanum = sat(_.isLetterOrDigit) val char: Char => P[Char] = x => sat(_ == x) val string: String => P[String] = { case "" => unit("") case x => for (_ <- char(x.head);_ <- string(x.tail)) yield x } val ident = for (x <- lower; xs <- many(alphanum)) yield x+:xs val nat = for (xs <- many1(digit)) yield xs.mkString.toInt val int = (for (_ <- char('-'); n <- nat) yield -n) +++ nat val space = for (_ <- many(sat(_.isWhitespace))) yield () val identifier = token(ident) val natural = token(nat) val integer = token(int) val symbol: (String => P[String]) = xs => token(string(xs)) } import Parsers._ lazy val expr: P[Int] = for { t <- term r <- (for { _ <- symbol("+"); e <- expr } yield t+e) +++ unit(t) } yield r lazy val term: P[Int] = for { f <- fact r <- (for { _ <- symbol("*"); t <- term } yield f*t) +++ unit(f) } yield r lazy val fact: P[Int] = (for { _ <- symbol("(") e <- expr _ <- symbol(")") } yield e) +++ natural val eval = (xs: String) => parse(expr, xs.toSeq) match { case Right((n, Seq())) => n case Right((_, out)) => sys.error("unused input " + out.mkString) case Left(_) => sys.error("invalid input") } assert( eval ("2*3+4") == 10 ) assert( eval ("2*(3+4)") == 14 ) assert( eval ("2 * (3 + 4)") == 14 )
flatMap ã ãã§ããããã«æãã map ããªãã¨ã¨ã©ã¼ã«ãªãã
eval ã§ã¡ã½ãã使ã£ã¦ãªããã¨ã«æ°ã¥ããããããã¯ãã¿ã¼ã³ãããã®æ¹ãè¦ãããã®ã§ãã®ã¾ã¾ã«ãã¦ããã
ããã¯ãã¼ã¯ã®æ´ç
ããã¯ãã¼ã¯ãç¡éãªã¹ãã®ãããªãã®ãªã®ã§ head ãã¤ããã ã¾ã¾ç¶ãã¦ãã㨠Out of Memory ã«ãªãã
ãªã®ã§ãæ°å転æã«æ´çãã¦ã¿ãã
æ´çã®æ¹æ³
å¤ãæ¹ããé ã«å¤æããã
æåããèãã¦ããããã§ã¯ãªãããçµæçã«4ã¤ã«å¥ããã
- ã«ãã´ã©ã¤ãºã㦠Wiki ã«æ¸ãè¾¼ãã ãã®
- åã«ããã¯ãã¼ã¯ãå¤ãããã®
- ãã®ã¾ã¾ããã¯ãã¼ã¯ãã¦ããã¦ãã¼ã¿ã¨ãã¦æ±ããã®
- å¤æã§ããªãã®ã§å度ããã¯ãã¼ã¯ãã¦æ¥ä»ãæ´æ°ãã
ã«ãã´ã©ã¤ãºãã
ã«ãã´ã©ã¤ãºã®åºæºã¯ããããã
å
容ã¾ã§ææ¡ã§ãã¦è©³ç´°ã«åé¡ã§ãããã®ããå
容ã¯ããããªãã大éæã«ãã®è¾ºãããªã¨ãããã®ãããã
ããã§ç²åº¦ãç´°ããæ°è»½ã«èªããããªãã®ã¯ TODO ãªã¹ãã«ããã
ç²åº¦ã大ãããã®ãã¾ã é£è§£ãªãã®ã¯ã«ãã´ã©ã¤ãºããã¾ã¾ã§çµãã£ã¦ããã
ä»å¾ã©ãå¦çãããèããªããã°ãªããªãã
ããç¨åº¦ã®æéãããã¨æ
å ±ãéè¤ãã¾ã¨ãããããã¨ããã£ãã
ä¸è¦ã«ãªããã®
ã©ã¤ãã©ãªããã¼ã«é¢é£ãå¤ãããã
æ°ãããã®ãã§ã¦ããã©ã¤ãã©ãªãéã«ä¸»æµã«ãªã£ãã©ã¤ãã©ãªã®æ
å ±ã¯ä¸è¦ã«ãªãã
主æµã«ãªã£ãã©ã¤ãã©ãªããã¼ã«ã¯å¿
è¦ãªã¨ãã«æ¤ç´¢ããã°æ°ããæ
å ±ãã¿ã¤ããã®ã§ããã¯ãã¼ã¯ã¯å¿
è¦ãªãã
ã¯ã¦ãªãã¿ã°ã¨æ¬æã§ç°¡åã«æ¤ç´¢ã§ããããã«ãªã£ãã®ã§æ¶ãã¹ããã¯å®éã«æ¤ç´¢ãã¦ã¿ã¦ç¢ºèªã§ããã
æ¤ç´¢ã§ãã¦ãæªæ¥ã®èªåããã£ã¨åãããã«æ¤ç´¢ããã¨æãããåé¤ããã
ãªã³ã¯åã
ããã°ã£ããã¯ä»æ¹ããªãã®ã ãä¸çªæ²ãããã¿ã¼ã³ã ã
ä¸éæ§ã®ãã®ãªãåãããªãã§ããªãã®ã ãããªããªããªã£ãã®ãåãããªããã®ãããã
ç¡å¸¸ãæããã
ãã¼ã¿ã¨ãã¦æ±ã
æ
å ±éãå¤ããããã®ãããã«ãããã
ãã¤ã§ã調ã¹ãããã®ã§ã¯ããã¦ãããã®ã ã調ã¹ãã¨å¤§éã« Hit ããã®ã§ãã£ã«ã¿ãããã£ããã®ã¨ãã¦æ®ãã¦ããã
ä¾ãã°ã¬ã·ãã®ãããªãã®ã
å éããã
ã¾ã ç解ä¸è¶³ãªã®ã§å¿
è¦ãã©ããã®å¤æãå
éãããã
人ã¯ç¿æ§ã¨ãã¦é¸æè¢ããªããªããã¨ãé¿ãããããã®ã§å¿
è¦ãã©ãã以å¤ã®é¸æè¢ããã£ãæ¹ãå¿
è¦ãªãã®ã«çµããã
è¿·ã£ããå¤æã1å¹´å
延ã°ãã«ããã°ããã ããªã®ã§ã
ä»å¾
æ´çãã¦ã¿ã¦ä¸è¦ã«ãªããã¿ã¼ã³ã¨ããããæããããã
ãããæåããããã¯ãã¼ã¯å¯¾è±¡ããå¤ãããã«ãã¦ããã®å観測ç¯å²ãåºããã¦ã¿ãã
ãããã¡ã¯1å¹´ãããã«ãããã¨æãã
2012-05-18 追è¨
Garry Kasparov æ°ã® ã決å®åãéããã ããããã¤ãå¼ç¨ã
ããã¯ãã¼ã¯æ´çããªããèªã¿å§ããã®ã ãèªã¿çµããã
ç§ãã¡ã¯ææ決å®ã®ããã»ã¹ãæèããªããã°ãªããªããããã®ããã»ã¹ã®å®è·µãéãã¦ç´æâç¡æèã®åããåä¸ãã¦ãã
...
æªããã¿ã¼ã³ãæ£ãããããã¿ã¼ã³ãããã«æ¹åããã«ã¯ãç©æ¥µçã«èªåããã£ã¨ç¥ããã¨ããªããã°ãªããªã
èªã¿ãå°ãã«ã¯ãåµé æ§ã¨ç§©åºãã¨ãã«è¡ãããã£ãç¶æ ã§ãªããã°ãªããªãããã ã
ãã¤æ £ç¿ãç ´ãå¿ è¦ããããã¯ãç¶æ³ã¨æ¬è½ãæãã¦ããã
調åãã§ãªãã¨ãã¯æ´çããããã«ããã
èªåãè¦ããå±éã«ã¤ãã¦å¤¢æ³ãã¦ã¿ãã¨ããããç¾å®ã«èµ·ããããã¨æ°ã¥ããã¨ãããã
ãããªã¢ã«ã«ã¯ããã®æç¨æ§ã«å¿ãã価å¤ãããªã
è¡åããããã®æéãéè¦ã¨ãªãã®ã¯ãæéãã¤ãã£ã¦ãããªã¢ã«ãããæå¹ã«ã§ããå ´åã«éããã
ä¸æ¥ã«ãã¨ä¸æé追å ãããããããã¦ãã®äººã¯æè¿ããã ããããååæã®ç¬æ¿ã®å人ã¯åã°ãªã
æå¹æ´»ç¨ã§ãããã®ãå¿
è¦ã¨ããªããã°ãªããªãã
å¯è½ãªæ段ãæ¢ããã¨ã¨ãç¶æ³ãè©ä¾¡ãããã¨ã«ã¯å¤§ããªéãããã
ä½æãå
ã¾ã§èªãã®ã¯è©ä¾¡ããããã§ãã£ã¦ãä½æå
ã¾ã§èªããã§è©ä¾¡ãã¦ã¯ãããªãã
èªããææ°ã¯ä¸æµã¨ããã§ãªããã¬ã¤ã¤ã¼ã§ãã¾ãå·®ã¯ãªããããã
è©ä¾¡ãå³ã¨å·¦ã«åããã¦ããã¿ããã ã
誤ã£ã決æã®å¤ãã¯ãã¨ã«ããææ決å®ã®ããã»ã¹ãçµãããããã決æãè¿«ãéå§ããéãããã¨ããé¡æã«ç«¯ãçºãã¦ãã
ããã¯ææªã¿ã¤ãã®æ§æ¥ããã¿ãããæãéã¡ã ããªãã¨ãã¦ãé¿ããªããã°ãªããªãã
決æããªããã°ãããªããã決æããã§ã¯çç±ã«ãªããªãã
ãã¤ã¦ç§ãæ»æããã®ã¯ãããããç¥ããªãããã ã£ã
ãã¾ç§ãæ»æããã®ã¯ãããããã£ã¨ãå¹æçã ã¨ç¥ã£ã¦ããããã
çµæã¯åãã§ãããã»ã¹ãéãã
ã¿ã«ã¿ã³ã¯èªé²
ãã§ã¹ã®å¯¾å±ã¯ä¸ã¤ã®æ®µéã«åããã¦ãã
第ä¸ã¯èªåãæå©ã ã¨é¡ã段éã第äºã¯æå©ã ã¨ä¿¡ãã段éã第ä¸ã¯è² ããã¨ãããã£ã段éã
ä¸çªç®ã¨äºçªç®ãéãªãã¾ã ãããã©ã
ãã¬ãã·ã£ã¼ã«ããããã¦ããã¨ãã«å¤å°ã®ä¸å®ãæããã®ã¯ãããã£ã¦èªç¶ãªãã¨ã ã
æ°ããªãã£ã¬ã³ã¸ã«å¯¾ãã¦ã®ããã«ãã¾ããããã«ãªã£ãã¨ããããå¿é ããæ¹ããããããããªã
ãªã«ãããç°¡åããã«æããã¨ããããèªåãååã«è¿½ãè¾¼ãã§ããªãããããã¯ãã£ã¬ã³ã¸ãä¸è¶³ãã¦ãã
èªä¿¡ãã¤ãããã¨ã¨èª¤ããè¨æ£ããããã¨ã®é©åãªãã©ã³ã¹ã¯ãåå人ãè¦ã¤ããªããã°ãªããªã
çµé¨ãããã£ã¦ãâææ ¢ã§ãããã¡ã¯è² ããâ ã¯åªããååã
é 調ãããã¨è½ã£ãã¡ããããã
ç§ãã¡ã¯å°éåéã§ãè ãä¸ãããã¨ã«éç¹ãç½®ãããã¦ãã
ãã®ãããèªåã®å°éã伸ã°ãä¸çªã®è¿éããã»ãã®åéã«å¼·ããªããã¨ã«ãã£ã¦ãæ°ãã¤ããªã
è¦æãå
æããã®ãä¸éããè¿éã®ãããªãã¨ãæ¸ããã¦ããã
ä¸åã®å±æ©ãé¿ãããã¨ããã®ã¯ãããã£ã¦å±éºã§ããå ´åãå¤ãã
ããã¯å¾ã ã«ãã¦å±æ©ãå éããããã¨ã«ãããªããªã
é£æãå¾æåéã«ãã£ã¦ããã¨ãããããã
Programming Grails
O'Reilly ã§ã¯ Open Feedback Publishing System ã¨ãã£ã¦å·çä¸ã®æ¸ç±ã«ã³ã¡ã³ãã§ããããã(ãã ã English)ã
ã¨ãããã㧠Grails ã®æ¬ãåºãã¿ãã(ã¾ã ååãæ¸ããã¦ããªã)ã
Stack Overflow ãè¦ã¦ãã㨠Groovy ã¿ã°ã«çµæ§ãªå²å㧠Grails ãæ··ãã£ã¦ããã®ã§æµ·å¤ã§ã¯äººæ°ãªã®ããªï¼
åºæ¬çã«ã¹ã¯ãªããããæ¸ããªãã®ã§é¢ä¿ãªããããªæ°ããããã©ã¹ã¯ãªããããã使ããã£ã½ãã