2010-01-01ãã1å¹´éã®è¨äºä¸è¦§
1å¹´åã®ä»æ¥ãã¢ã»ã³ããªã§æ°åè¡ã®echoããã°ã©ã ãä½æãã¾ããã ãããå¾ã ã«è²ã¦ã¦ãä»æ¥ã§ã¯ã½ã¼ã¹ã³ã¼ãè¡æ°ããã¼ã¿ã«ã§1ä¸5åè¡ãè¶ ãã¦ãã¾ããã ï¼å¹´ã§ãã£ãããã ããã¨ããæ°ãããªãããªãã§ããã趣å³ããã°ã©ã ã«ãã¦ã¯ãããªãã«é²ãã ã®â¦
50åç®ã¾ã§è§£ãã¾ãããæ°å¦ã使ã£ã¦å·¥å¤«ããã¨éã解ããããããããªãã®ã«ã¤ãã¦ã ãèªåã®è§£çãæ¸ãã¾ãã Problem 15 20x20ã®ã°ãªããã®å·¦ä¸ããå³ä¸ã¾ã§ã®æççµè·¯æ°ãæ±ãã ããã¯ï¼é ä¿æ°ã ã®å¤ãè¨ç®ããã°è¯ãã§ããï¼é ä¿æ°ã®å¤ã¯ãã¹ã«ã«ã®ä¸â¦
8åã¨ãã¾ããã Problem 3 600851475143ã®æå¤§ç´ å æ°ãæ±ãã ãç´ å æ°å解ãããã§ã¯ãªããæå¤§ç´ å æ°ã ãæ±ãããã§ãããç´ æ°ã®ãã¼ãã«ã¯ä½ããããªãã®ã§ãå復ã«ããæ±ããäºãèãã¾ãã æ´æ°Nãç´ å æ°å解ãã¦ã¿ã㨠ã¨ãªãã¾ãããããã®æå°ã®ç´ â¦
ããã¯ããªãã®è¯éã§ã¯ãªãã§ããããã ç´æ°ã®æ°ã500以ä¸ã«ãªãæåã®ä¸è§æ°ãæ±ããä¸è§æ°ã¨ã¯ä»¥ä¸ã®å¼ã§æ¸ãããã®ã§ãã Nã®ç´ å æ°å解ãä¸ã®ããã«ãªãæ ç´æ°ã®åæ°ã¯ ã¨ãªãã¾ããã¾ããäºãã«ç´ ãª2æ°ã¯ææ°ãéè¤ããªãã§ãããã nãå¥æ°ãªã ã§â¦
Project Euler解ãå§ãã¾ãããèªåã®æ°å¦ã®åå¼·ãå ¼ãã¦ãã§ããã ãããã°ã©ã ã§ã®åæã®è¨ç®ã¯é¿ãããã¨æã£ã¦ãã¾ããã©ããã¦ãããã°ã©ãã³ã°ãå¿ è¦ãªãã¤ã¯ããã¨ã§rowlã§æ¸ããã¨æã£ã¦ã¾ãã Problem 1 1000æªæºã®3ã¾ãã¯5ã®åæ°ã®åãæ±ãã éåâ¦
nåã®å¯¾å¿ããæ¬å¼§ã®ãã¿ã¼ã³ã®æ°ãæ¯é¢æ°ã使ã£ã¦æ±ãã¦ã¿ã¾ããã ããã¯id:nobsunãããææãªãã£ã¦ããããã«ã«ã¿ã©ã³æ°ã¨ããæ°ã«ãªããã§ãããããããåæç¥èãªãã§æ©æ¢°çã«è§£ããããããªå ´åã«ä½¿ãã¾ãã ããããªæç§æ¸ãããã¨æãã¾ãããç§â¦
rowlã®å¼ã¨ãã¦ä»¥ä¸ã®å®ç¾©ã使ãæ¹éã«ãã¾ããããã®çºãããããã¨å®è£ ã®ä¿®æ£ãè¡ã£ã¦ãã¾ãã åå§å¼(ã·ã³ãã«ï¼æ´æ°ãªãã©ã«ï¼æµ®åå°æ°ç¹æ°ãªãã©ã«ï¼æåå)ã¯å¼ã§ããã hãã·ã³ãã«ï¼e1,...,enãå¼ã®æ h(e1, .., en)ã¯å¼ã§ãããhãå¼ã®headã¨è¨ããâ¦
åã§ã®ãããã³ã°ã®å®è£ ãä¸é¨å®è£ ãã¾ããã ããã«ãã£ã¦é¢æ°ã®ãªã¼ãã¼ãã¼ããåºæ¥ãããã«ãªãã¾ããâ print(10) # print_intãå¼ã°ãã print("Hello World") # print_stringãå¼ã°ããé¢æ°å®ç¾©æã«ã¯ãããªæãã§æ¸ãã¾ãâ fib(n!Int): fib(n-1) + fiâ¦
Haskellã«å¯ä½ç¨ãããã®ãï¼ã¨ããã®ã¯é£ãããã¼ãã ã¨æãã¾ãããå°ãªãã¨ãæé©åçè«ã§ã®ä¸è¬çãªãå¯ä½ç¨ãã®å®ç¾©ã§ã¯Haskellã¯å ¨ãå¯ä½ç¨ããªãè¨èªã¨è¨ããã¨æãã¾ãã çè«çã«ç¾ããã¨ããç¹ãHaskellã®è¨è¨ã®ä¸çªéè¦ãªã¨ããã ã¨æãã®ã§ããâ¦
Rowlã®åçãªãã¿ã¼ã³ãããã¨ã³ã¸ã³ã®æ§æã«ã¤ãã¦æ¸ãã¾ãã ã¾ããã¤ã³ã¿ããªã¿å ã«funtableã¨ããé¢æ°ãã¼ãã«(é¢æ°å à å¼æ°ã®æ° â é¢æ°å®ä½)ãããã¾ãã é¢æ°ã®å®ä½ã¯ é¢æ°æ¬ä½(ãã¤ãã³ã¼ã) é¢æ°å®ç¾©ã®ãªã¹ã(ASTã§ã¯ãªãã³ã³ãã¤ã«ããå½¢) ãããªâ¦
以ä¸ã®è¨äºã®ããããã¯ãã¼ã«ã«ã§é¢æ°å®ç¾©ãåå®ç¾©ã§ãããã¨ããä»çµã¿ã«ã¯åé¡ãããã¾ããã®ã§ããããã¨ã«ãã¾ããã ä½ãå¥ã®å½¢ã§çç¾ãªãåæ§ã®æ©è½ã使ããããã«ãããã¨æãã¾ãã fib(n): fib(n-1) + fib(n-2) fib(0): 0 fib(1): 1 print_int(fibâ¦
èªåã¯ã³ã³ãã¤ã©ã®å®è£ è¨èªã«ã¯ãã¿ã¼ã³ããããããã¨æ¥½ã ã¨æã£ã¦ããã®ã§rowlã«ããã¿ã¼ã³ãããã¨ã³ã¸ã³ãå®è£ ãã¦ãã¾ãã以ä¸ã®è«æãåèã«ãã¦ãã¾ãã http://portal.acm.org/citation.cfm?id=507641&dl= ããã¾ã§å¤æ°ãã¿ã¼ã³ãDontcareãã¿ã¼ã³â¦
ã¨ã¯ãã£ã¦ãx86ã®æ©æ¢°èªãçæããã®ã§ã¯ãªããVMã®ãã¤ãã³ã¼ããçæãããã¤ãä½ãã¾ãããx86ã®JITã¢ã»ã³ãã©ã¯æ¬¡ã®ä¸ä»£ã§ä½ãäºå®ã§ãã ãã®JITã¢ã»ã³ãã©ã¯ç¾å¨å®è£ ä¸ã®ã¤ã³ã¿ããªã¿ã«å èµããJITã³ã³ãã¤ã©ã§ç¨ãã¾ãã 以ä¸ã¯ãã£ãããããè¨ç®ãâ¦
ãªã³ã«ãåé¡ãªãåãããã«ãªã£ãã®ã§ããããã次ã®å¦çç³»(rowl1)ä½ããéå§ãã¾ããã ã¬ããµã¯ããã¾ã§ã¨åããç¶æ é·ç§»å³ãæã§ä½æãã¾ãããrowl2ã®éçºæã«ã¯ã¬ããµã®èªåçæãåºæ¥ãããããè¨èªãé«ç´ã«ãªã£ã¦ããã¨è¯ããªãã¨æã£ã¦ãã¾ããç¾å¨â¦
ä¸ãæã»ã©æ¬æ¥ã«å°å¿µãã¦ãã¾ããããRowlã®éçºãåéãã¾ããã çµæ§å¿ãã¦ããã¨ãããããã®ã§ãããã¾ã§ã®çµéãã¾ã¨ãã¾ããããã¾ã§å®è£ ãããã®ã®ä¸è¦§ã¯ä¸å³ã åé¡1: æ©è½ä¸è¶³ ã¢ã»ã³ããªè¨èªã§å®è£ ããrowl0ã¯æ©è½ã貧弱ããã¦ã次ã®ã¹ãããã§ä¸â¦
ãã³ããã¼ã¯ç¨éãç®çã¨ãã¦Rubyã§æ¸ããã¬ã¤ãã¬ã¼ãµã¼ãå ¬éãã¾ããhttp://github.com/nineties/raytracer以ä¸ãPart3ã¾ã§å®è£ ãããã®ã§ãã http://www.devmaster.net/articles/raytracing_series/part1.phpPPMå½¢å¼ã®ç»åãçæããã®ã§é©å½ã«å¤æãâ¦
ã³ã³ãã¤ã©ã®å®è£ è¨èªã«ããã¨è¯ãæ©è½ã§Javaã§AST(æ½è±¡æ§ææ¨)ä½ãã®ã大å¤ã ã¨ãã話ã«è§¦ããã®ã ããã©ããå®ã¯èªåã®ç¥ããªãè¯ãããæ¹ãããã®ã§ã¯ãªããã¨æã£ã¦Clojureãªã©Javaã§å®è£ ãããå¦çç³»ã®ã½ã¼ã¹ãè¦ãã¦ã¿ã¾ããã çµè«ï¼ãã£ã±ã大å¤ã Câ¦
Så¼ããbrainfuckã®ã³ã¼ããèªåçæããããã°ã©ã ãæ¸ãã¦ã¿ã¾ããã ã³ã¼ãçæãç®çã§ã¯ãªãã¦åã«ã§ããã ãããã¨æ°ã«ãªã£ãã®ã§ãã£ã¦ã¿ã¾ãããgaucheã使ãã¾ããã brainfuck ã¤ã³ã¿ããªã¿ãã¹ã¿ãã¯ãã·ã³ã£ã½ã使ã£ã¦åä½ãã¾ãã å¤æ°ã使ããâ¦
ç´ç²é¢æ°åè¨èªã®å¦çç³»ãä½ã£ã¦ã¿ããã¨ã«ãã (ãã®3 : Mark-1 G-machine)ã®ç¶ããæç§æ¸P94-P97ã¾ã§ã http://github.com/nineties/puref/commit/4cd5d92a5f02468929bc2dd2ddafbd363251c86cMark-2 G-machineã§ã¯é 延è©ä¾¡ãè¡ãçºã®æºåã¨ãã¦ãUpdate/Popâ¦
ç´ç²é¢æ°åè¨èªã®å¦çç³»ãä½ã£ã¦ã¿ããã¨ã«ãã (ãã®2)ã®ç¶ãã ä»æ¥ã¯æç§æ¸ã®ç¬¬3ç« P75-P94(Mark1: A MINIMAL G-MACHINE)ã®å®è£ ããã¾ããã ç¾ç¶ã§ã¯é¢æ°é©ç¨ããã§ãã¾ãããé 延è©ä¾¡ã¯ã¾ã æ±ã£ã¦ããªãã¦ã次åMark2ã§æ±ããã¨ã«ãªãã¨æãã¾ãã ãã â¦
ãããªã®ãè¦ã¤ããã®ã ãã© http://code.google.com/p/brainfuckos/ ä¸ã空ã£ã½ã§ãã£ããããã®ã§ãèªåã§ä½ãä½ã£ã¦ã¿ãããã¨æã£ãã ã¯ã£ããè¨ã£ã¦ããã©ãããããã®ã§ç¶ãã¯ããã¾ãããããããªã®ä½ã£ã¦ã¿ã¾ããã .code16 .equ SCREEN, 0xb800 .eâ¦
ãã¡ã¤ã«å ¥åºåã¨ãå¯å¤é·é åã¨ãrowlVMã®ããªããã£ããå å®ãã¦ããã®ã§ãç¾å¨ã¯rowl-coreè¨èªã§æ¬¡ærowl1ã³ã³ãã¤ã©ã®å®è£ ããã¦ãã¾ãã ã¨ããããã¡ã¢ãªããã¼ã¸ã£ã®ãªãã¹ã¯ãªããè¨èªã§ããrowl-coreã¯å¤§éã«ã¡ã¢ãªãæ¶è²»ããçºã¤ãã«éçããã¾ãâ¦
ç´ç²é¢æ°åè¨èªã®å¦çç³»ãä½ã£ã¦ã¿ããã¨ã«ããã®ç¶ãã å é±æ«ã¯ã¡ãã£ã¨å¿ããã£ãã®ã§æ¯é±æ¥ææ¥ã®äºå®ãããã¦ãã¾ãã¾ããã ä»æ¥ã¯Pretty Printerãä½ãã¾ãããG-machineã¯æ¬¡åã«åãã¾ãã http://github.com/nineties/puref/commit/9295d96e1e0adb7â¦
ã¡ã¢ãªããã¼ã¸ã£ãã¡ããã¨åãã¾ãããGCãä»ã®ã¨ãã大ä¸å¤«ã£ã½ãã§ãã ã¨ãããã¨ã§ãã¨ã©ãã¹ããã¹ã®ç¯©ãå®è£ ãã¦ã¿ã¾ããã次æã³ã³ãã¤ã©å®è£ å°ç¨ã®DSLãªã®ã§å¯èªæ§ãä½ãã®ã¯åå¼ãã¦ãã ããã (fun main () ( (sieve 200000) (exit 0) )) (fun sâ¦
ããã°ã©ãã³ã°è¨èªã®é«ç´åã¯ãã¦ãã¦ããã°ã©ã ãè¤éåãæé©åãé»å®³ãã¦ãã¾ãã¾ãã rowlã®éçºã§ã¯ãã®ãã¬ã¼ããªãã«ã¤ãã¦ç¥çµè³ªã«ãªããã¨æã£ã¦ãã¾ãã æé©åã®åºæ¬ æé©åã«ã¯å½ä»¤æ°åæ¸ã»ä¸¦ååã»ãã¤ãã©ã¤ã³æé©åã»ã¬ã¸ã¹ã¿å²ãå½ã¦ã»ã¹ã±â¦
æ§é ä½ã¨ãé åã¨ãã©ããªè¨èªã«ã大ä½ãããã®ã¯é¤ãã¾ããããã¾ã§ç§ã®ä¸»è¦³ã§ãã lex/yacc/gperfãªã©ã®ãã¼ã« ç¹ã«yaccããªãã¨è¤éãªè¨èªã®ãã¼ã¹ã¯å¤§å¤ã ããªã¢ã³ã æ§ææ¨ã®è¡¨ç¾ã«ä¸çªé©ãã¦ããã¨æãã ãã¿ã¼ã³ããã ã³ã³ãã¤ã©å é¨ã¯ãã¿ã¼ã³ãâ¦
é¢æ°åè¨èªã¨ããã¨åã·ã¹ãã ãªã©ããã³ãã¨ã³ãé¨ã«æ³¨ç®ãéã¾ããããã¨æãã¾ãããç§ã¯ããã¯ã¨ã³ãã®å®è£ ã«èå³ãããã¾ãã ããã§å°ããªç´ç²é¢æ°åè¨èªã®å¦çç³»ãä½ããã¨ã«ãã¾ãããååã¯å®ç´ã§ããpurefã«ãã¾ããæ¹é åå¼·ç¨ã®å®è£ 飾ãã¯ä»ãâ¦
æ§ææ¨ã¯æç§æ¸7ãã¼ã¸ã«æ¸ãã¦ããã¾ããé常ã«ã·ã³ãã«ã§ããHaskellã®ãããªè¤éãªè¨èªãæ§æç³è¡£ãåãé¤ãã¨,åæ§ã®è¨èªã¾ã§åç´åããã¾ãããããªãã«ãªã¨æã人ã¯,GHCã®ã½ã¼ã¹ã®ghc/compiler/coreSyn/CoreSyn.lhsãèªãã§ã¿ã¦ä¸ããã ã¬ããµ/ãã¼ãµâ¦
Cè¨èªã®ã½ã¼ã¹ãcppã«ãããã¨çæããããã£ã¬ã¯ãã£ãã®æå³ã # 1 "/usr/include/math.h" 1 3 4 æåã®æ°åã¯ãã¡ã¤ã«ã®è¡çªå·ã§ãæ«å°¾ã®æ°å㯠1 : includeãéå§ãã¦æ°ããªãã¡ã¤ã«ã«ç§»ã (ENTERãã©ã°) 2 : includeãçµäºãã¦å ã®ãã¡ã¤ã«ã«æ»ã (LEAVâ¦
ä»æ¥ãµã¨é«æ ¡æ代ã«é»åéã³ã«ããã£ã¦ããäºãæãåºããã®ã§ãã¡ã¢ãã¦ããã¾ããâã®ãªãè¨ç®æ©ã§Nã®å¹³æ¹æ ¹ãæ±ãããå ´å㯠[N(æ°å)][M+]ã¨æ¼ããã㨠[MR][x][MR][-][N][/][2][/][MR][M-]ãç¹°ãè¿ãã¾ãã Nã®mä¹æ ¹ã®å ´å㯠[N][M+]ã¨æ¼ããã㨠[MR][xâ¦