A functional compile-to-JS language for writing beautiful command-line interfaces.
- Functional (closures, first-class functions, purity)
| # Algorithm W (Damas-Hindley-Milner) in LiveScript. | |
| # By Paul Miller (paulmillr.com), Public domain. | |
| # | |
| # Based on Robert Smallshire's [Python code](http://bit.ly/bbVmmX). | |
| # Which is based on Andrew's [Scala code](http://bit.ly/aztXwD). | |
| # Which is based on Nikita Borisov's [Perl code](http://bit.ly/myq3uA). | |
| # Which is based on Luca Cardelli's [Modula-2 code](http://bit.ly/Hjpvb). | |
| # Something like that. | |
| prelude = require './prelude' |
| function attributes(xs, name) { | |
| return is_element(xs)? xs.getAttribute(name) | |
| : is_array(xs)? xs.map(attributes) | |
| : is_sequence(xs)? map(xs, attributes) | |
| : /* otherwise */ raise(TypeError('Not supported.')) | |
| } | |
| // vs | |
| function attributes(xs, name) { |
| [ | |
| a: 1 | |
| , b: 2 | |
| , c: 3 | |
| ] | |
| [ a: 1 | |
| , b: 2 | |
| , c: 3 | |
| ] |