JavaScript Collection & Copy - String#succãMochiKit(âã¯â)ï¼motemenã®æ¥è¨ - String#succ x 10 ã¤ã¥ã motemenããã®ã³ã¼ããããããªãã£ãã®ã§ãå³ã«ãã¦èãã¾ããã function iterate (f, s) { return chain([s], { next: function() { return s = f(s) } }) } function right(a, b) { return b } var last = partial(reduce, right); last(islice(iterate(succ, 'A'), 4)); // => "D" ã¾ããchainã¯ã¤ãã¬ã¼ã¿ã¼ããã£ã¤ããé¢æ°ã§ããchain(range(2), range(3))ã¯ã0,1,0,1,2 ã¨ãããããªä¸
MochiKit.Iterã®ãµã³ãã«ã³ã¼ããèªã MochiKit.Iterã®ããã¥ã¡ã³ãã®ãµã³ãã«ã³ã¼ããããã©ãã©ã«ãã¦è¦ã¦ããã¾ãã 以ä¸ã¯2ã®åæ°ãã¤ãã10æªæºã®éç¹°ãè¿ããåç®ããã³ã¼ãã§ãã theSum = sum(takewhile( partial(operator.gt, 10), imap( partial(operator.mul, 2), count() ) )); ok( theSum == (0 + 2 + 4 + 6 + 8) ); operator operatorã¯åç´æ¼ç®é¢æ°ç¾¤ãä¿æãããªãã¸ã§ã¯ãã§ãã gt(a, b)ã¯ãa > bãè¡ãçå½å¤ãè¿ãã¾ãã mul(a, b)ã¯ãa * bãè¡ãªãçµæå¤ãè¿ãã¾ãã ok(operator.gt(1, 10) == false); ok(operator.gt(10, 1) == true);
JavaScriptã«ãããç¹°ãè¿ã 翻訳 åæï¼from __future__ import * >> Iteration in JavaScript èè ï¼Bob Ippolito JavaScriptã«ã¯ãåºæ¬çã¯2種é¡ã®ãªãã¸ã§ã¯ãã®ç¹°ãè¿ããããã ãã¹ã¦ã®ãªãã¸ã§ã¯ãã¯ããããã£ã®åæããµãã¼ããã¦ããã for (var propName in someObject) { var value = someObject[propName]; } "Arrayãããã³ã«"ããµãã¼ããããªãã¸ã§ã¯ããããã for (var i=0; i<someObject.length; i++) { var value = someObject[i]; } ã©ã£ã¡ããã²ã©ãã ããããã£ã®åæã¯ãããã°ããããã使ãéããªããä½æ ãªããåæã®ä¸ã§ã¯èå³ã®ãªãããããã£ã«ããããééããããã«
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}