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
| // Class sugar | |
| var Class = (function () { | |
| 'use strict'; | |
| // Base class | |
| function Class() { | |
| throw new Error('Cannot instantiate `Class`.'); | |
| } |
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
| class FooA { | |
| public: | |
| int a; | |
| } | |
| class FooB : public FooA { | |
| public: | |
| int b; | |
| } |
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
| #include <iostream> | |
| #include <functional> | |
| #include <memory> | |
| using namespace std; | |
| std::function<void()> createCounter() { | |
| std::shared_ptr<int> count(new int(0)); | |
| return [count](){ | |
| (*count) += 1; | |
| cout << "count = " << (*count) << "\n"; |
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
| var sample_set = (function () { | |
| 'use strict'; | |
| var sample_set = []; | |
| function generateSample(not_recursive) { | |
| var overhead_usage = Math.random() * 2 + 5, | |
| game_usage = Math.random() * 2 + 3, | |
| idle_usage = Math.random(), | |
| games = Math.floor(Math.random() * 30) + 10, |
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
| fnMaker = (name) => (args...) => [name, args] | |
| what = fnMaker 'what' | |
| the = fnMaker 'the' | |
| fuck = 'fuck' | |
| _is = fnMaker 'is' | |
| going = fnMaker 'going' | |
| to = 'to' | |
| happen = 'happen' |
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
| #ifndef __signals_h__ | |
| #define __signals_h__ | |
| #include <list> | |
| #include <memory> | |
| #include <iostream> | |
| #include <functional> | |
| namespace signals { | |
| template<typename... Values> class Signal { |
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
| # named functions | |
| def HelloWorld(str, fn, str2): | |
| pass | |
| # single statement anonymous function | |
| helloWorld('foo', lambda x, y: foo(x, y), 'bar') | |
| # multi statement anonymous functions | |
| helloWorld('foo', (lambda x, y: | |
| arbitraryMulti(x) |
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
| import timeit | |
| print 'Lambda: %f' % timeit.Timer('fn = lambda x: x * x\n' | |
| 'map(fn, xrange(10))', 'gc.enable()').timeit() | |
| print 'Named function: %f' % timeit.Timer('def fn(x): return x * x;\n' | |
| 'map(fn, xrange(10))', 'gc.enable()').timeit() |
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
| /* | |
| !.* | |
| .gitignore |
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
| #include <iostream> | |
| using namespace std; | |
| class Foo { | |
| public: | |
| int a; | |
| Foo(int a) : a(a) { | |
| } | |
| virtual void print() { | |
| cout << " I am Foo: " << a << "\n"; |