http://haskell.g.hatena.ne.jp/mr_konn/20061006/1160138831 Haskellããå ¥ã£ã人ã«ã¯ãcinã¨ãcoutã¨ãå¾®å¦ããã¦ãããªãã ããã¨ãæã£ãã®ã§ãé©å½ã«ã 対象èªè ã¯ãHaskellãããããC++ãããã人ï¼æå³ãã¼ï¼ããã¿ãç解ã§ãã人ã§ãã C++ã¨ã¯ C++ã¨ã¯ã以ä¸ã®ãããªç¹å¾´ãæã£ãããã°ã©ãã³ã°è¨èªã§ã åç §éæï¼ï¼ï¼ åºç¾è©ä¾¡(occurrence evaluation) ï¼ãªã©ã¨ããããããããåèªãã¤ããï¼ ãã¿ã¼ã³ãããã§ãã å ¨ãç´æçã§ãªãæ§æ IOã¢ãããæ¸ãããã®å¤§éã®syntax sugarããã 説æãã¦ããã¨é·ããªãã®ã§ããããããããããå¿ è¦ã«ãªã£ãã¨ãã«èª¬æããããã«ãã¾ãã C++ã®å C++ã«ã¯ã次ã®åãããã¾ãã æ´æ° çå½å¤ é£æ³é å ã¾ãããããã説æãï¼ã¯ããã飽ãã¦ããï¼
2006.10.06 ohmynews ã®èº«ä¸ã®è« ãã¼ãï¼ç§ã®PCçæ´»(7441) ã«ãã´ãªï¼æ¥å¸¸çãªåºæ¥äº ããããªã¼ãã¼ãã¥ã¼ã¹ã¯é¢ç½ããªãã¦å ¨ç¶ãã§ãã¯ãã¦ããªãã£ãã®ã ããä¹ ã ã«è¦ã«è¡ã£ããã¨ãã§ããªããã¨ã«ãªã£ã¦ããã ãæ»ã¬æ»ã¬è©æ¬ºã»ã¾ã¨ããµã¤ããã®åå£ããèãã ãæ»ã¬æ»ã¬è©æ¬ºãè¨äºã®åé¿ã«çãã ãæè¿ã®ãªã¼ãã¤ãã¥ã¼ã¹ã¯ãã¢ã¯ã»ã¹ãè½ã¡ã¦ããã¨2ã¡ãããæ»æãã¦ãã¼ã¸ãã¥ã¼ãå¢ããã¨ããã1chåã¢ãã«ãåãå ¥ãã¦ãããããã¨è¨ã話ãèããããããã«ãã¦ãæè¿ã®æµè¡ã«å®å¼¾ãæã¡è¾¼ãã§ããã¨ã¯åæ°ãããã ã¨ãããã¡ã¼ã¹ãã¤ã³ãã¬ãã·ã§ã³ãæã£ãã®ã ããã©ãããã®ãã¥ã¼ã¹ããã¾ãã«ãæ»æçã§ç¨æãããã æ¸ãã¦ãè¨è ã¯ãé³ç¾½ çå²ãã¨ã®ãã¨ã ãï¼ é³ç¾½ çå²ï¼ ã©ããã§èãããã¨ããããããªâ¦â¦â¦ã¨æã£ã¦ããã£ã¦ã¿ããããããªãããã¼ãã ãããªã¨ã¯ 2ã¡ããããã®æªã
èªåãã¡ã®è¨èã«æ¸ãå¾ããã® åè¨äºãããæ»ã¬æ»ã¬è©æ¬ºã»ã¾ã¨ããµã¤ããã®åå£ããèãããã¯ã¨ã¦ãåé¿ã大ããã£ããä»ãè¨äºãæ¸ãã¦ããï¼ï¼æï¼æ¥ååï¼æï¼ï¼åç¾å¨ãã¢ã¯ã»ã¹æ°ã ï¼ä¸ï¼ï¼ï¼ï¼åã§ã³ã¡ã³ãæ°ãï¼ï¼åã§ããã ã¢ã¯ã»ã¹è§£æãåºæ¥ãããã§ã¯ãªãã®ã§æ¨æ¸¬ã§ãããªãããï¼ã¡ããããããã®ã¢ã¯ã»ã¹ãããªãå¤ãã®ã§ã¯ãªãããã³ã¡ã³ãã«ããï¼ã¡ããããã¼ã代å¼ãããããªæè¦ãå¤ãã£ãã å¾æ®µã®å 容ã¯ç¢ºãã«åããã«ããã£ããããããªãããå°ãå¯ãããªãã®ã¯ãããã¾ã§ä¼ãããªããã®ãªã®ã ããããre-presentï¼ãªãã¬ã¼ã³ãï¼ã¯ãåç¾åãã¨è¨³ãããããã代表ãã代å¼ãã¨ããæå³ãããã®ã ã å§ãã«ï¼ã¤è¨ã£ã¦ããããã®ã¯ããã®è¨äºã¯ï¼ã¡ããããæ¹å¤ã¨ããããã§ã¯ãªããã¨ãããã¨ã ãã¼ãããã®è¨äºã«å ã ã¤ãããµãã¿ã¤ãã«ã¯ ããã¤ã³ã¿ã¼ããããã¨ããåç¾åï¼ãªãã¬ã¼ã³ãï¼ã ã ã£ãããããã示
Q:ããPythonã§éä¹ãæ±ãã(ããã¯ã²ã©ã)ãã¯Yã³ã³ããã¼ã¿ï¼ A:ããããã å帰å¼ã³åºãã¯æ®éã以ä¸ã®ããã«é¢æ°ãèªåèªèº«ã®ååã使ã£ã¦èªåèªèº«ãå¼ã³åºãã¾ãã >>> f = lambda n: n and n * f(n - 1) or 1 >>> f(5) 120 ããã§ãååãã¤ããã«ãé¢æ°èªä½ã«ãæãå ããã«ãå帰å¼ã³åºããå®ç¾ããããã®æ段ãYã³ã³ããã¼ã¿ã§ããå帰å¼ã³åºããå®ç¾ããã ããªãã°Yã³ã³ããã¼ã¿ã¯å¿ é ã§ã¯ããã¾ããã ååã®ã³ã¼ãã¯Yã³ã³ããã¼ã¿ã使ããã«å帰å¼ã³åºãããã¦ãã¾ããå ·ä½çã«ã¯ãå ã®é¢æ°ãnã ããåãåãã®ã§ã¯ãªããèªåèªèº«ãå¼æ°fã«åãåãããã«ããã¾ãå帰å¼ã³åºãã§fãå¼ã³åºãéã«ãå¼æ°ã«fã渡ãã¦ããããã«ãã¦ãã¾ãã Yã³ã³ããã¼ã¿çã¯ä»¥ä¸ã >>> Y = lambda f:((lambda g: f(lambda x: g(g)
ãªã¼ãã¤ãã¥ã¼ã¹ã® "ãæ»ã¬æ»ã¬è©æ¬ºã»ã¾ã¨ããµã¤ããã®åå£ããèãã" ã¨ããè¨äºã«é¢ãããã¡ãã®ã¨ã³ããªã«ãè¨è ã®é³ç¾½çå²ããããã³ã¡ã³ããããã ãã¾ããããããã¨ããããã¾ããã æ¬ã¨ã³ããªã§ã¯ãé³ç¾½ããããããã ããã³ã¡ã³ãã«ãçããããã¨æãã¾ãããã ããã¤ã³ã¿ã¼ãããã«ãããäºãã®é¡ã®è¦ããªãè°è«ã§ã¯ãããããã«è°é¡ãå¢ããã¨åæ¾ãã¤ããªããªããã¨ã¯ãéå»ã®çµé¨ããããåãã£ã¦ãã¾ããããã§ãæ¬å½ã¯ä¼ºããããã¨ãä»ã«ãããã¤ãããã®ã§ãããä»åã¯ã¾ããé³ç¾½ãããã示ãã«ãªã£ã以ä¸ã®3ã¤ã®ãã¼ãã«çµã£ã¦è°è«ãé²ãããã¨æãã¾ãã ï¼ï¼NHKè·å¡ã®çµ¦ä¸ã¯é«æ°´æºãªã®ãï¼ ï¼ï¼ç§ãã¡ã示ããè«æã¯æ ¹æ ã¨ãã¦èªãããããï¼ ï¼ï¼ç§ï¼fw0ï¼ã¯3000ä¸åãç¨æã§ãããï¼ ä»¥ä¸ãé ã«è¦ã¦ããã¾ãã â ï¼ï¼NHKè·å¡ã®çµ¦ä¸ã¯é«æ°´æºãªã®ãï¼ ããã¯æè¦ãããã¾ããããããããããªãããä¸ã®æ å ±ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}