public
Description: Functional is a library for functional programming in JavaScript. It defines the standard higher-order functions such as map, reduce (aka foldl), and select (aka filter). It also defines functions such as curry, rcurry, and partial for partial function application; and compose, guard, and until for function-level programming.
Homepage: http://osteele.com/sources/javascript/functional/
Clone URL: git://github.com/osteele/functional-javascript.git
100644 46 lines (41 sloc) 1.482 kb
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
/* Copyright 2007-2008 by Oliver Steele. Available under the MIT License. */
 
$(function() {
    new DocViewer({api:['functional.js', 'to-function.js'],
                   examples:'examples.js',
                   onLoad:loaded});
    function loaded() {
        var evaluator = new Evaluator('#evaluator', {onUpdate: showEvaluator});
        ieMode();
        if (navigator.appName != 'Microsoft Internet Explorer')
            $('#header pre').each(function() {
                this.innerHTML = OSUtils.unindent(this.innerHTML);
            });
        $('#evaluator').show();
        resetGradients();
        $(window).resize(scheduleGradientReset);
        $('.example kbd').click(function() { evaluator.eval(this) });
        $('.protodoc kbd').click(function() {
            var value = evaluator.eval(this);
            typeof value == 'undefined' ||
                $.scrollTo($('#evaluator'), {speed:1000});
        });
    }
});
 
function showEvaluator() {
    $('header').show()
    resetGradients();
}
 
function ieMode() {
    if (navigator.appName != 'Microsoft Internet Explorer') return;
    window.resetGradient = Functional.I;
    var e = $('ie-warning');
    e.show();
    $('#ie-warning .close').click(function() {this.hide});
}
 
// Emulate enough of Prototype for the example to work
var Event = {
    observe: function(elt, handlerName, handler) {
        var e = $(typeof elt == 'string' ? '#' + elt : elt);
        e[handlerName].call(e, handler);
    }
}