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
/** | |
* Features of bound functions. | |
* | |
* See: http://dmitrysoshnikov.com/notes/note-1-ecmascript-bound-functions/ | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT Style License | |
*/ | |
var F = function () {}; |
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
/** | |
* The simplest processes (cooperative tasks) with Scheduler | |
* (sort of Erlang's processes but without messages yet) | |
* See: http://www.dabeaz.com/coroutines/index.html | |
* | |
* Deps: JS 1.7 with generators (yield) | |
* | |
* This version uses "trampolining" technique to request | |
* data from other processes in synchronous manner. | |
* See also: https://gist.github.com/1127536 (without "trampolining") |
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
/** | |
* The simplest processes (cooperative tasks) with Scheduler | |
* (sort of Erlang's processes but without messages yet) | |
* See also: http://www.dabeaz.com/coroutines/index.html | |
* | |
* Deps: JS 1.7 with generators (yield) | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT Style License | |
*/ |
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
<html> | |
<head> | |
<title>Process</title> | |
<style type="text/css"> | |
#p-0 {color: green;} | |
#p-1 {color: blue;} | |
.p { | |
float: left; | |
width: 300px; | |
border: 1px solid #CCC; |
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
/** | |
* Manual negative indicies for arrays in ES5: | |
* usually we use in such cases only first three | |
* negative indices, so these are enough (you may | |
* add -4, -5, etc. if needed). | |
* | |
* See also the implementation with proxies: | |
* https://github.com/DmitrySoshnikov/es-laboratory/blob/master/src/array-negative-indices.js | |
* | |
* by Dmitry Soshnikov <[email protected]> |
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
// by Dmitry Soshnikov <[email protected]> | |
// MIT Style License | |
*Classification of classes:* | |
============================================================================= | |
| Dynamic | Static | |
----------------------------------------------------------------------------- | |
| | | |
| Coffee, Python, Ruby, | SmallTalk, built-in |
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
$coroutine = (func) -> -> | |
gen = func(arguments...) | |
gen.next() | |
gen | |
grep = $coroutine (pattern) -> | |
console.log "Looking for #{pattern}" | |
while true | |
line = yield | |
if line.indexOf pattern != -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
main([]) -> | |
%% Given the parsed HTML tree in the following format: | |
%% | |
%% Types HTML = [Element] | |
%% Element = {Tag, [Attribute], [Element | Text]} | |
%% Tag = atom() % e.g. 'a', 'pre', 'p' | |
%% Attribute = {Name, Value} | |
%% Name = atom() | |
%% Value = string() |
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
main(_Arg) -> | |
HTML = {p, [{text, "test"}, {class, "bold"}], [ | |
{span, [{text, "value"}, {class, "bold"}], [ | |
{span, [{text, "hi"}, {class, "bold"}], []} | |
]} | |
]}, | |
Texts = get_text(HTML, []), | |
% ["value","test"] |
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
/** | |
* Test for module imports | |
* Tested in Narcissus | |
* by Dmitry Soshnikov | |
*/ | |
module M { | |
export var x = 10; | |
export var y = 20; | |
} |