This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-TW"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf8"> | |
| <style> | |
| html, body, div, span, applet, object, iframe, | |
| h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
| a, abbr, acronym, address, big, cite, code, | |
| del, dfn, em, img, ins, kbd, q, s, samp, | |
| small, strike, strong, sub, sup, tt, var, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $units = array(3, 8, 4, 5); | |
| $cn = 0; | |
| $units = array_map(function($a) use(&$cn) { | |
| $cn++; | |
| return array($a, $cn); | |
| }, $units); | |
| $first = array_shift($units); | |
| $s = array_reduce($units, function($res, $item) { | |
| return $res." UNION SELECT ".$item[0].", ".$item[1]." "; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = function(le, cb, payload) { | |
| var count = 0; | |
| this.getRecurser = function() { | |
| return (function(f) { | |
| return f(f); | |
| })(function(f) { | |
| count++; | |
| return le(function() { | |
| var args = Array.prototype.slice.call(arguments, 0); | |
| return f(f).apply(f, args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <script src="https://traceur-compiler.googlecode.com/git/bin/traceur.js" | |
| type="text/javascript"></script> | |
| <script src="https://traceur-compiler.googlecode.com/git/src/bootstrap.js" | |
| type="text/javascript"></script> | |
| <script> | |
| traceur.options.experimental = true; | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function * gen() { | |
| console.log('start'); | |
| yield "called"; | |
| } | |
| var g = gen(); | |
| //nothing happened | |
| var a = g.next(); | |
| //顯示start | |
| console.log(a.value); | |
| //顯示called |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function * gen() { | |
| console.log('start'); | |
| var got = yield 'called'; | |
| console.log(got); | |
| } | |
| var g = gen(); | |
| var a = g.next(); | |
| //顯示start | |
| var b = g.next('hello generator'); | |
| //顯示hello generator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function * gen(){} | |
| var g = gen(); | |
| g.throw('got an error.'); | |
| //拋出一個例外,錯誤訊息是 'got an error.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function * serial() { | |
| var c = 0; | |
| while(true) { | |
| yield c; | |
| c++; | |
| } | |
| } | |
| var s = serial(); | |
| console.log(s.next().value); | |
| //顯示 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function * gen() { | |
| var c = 0; | |
| while(true) { | |
| yield c; | |
| c++; | |
| } | |
| } | |
| function run() { | |
| var g = gen(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| co(withYield); | |
| withoutYield(); | |
| function timeout(sec) { | |
| return function(notify) { | |
| setTimeout(function() { | |
| notify(null, new Date().getTime()); | |
| }, sec*1000); | |
| }; | |
| } | |
| function co(gen) { |