diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-01 22:50:55 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-01 22:50:55 -0500 |
| commit | 9528bb145193159fa3e697da642e32a0877af5fb (patch) | |
| tree | 3375b4524d7c845ec33c7636fb7697ce3c1d6a42 /js/types.js | |
| parent | 950e3c765e30648de34cfc4f65fffdce06f0727f (diff) | |
| download | mal-9528bb145193159fa3e697da642e32a0877af5fb.tar.gz mal-9528bb145193159fa3e697da642e32a0877af5fb.zip | |
All: pass stepA tests, in particular with correct conj behavior.
Diffstat (limited to 'js/types.js')
| -rw-r--r-- | js/types.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/js/types.js b/js/types.js index 062b0dd..18fad0a 100644 --- a/js/types.js +++ b/js/types.js @@ -2,6 +2,9 @@ var types = {}; if (typeof module === 'undefined') { var exports = types; +} else { + // map output/print to console.log + var print = exports.print = function () { console.log.apply(console, arguments); }; } // General utility functions @@ -112,13 +115,13 @@ function str() { } function prn() { - console.log.apply(console, Array.prototype.map.call(arguments,function(exp) { + print.apply({}, Array.prototype.map.call(arguments,function(exp) { return _pr_str(exp, true); })); } function println() { - console.log.apply(console, Array.prototype.map.call(arguments,function(exp) { + print.apply({}, Array.prototype.map.call(arguments,function(exp) { return _pr_str(exp, false); })); } @@ -325,7 +328,13 @@ function concat(lst) { } function conj(lst) { - return lst.concat(Array.prototype.slice.call(arguments, 1)); + if (list_Q(lst)) { + return Array.prototype.slice.call(arguments, 1).reverse().concat(lst); + } else { + var v = lst.concat(Array.prototype.slice.call(arguments, 1)); + v.__isvector__ = true; + return v; + } } function first(lst) { return lst[0]; } |
