ãã®è¨äºã«ã¯åèæç®ãå¤é¨ãªã³ã¯ã®ä¸è¦§ãå«ã¾ãã¦ãã¾ãããè注ã«ããåç §ãä¸ååã§ãããããæ å ±æºãä¾ç¶ä¸æ確ã§ãã é©åãªä½ç½®ã«è注ã追å ãã¦ãè¨äºã®ä¿¡é ¼æ§åä¸ã«ãååãã ãããï¼2020å¹´5æï¼ ã©ã ãè¨ç®ï¼ã©ã ããããããè±èª: lambda calculusï¼ã¯ãè¨ç®æ¨¡åã®ã²ã¨ã¤ã§ãè¨ç®ã®å®è¡ãé¢æ°ã¸ã®å¼æ°ã®è©ä¾¡ï¼è±èª: evaluationï¼ã¨é©ç¨ï¼è±èª: applicationï¼ã¨ãã¦ã¢ãã«åã»æ½è±¡åããè¨ç®ä½ç³»ã§ãããã©ã ãç®æ³ã¨ãè¨ããé¢æ°ã表ç¾ããå¼ã«æåã©ã ã (λ) ã使ãã¨ããæ £ç¿ãããã®åããããã¢ãã³ã¾ã»ãã£ã¼ãã¨ã¹ãã£ã¼ã´ã³ã»ã³ã¼ã«ã»ã¯ãªã¼ãã«ãã£ã¦1930年代ã«èæ¡ãããã1936å¹´ã«ãã£ã¼ãã¯ã©ã ãè¨ç®ãç¨ãã¦ä¸éè¿°èªè«çã®æ±ºå®å¯è½æ§åé¡ãï¼å¦å®çã«ï¼è§£ãããã©ã ãè¨ç®ã¯ãè¨ç®å¯è½ãªé¢æ°ãã¨ã¯ãªã«ããå®ç¾©ããããã«ç¨ãããããã¨ããããè¨ç®ã®æå³è«ãåçè«
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 ''' Implementation of the fixed point combinator Y. ----------------------------------------------- The Y combinator is a higher order function that suffices following relation: Y(F) = F(Y(F)) From the fixed point property we can get an idea on
ããã¾ã§CPUã¯ã ã¼ã¢ã®æ³åã«å¾ã£ã¦é«éåãã¦ããããä»å¾ãCPUã¯é«éåããã並ååãé²ãããããã¾ã§ã¯åä½ã®é ãããã°ã©ã ã§ããæ¥å¹´ã«ã¯é«éã«åãã¨ããã®ã常èã§ãããããããããã¯ãã¯ãç¾å¨ã®ç¶æ³ã«ã¯å½ã¦ã¯ã¾ãã¾ãããããµã³ã»ãã¤ã¯ãã·ã¹ãã ãºã§Webãã¯ããã¸ã¼é¢é£ã®ãã£ã¬ã¯ã¿ã¼ãåãããã£ã ã»ãã¬ã¤ï¼Tim Brayï¼æ°ã¯ãè¿ãå°æ¥ã«ããã°ã©ããç´é¢ããåé¡ã¯ãCPUã®ã³ã¢æ°ãå¢ãã¦ãã¼ãã¦ã§ã¢ã®ä¸¦ååãé²ãã®ã«å¯¾ãã¦ãç¾å¨ä½¿ããã¦ããè¨èªã®å¤ãã§ä¸¦åããã°ã©ãã³ã°ã®ãµãã¼ããååã§ãªããã¨ã ã¨ããã ãUltraSparc T1ã§ã¯8ã³ã¢32ã¹ã¬ããã®ä¸¦åå¦çãå¯è½ã§ããIBMãAMDãã¤ã³ãã«ãCPUã®ã³ã¢ã®æ°ãå¢ããã¤ã¤ããã¾ããJavaEEã使ãã°ã¹ã¬ãããµãã¼ãã«ãã並ååã®æ©æµã«ããããã¾ãããããã§ãªãè¨èªãå¤ãããã¾ããã ãã¬ã¤æ°ã¯ãããããåé¡ã«å¯¾ãã¦2ã¤ã®æ¹
ãã«ã®ã¼ã«è¡ã£ã å æ¥ããã«ã®ã¼ã«è¡ãã¾ããã ãã°ãªããã®çµµã¨ã«ã¼ãã³ã¹ã®çµµãè¦ãã®ãç®çã ãã¾ãæéããªããããªã¥ãã»ã«ã¨ã¢ã³ãã¯ã¼ããé§ã足æ°å³ã§å·¡ããã¨ã«ã ãã¥ã³ãã³ããè»ã§10æéè¿ããããããªãã§ãããªç¡è¶ããã¦ãã¾ã£ãã®ãã¨ãæãã¾ããããã¨ã¼ãããã®æ¹â¦
[id:m-hiyama:20060615]ããTBããã¦ãæ¹ãã¦èããã¾ã¨ãããï¼åã®è¨äºã¯ããªãã¸ã§ã¯ãæåã®è©±ãããªãã£ã¦ãã£ãªã¢ã®è©±ã ã£ãã®ã§ï¼*1 - ã¨ãã£ã¦ããæ£ç´ã«è¨ã£ã¦ãç§ãã¡ããã¨ç解ãã¦ããã¨è¨ãããªãã¸ã§ã¯ãæåè¨èªã¯ãJavaããããããªãã®ã§ãçµå±ã¯Javaã®è©±ãªã®ã§ããã æè¿ãè³å ã§ãJavaã¨Schemeã®å·®ãã©ãã©ããªããªã£ã¦ããã®ãæããã®ã§ããã¯ã£ããè¨ã£ã¦ããJavaã®ãªãã¸ã§ã¯ã ï¼ Schemeã®ã¯ãã¼ã¸ã£ãã¨ããæããªãã§ãã åã«ããã®ããã°å ã§ãSmalltalkã®ãªãã¸ã§ã¯ãã¨Schemeã®ã¯ãã¼ã¸ã£ã¯é常ã«è¿ãé¢ä¿ã ã¨ãã話ãããã¾ãããï¼see: [id:lethevert:20060117:p1], [id:lethevert:20060118:p2]ï¼ãããã§è¨ããã¦ãããã¨ãJavaã§å®æããããã«ãªã£ã¦ããã¨ãããã¨ãªã®ã§ã
C++ 㯠JS ã»ã©ãããªãã«ããã誤解ããã¦ããè¨èªã ã¨æãã¾ãããããè¤éã ã¨ãããã®ã¯èª¤è§£ã§ã¯ãªãç´ããã¨ãªãçå®ãªã®ã§ããããã®è¤éãããã ãã©ãã¤ã¢ããæ¥ãè¤éãªã ãã®ãã®ã§ã¯ãªããä¸å¿ã®æç¨æ§ãä¼´ããã®ã â¦ã£ã¦ããããã¯ããã£ã¦ãããªæ°ã¯ããã®ã§ã誤解ã¨ããã»ã©ã®ãã¨ã§ããªãããã§ãããæ¨ä»ã«æ¯ã¹ã¦ããªããæç¨ãããªãã®ã§ãããã¨ããèªèã¯ä½ãã ã£ãããã«æãã¾ãã ãã ä»åº¦ã¯ããªããé¢æ°åãªé°å²æ°ããã¼ããã¨ããã ãã®åèªãä¸äººæ©ãæ°å³ãªæ°ããã¾ãããªãããããããã© C++ ããã¼ãã¿ãããªãä¸æåã® Haskell ãå¾ã¦ãããããªã¤ã¤ãªå°ä½ãã²ãããã¦ãããããªæ°ããã¦ãããã¯ããã§å¥ã®ç¨®é¡ã®ããã種ã®èª¤è§£ã§ããããã«æã£ãã®ã§ããã ã¨ããããã§ãã«ããã©ãã¤ã è¨èª C++ ã«ã¤ãã¦ãé¢æ°åè¨èªã¨ãã¦ã®æ©è½ã«ã¤ãã¦åã®è¦æ¹ãã ã¾ã絶対ã«æèãã¦æ¬²ããé¨åãªã®ã§ãã
23 ãã¹ã¼ããæ°åºãã¼ã ä¸é±éãããæ¾ç½®ãã¦ããããæ°åºããã¨æã£ã¦ããã ãã©ãå ¨ç¶ä½ããã¦ãªãã®ã ã£ãã ã¨ããããã§ããªãããªãã¦ããªããæ¸ãããé¢æ°åè¨èªãCè¨èªãããé«éã ã¨ãã話ã http://d.hatena.ne.jp/w_o/20050924#p2 ãããã¸ãã®è©±ã®é¢é£ãCè¨èªã§ã¯ãæä½ãããã¡ã¢ãªãå¤æ´ãããã¨ããå ·ä½çãªãã®ã«ãªã£ã¦ãã¾ãã®ã§ãæé©åãé£ããã¨ãã話ã 次ã®ã³ã¼ããèãããã struct stack { char *buf; int pos; }; void push( struct stack *stk, char v ) { stk->buf[stk->pos] = v; ++stk->pos; } void pop( struct stack *stk ) { --stk->pos; }; void nop( struct stack *s
è³è²¸æ®ããã®ãã家ã®å°é対çãæºãããå½ãå®ãç·¨ã 以åã®ããã°ã§ãè¨è¼ãããé²ç½ã®åªå é ä½ã«åºã¥ãã¦å¯¾çãé²ãã¦ãã¾ããã¾ã æãã¤ãããã¦ããªãé¨åãããã¾ãããããç¨åº¦ã¾ã¨ã¾ã£ã¦ããã®ã§ãã£ããã¨ãç´¹ä»ãã¦ããã¾ãã åªå é ä½å¥ã«æ¹åãã¦ãã£ã¦ãããããä»åã¯ä¸»ã«å°éã®æºã対çãã¡ã¤ã³ã«ãªãã¾ããâ¦
[ruby] Rubyã§Map by MethodãJavascriptã«ç§»æ¤ãã¦ã¿ãã SpiderMonkeyéå®ã«ãªãã®ãã¨ã¦ãã¤ã¿ã¤ã®ã§ãããIEã§ãåããããªæ¹æ³ã試ããªãããã¨ã§èããã(å®ç¾©ããã¦ããªãã¡ã½ãããå¼ã³åºããéã«å¼ã³åºãããã¯ã¡ã½ãããå®ç¾©ãããã®æ¹æ³ã¯ä½ã¦ååãã¤ãã¦ããã ããï¼èª°ãæãã¦ãã ããã) String.prototype.singularize = function() { // ææãå®è£ return this.replace(/s$/, ''); } Array.prototype.map = function(lambda) { var ret = []; for(var i=0,l=this.length;i<l;i++) ret[i] = lambda(this[i]); return ret; } Array.prototype.c
2å¹´åPHPã§ã¬ãªã¬ãªã¨ä½ã£ã¦å·¥å¤«ããããèãã¦ããã¨ãã«ã¯ã試è¡é¯èª¤ãç¹°ãè¿ãã¦ããããRailsã使ãåºãã¦ããã¤ãã¤ãRailså ã®æ©è½ã§æºè¶³ãã¦ãã¾ãã ãã»ã©æ°ãã¤ãã¦ããªãã¨ãããã«ã¯æ¹åãã¹ãé¢ç½ãæ©è½ãããããããã®ã«ãããè¦éãã¦ãã¾ããå¤å°é¢åã§ãRuby&Railsã®ååãªæ©æµã«ãããã£ã¦ãã¦ãããã§ååç°¡åã ã¨æãè¾¼ãã§ãã¾ãã ä¾ãã°Symbol#to_procã使ç¨ãã次ã®ãããªã³ã¼ããããæ¸ãã Person.find(:all).map(&:username) Person.find(:all).map {|obj| [obj.username, obj.age]} Symbol#to_procã¯ãã¨ã¦ãç¾ããã便å©ã§ããå©ç¨ããåã ãããã®ã³ã¼ãã£ã³ã°ãåé·ã«æãã¦ããã method_missingãå©ç¨ãã¦ã¡ã½ãããmapã¡ã½ããã¨é¢é£ä»ãDynami
é¢æ°åè¨èªã¨ãªãã¸ã§ã¯ãæåã¯ç¸å®¹ããªãï¼ã¨ãã説ãããèãããããã«ããªãã¸ã§ã¯ãã¯ç¶æ ãæã¤ããé¢æ°åããã°ã©ãã³ã°ã§ã¯ï¼ã§ããã ãç ´å£çä»£å ¥ãè¡ããªããã¨ããã°ï¼äºã¤ã®æ¦å¿µã¯çç¾ãã¦ããããã«ãæããããã¾ãï¼æè¡ç観ç¹ä»¥å¤ã«ãï¼ãã¨ããã·ã³ãã«ãã好ãå¤ãã®é¢æ°åè¨èªããã°ã©ããï¼ä½ãã¨ç©äºãè¤éã«ããï¼ã¨æããã¦ããï¼ãªãã¸ã§ã¯ãæåãå«ã£ã¦ãããã¨ããé¢ããããããããªãã ãããï¼å人ã®å¥½ãå«ãã¯ãã¦ããï¼å®éåé¡ã¨ãã¦ï¼é¢æ°åè¨èªã¨ãªãã¸ã§ã¯ãæåã¯å¤§ãã«é¢ä¿ãããããããï¼åºç¤çè«ã«ã¤ãã¦ã¯ï¼ã»ã¨ãã©åãã³ãã¥ããã£ã®äººãã¡ãåãçµãã§ããï¼ã¨è¨ã£ã¦ããããä¾ãã°ï¼ä»¥ä¸ã®ãããªç 究ãï¼1980年代ããç¾å¨ã«è³ãã¾ã§è¡ããã¦ããã é¢æ°åè¨èªã®ã¢ãã«ã§ããλè¨ç®ã¨ããä½ç³»ã«ããã¦ï¼ãªãã¸ã§ã¯ãã表ç¾ããç 究ï¼åèãªã³ã¯ãªã©ï¼ λè¨ç®ã«ãªããï¼ï¼ãããã¿ã¤ããã¼ã¹ã®ï¼ãªãã¸ã§
ã¾ãï¼ã³ã³ãã¤ã©ã¨ãä½ã£ã¦ã㨠CPS (ç¶ç¶æ¸¡ãã¹ã¿ã¤ã«) ã£ã¦ã®ã¯é常ã«éè¦ã«ãªã£ã¦ãããã§ããï¼ããã¾ãä¸éçã«ã¯ã¡ã¸ã£ã¼ãªæ¦å¿µãããªãã®ããï¼ ã¨ããããã§ï¼çªçºçã« ET 㧠CPS ã説æãã¦ã¿ãï¼é¢åãªã®ã§ï¼è©³ãã㯠(1) ãªãã§ãç¶ç¶ (2) Scheme:CPS (3) æ å ±ç§å¦å®é¨IIè³æ (3) CPSã®å®ç¾© ãªã©ãè¦ã¦ãã ãã (ææã)ï¼ # ãã¨ãã¨ãã¾ãã¾èªãã (2) ã«ï¼ãCPSãã®ãã®ã¯ã Perlã§ãRubyã§ãJavaã§ãæ¸ãã¾ãããã¨ãã£ã¦ï¼ã§ããããªä½æ°´æºãªè¨èªããé¢åã ããã«ï¼ET ã¨ã Prolog ãªããã£ã¨æ¥½ãªã®ã«ãªãï¼ã¨æã£ãã®ããã£ããï¼ ã¡ãã¼ç°¡åãªä¾é¡ã¨ãã¦ï¼ãªã¹ãã®é·ããæ±ããã«ã¼ã« length ã使ããï¼ (length () *n) --> (= *n 0). (length (? | *xs) *n) --> (len
JavaScriptã§ã«ãªã¼åããããã¡ãã¤ããå®éã«ããã§ãããããå°ãã¿ã¨æã£ã¦ããã¯ãããããæå¤ã¨æ··ä¹±ãããä¸ç¨®ã®ã¡ã¿ããã°ã©ãã³ã°ã®ã¯ãã ããå®éã«ã¯ããã¹ãå å·¥å¦çã å å®¹ï¼ ã«ãªã¼åã£ã¦ãªã«ï¼ ã«ãªã¼åãè¡ãé¢æ°ãä½ãï¼æºå ã«ãªã¼åãè¡ãé¢æ°ãä½ãï¼ããã¹ãã®ãããã¯ã¼ã¯ ã«ãªã¼åãè¡ãé¢æ°ãä½ãï¼çµã¿ç«ã¦ âã«ãªã¼åã£ã¦ãªã«ï¼ 2å¼æ°ã®é¢æ°f(x, y)ã«å¯¾ãã¦ããgãfã®ã«ãªã¼åãã ã¨ã¯ãf(x, y) = g(x)(y) ã常ã«æç«ããã㨠-- ã´ãã£ã´ãã£èª¬æããããå®ä¾å®ä¾ï¼ functio sum(x, y) { return x + y; } ãã®sumã®ã«ãªã¼åã®ä¾ï¼ function curried_sum(x) { return function (y) {return sum(x, y);} } curreid_sumé¢æ°ã¯1å¼æ°ã§ãæ»ãå¤ã¨ãã¦é¢æ°
é¢æ°åããã°ã©ãã³ã°è¨èªã触ã£ããã¨ããªãã®ã§ãããé¢æ°çãã©ããã¯ç¥ããªããããã¡ãã¡ function ã¨ã return ã¨ãæ¸ãã®ã¯é¢åãããã¨æã£ãã®ã¨ãé¢æ°ã®å¤å½¢ãã beyond.js ãboost::bind ã«å½±é¿ãåãã¦ãé¢æ°ã®å¤å½¢ãè¡ãã©ã¤ãã©ãªãä½ã£ãã ã¾ãã¯å¼æ°ã®æç¸ãåã³å ¥ãæ¿ãããé¢æ°ã®å¤å½¢ãåã³ boost::bind ã«ãªãã£ã¦å¾ã å ¥åãããå¼æ°ã _n ã§ãããããã¨ã«ããã function concat(a, b) { return "" + a + b; } concat.bind(_1, "a")("b"); // "ba" concat.bind("a", _1)("b"); // "ab" concat.bind(_2, _1)("a", "b"); // "ba" concat.bind(_1, _1)("a"); // "aa" 次ã«é¢
ãããã軽ãã Larry and Damianã®è©±ãè¡ããã¦ãã¾ããä»æ¥ãé å»ãã¦ãçããæã«ã¯å¼¾ããã®è³ªåæéã«ãªã£ã¦ãããæ®å¿µã é¢æ°åã¨OOPã®è©±ã®ç¶ããã¡ãã£ã¨è°è«ããã¦ã¿ãã®ã ããã©ããä¾ãã°ããããããã°ã©ã ãèãã¦ã¿ããã class Mover1{ int x; public Mover(int x){ this.x = x; } public void move(){ this.x++; } public int getX(){ return this.x; } } ãã¦ããã®ã³ã¼ããäºã¤ã®æ¹éã§æ¸ãç´ãã¦ã¿ãã class Mover2{ int x; public Mover(int x){ this.x = x; } public Mover2 move(){ this.x++; return this; } public int getX(){ return t
KEMURIããã¥ã¼ãªã³ã°å®å ¨ã«ããããã«ã¯ã©ãããããããããããã¯ã©ãããã°ãã¥ã¼ãªã³ã°å®å ¨æ§ãå¤å®ã§ããã®ãããã³ããæ¢ãã¦ããããC++ãã³ãã¬ã¼ãã¯ãã¥ã¼ãªã³ã°å®å ¨ã ãã¼ãã¨ããè«æã«ãã©ãçããã C++ Templates are Turing Completeï¼PDFï¼ Boost::MPL ã¿ãããªãã®ãå®ç¾ã§ãããããããã®å¯è½æ§ã¯æãã¦ãããã©ãã£ã±ããï¼ï¼ä½ãããã¥ã¼ãªã³ã°å®å ¨ã ã¨ãããããããã¥ã¼ãªã³ã°æ©æ¢°ã®åæ¢å¤å®åé¡ããããããã§ãC++ã¯ãã®åé¡ãé¿ããããã«ãè¨èªä»æ§ã§ã¯æä½17åã®å帰ã¾ã§ããä¿è¨¼ããªããã¨ã«ãã¦ããããªã®ã§ãå³å¯ã«ã¯ãã¥ã¼ãªã³ã°å®å ¨ã§ã¯ãªãã¨ããããããç¡å¶éã¨ä»®å®ãã¦ããã®ããã½ãããã¦ããã³ãã¬ã¼ãããã¥ã¼ãªã³ã°å®å ¨ãªãã°ãï¼ãã³ãã¬ã¼ãã使ã£ãï¼C++ããã°ã©ã ã¯ã³ã³ãã¤ã«ã§ãããã©ããå¤å®ããäºãä¸è¬çã«ã§ããªããªã*1ã æ¨å¹´
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}