From 4a8c7c9f0f6154cbf67d83f0c9e80d5fc333ea94 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Mar 2021 13:56:30 +0100 Subject: [PATCH] version 1.0.0-beta.12 --- Makefile | 4 ++-- README.md | 12 ++++++------ dist/lips.js | 14 +++++++------- dist/lips.min.js | 6 +++--- package.json | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 8e2834e1c..28f599d1b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: publish test coveralls lint zero -VERSION=1.0.0-beta.11 -VERSION_DASH=`echo -n "1.0.0-beta.11" | sed "s/-/%E2%80%93/"` +VERSION=1.0.0-beta.12 +VERSION_DASH=`echo -n "1.0.0-beta.12" | sed "s/-/%E2%80%93/"` BRANCH=`git branch | grep '^*' | sed 's/* //'` DATE=`date -uR` YEAR=`date +%Y` diff --git a/README.md b/README.md index 01077d6df..5023bcde6 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/devel/assets/lips.svg?raw=true) +![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/master/assets/lips.svg?raw=true) -[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) +[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.12-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) ![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete) -[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a2ecde1c90338410808edb4f6f18383b2f90a393)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&1d824f61301ea2d85162361f0502128a)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=master&cf80fc447f81ce5a85d1c3958a88636a5c707b84)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&1d824f61301ea2d85162361f0502128a)](https://coveralls.io/github/jcubic/lips?branch=master) [![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips) [![GitHub license](https://img.shields.io/github/license/jcubic/lips.svg)](https://github.com/jcubic/lips/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/jcubic/lips.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/jcubic/lips/stargazers/) - Tweet + Tweet ![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips) ![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips) @@ -143,7 +143,7 @@ npm install -g @jcubic/lips@beta you can run the interpreter from the terminal: -![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/devel/assets/screencast.gif?raw=true) +![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/master/assets/screencast.gif?raw=true) You can also run code in a string with: diff --git a/dist/lips.js b/dist/lips.js index c10c14937..416bcedf1 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -4,7 +4,7 @@ * | | \ \ | | | || . \/ __> | | * | | > \ | |_ | || _/\__ \ | | * | | / ^ \ |___||_||_| <___/ | | - * \_\ /_/ \_\ /_/ v. DEV + * \_\ /_/ \_\ /_/ v. 1.0.0-beta.12 * * LIPS is Pretty Simple - Scheme based Powerful LISP in JavaScript * @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Mar 2021 12:52:41 +0000 + * build: Tue, 16 Mar 2021 12:53:59 +0000 */ (function () { 'use strict'; @@ -13790,10 +13790,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 16 Mar 2021 12:52:41 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Mar 2021 12:53:59 +0000' == '{{' + 'DATE}}'; can be removed // but disablig Tree-shaking is adding lot of not used code so we use this // hack instead - var date = LString('Tue, 16 Mar 2021 12:52:41 +0000').valueOf(); + var date = LString('Tue, 16 Mar 2021 12:53:59 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13805,7 +13805,7 @@ var _build = [_year, _format(_date.getMonth() + 1), _format(_date.getDate())].join('-'); - var banner = "\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(_build, ") \nCopyright (c) 2018-").concat(_year, " Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables.\nYou can also use (help name) to display help for specic function or macro and\n(apropos name) to display list of matched names in environment.\n").replace(/^.*\n/, ''); + var banner = "\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.12 (".concat(_build, ") \nCopyright (c) 2018-").concat(_year, " Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables.\nYou can also use (help name) to display help for specic function or macro and\n(apropos name) to display list of matched names in environment.\n").replace(/^.*\n/, ''); return banner; }(); // ------------------------------------------------------------------------- // to be used with string function when code is minified @@ -13831,9 +13831,9 @@ QuotedPromise.__class__ = 'promise'; // ------------------------------------------------------------------------- var lips = { - version: 'DEV', + version: '1.0.0-beta.12', banner: banner, - date: 'Tue, 16 Mar 2021 12:52:41 +0000', + date: 'Tue, 16 Mar 2021 12:53:59 +0000', exec: exec, // unwrap async generator into Promise parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 8c545cf76..850626012 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -4,7 +4,7 @@ * | | \ \ | | | || . \/ __> | | * | | > \ | |_ | || _/\__ \ | | * | | / ^ \ |___||_||_| <___/ | | - * \_\ /_/ \_\ /_/ v. DEV + * \_\ /_/ \_\ /_/ v. 1.0.0-beta.12 * * LIPS is Pretty Simple - Scheme based Powerful LISP in JavaScript * @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Mar 2021 12:52:41 +0000 + * build: Tue, 16 Mar 2021 12:53:59 +0000 */ -(function(){"use strict";function _readOnlyError(e){throw new Error('"'+e+'" is read-only')}var readOnlyError=_readOnlyError;function createCommonjsModule(e,r){return r={exports:{}},e(r,r.exports),r.exports}var setPrototypeOf=createCommonjsModule(function(t){function n(e,r){t.exports=n=Object.setPrototypeOf||function e(r,t){r.__proto__=t;return r};return n(e,r)}t.exports=n});function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true}catch(e){return false}}var isNativeReflectConstruct=_isNativeReflectConstruct;var construct=createCommonjsModule(function(n){function i(e,r,t){if(isNativeReflectConstruct()){n.exports=i=Reflect.construct}else{n.exports=i=function e(r,t,n){var i=[null];i.push.apply(i,t);var a=Function.bind.apply(r,i);var u=new a;if(n)setPrototypeOf(u,n.prototype);return u}}return i.apply(null,arguments)}n.exports=i});function _arrayWithHoles(e){if(Array.isArray(e))return e}var arrayWithHoles=_arrayWithHoles;function _iterableToArray(e){if(typeof Symbol!=="undefined"&&Symbol.iterator in Object(e))return Array.from(e)}var iterableToArray=_iterableToArray;function _arrayLikeToArray(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t=0;--r){var i=this.tryEntries[r];var a=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e){this.complete(t.completion,t.afterLoc);S(t);return m}}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if(n.type==="throw"){var i=n.arg;S(t)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){this.delegate={iterator:C(e),resultName:r,nextLoc:t};if(this.method==="next"){this.arg=c}return m}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,t,n,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){t(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(n,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,t){var n=o.apply(e,u);function i(e){asyncGeneratorStep(n,r,t,i,a,"next",e)}function a(e){asyncGeneratorStep(n,r,t,i,a,"throw",e)}i(undefined)})}}var asyncToGenerator=_asyncToGenerator;function _classCallCheck(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var classCallCheck=_classCallCheck;function _defineProperties(e,r){for(var t=0;t=0)continue;t[i]=e[i]}return t}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var t=objectWithoutPropertiesLoose(e,r);var n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var t=[];var n=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){t.push(o.value);if(r&&t.length===r)break}}catch(e){i=true;a=e}finally{try{if(!n&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return t}var iterableToArrayLimit=_iterableToArrayLimit;function _slicedToArray(e,r){return arrayWithHoles(e)||iterableToArrayLimit(e,r)||unsupportedIterableToArray(e,r)||nonIterableRest()}var slicedToArray=_slicedToArray;var _typeof_1=createCommonjsModule(function(r){function t(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=t=function e(r){return typeof r}}else{r.exports=t=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return t(e)}r.exports=t});function _asyncIterator(e){var r;if(typeof Symbol!=="undefined"){if(Symbol.asyncIterator){r=e[Symbol.asyncIterator];if(r!=null)return r.call(e)}if(Symbol.iterator){r=e[Symbol.iterator];if(r!=null)return r.call(e)}}throw new TypeError("Object is not async iterable")}var asyncIterator=_asyncIterator;function _AwaitValue(e){this.wrapped=e}var AwaitValue=_AwaitValue;function _awaitAsyncGenerator(e){return new AwaitValue(e)}var awaitAsyncGenerator=_awaitAsyncGenerator;function AsyncGenerator(a){var u,o;function e(n,i){return new Promise(function(e,r){var t={key:n,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=t}else{u=o=t;c(n,i)}})}function c(r,e){try{var t=a[r](e);var n=t.value;var i=n instanceof AwaitValue;Promise.resolve(i?n.wrapped:n).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(t.done?"return":"normal",e)},function(e){c("throw",e)})}catch(e){s("throw",e)}}function s(e,r){switch(e){case"return":u.resolve({value:r,done:true});break;case"throw":u.reject(r);break;default:u.resolve({value:r,done:false});break}u=u.next;if(u){c(u.key,u.arg)}else{o=null}}this._invoke=e;if(typeof a["return"]!=="function"){this["return"]=undefined}}if(typeof Symbol==="function"&&Symbol.asyncIterator){AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}}AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)};AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e)};AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e)};var AsyncGenerator_1=AsyncGenerator;function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator_1(e.apply(this,arguments))}}var wrapAsyncGenerator=_wrapAsyncGenerator;function _createForOfIteratorHelper(r,e){var t;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(t=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(t)r=t;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=r.length)return{done:true};return{done:false,value:r[n++]}},e:function e(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=true,u=false,o;return{s:function e(){t=r[Symbol.iterator]()},n:function e(){var r=t.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&t["return"]!=null)t["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor)t=e.constructor.name;if(t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t1&&arguments[1]!==undefined$1?arguments[1]:null;var n=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(t===null||t instanceof RegExp&&t.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(n){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env&&user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.fetch=function(i,a){a=a||{};return new Promise(function(e,r){var t=new XMLHttpRequest;t.open(a.method||"get",i,true);for(var n in a.headers){t.setRequestHeader(n,a.headers[n])}t.withCredentials=a.credentials=="include";t.onload=function(){e(o())};t.onerror=r;t.send(a.body||null);function o(){var n=[],i=[],a={},u;t.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,t){n.push(r=r.toLowerCase());i.push([r,t]);u=a[r];a[r]=u?"".concat(u,",").concat(t):t});return{ok:(t.status/100|0)==2,status:t.status,statusText:t.statusText,url:t.responseURL,clone:o,text:function e(){return Promise.resolve(t.responseText)},json:function e(){return Promise.resolve(t.responseText).then(JSON.parse)},blob:function e(){return Promise.resolve(new Blob([t.response]))},headers:{keys:function e(){return n},entries:function e(){return i},get:function e(r){return a[r.toLowerCase()]},has:function e(r){return r.toLowerCase()in a}}}}})}}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,r){return"".concat(num_mnemicic_re(e),"[+-]?").concat(r,"+/").concat(r,"+")}function gen_complex_re(e,r){return"".concat(num_mnemicic_re(e),"(?:[+-]?(?:").concat(r,"+/").concat(r,"+|nan.0|inf.0|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function gen_integer_re(e,r){return"".concat(num_mnemicic_re(e),"[+-]?").concat(r,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var complex_float_stre="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var t=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(t,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+|[+-]?").concat(r,"+|[+-])i$"),"i")}var complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var r=slicedToArray(e,3),t=r[0],n=r[1],i=r[2];a[t]=make_complex_match_re(n,i)});return a}();var characters={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function ucs2decode(e){var r=[];var t=0;var n=e.length;while(t=55296&&i<=56319&&t1&&arguments[1]!==undefined$1?arguments[1]:10;var t=num_pre_parse(e);var n=t.number.split("/");var i=LRational({num:LNumber([n[0],t.radix||r]),denom:LNumber([n[1],t.radix||r])});if(t.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var t=num_pre_parse(e);if(t.inexact){return LFloat(parseInt(t.number,t.radix||r))}return LNumber([t.number,t.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var t;if(r){var n=parseInt(r[1],16);t=String.fromCodePoint(n)}else{r=e.match(/#\\(.+)$/);if(r){t=r[1]}}if(t){return LCharacter(t)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;function r(e){var r;if(e==="+"){r=LNumber(1)}else if(e==="-"){r=LNumber(-1)}else if(e.match(int_bare_re)){r=LNumber([e,i])}else if(e.match(rational_bare_re)){var t=e.split("/");r=LRational({num:LNumber([t[0],i]),denom:LNumber([t[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(r.valueOf())}return r}var a=num_pre_parse(e);i=a.radix||i;var t;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){t=n}else{t=a.number.match(complex_list_re[i])}var u,o;o=r(t[2]);if(t[1]){u=r(t[1])}else{u=LNumber(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return u}return LComplex({im:o,re:u})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(e){var r=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(r){var t=parseInt(r[4],10);var n;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}t=LFloat(t);if(r.exact){return t.toRational()}return t}function parse_string(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,r){return"\\u"+r.padStart(4,"0")}).replace(/\n/g,"\\n");var r=e.match(/(\\*)(\\x[0-9A-F])/i);if(r&&r[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(r[2]))}try{return LString(JSON.parse(e))}catch(e){throw new Error("Invalid string literal")}}function parse_symbol(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var t={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,r){return String.fromCharCode(parseInt("0"+r,16))}).replace(/\\(.)/g,function(e,r){return t[r]||r})}return new LSymbol(e)}function parse_argument(e){var r=e.match(re_re);if(r){return new RegExp(r[1],r[2])}else if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e.match(char_re)){return parse_character(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}else if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e==="nil"){return nil}else if(["+nan.0","-nan.0"].includes(e)){return LNumber(NaN)}else if(["true","#t","#true"].includes(e)){return true}else if(["false","#f","#false"].includes(e)){return false}else if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant")}else{var t=e.match(/#\\(.+)/);if(t&&ucs2decode(t[1]).length===1){return parse_character(e)}return parse_symbol(e)}}function is_symbol_string(e){return!(["(",")","[","]"].includes(e)||e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var r=/([-\\^$[\]()+{}?*.|])/g;return e.replace(r,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};Stack.prototype.top=function(){return this.data[this.data.length-1]};Stack.prototype.pop=function(){return this.data.pop()};Stack.prototype.is_empty=function(){return!this.data.length};function tokens(e){if(e instanceof LString){e=e.valueOf()}var r=new Lexer(e,{whitespace:true});var t=[];while(true){var n=r.peek(true);if(n===eof){break}t.push(n);r.skip()}return t}function multiline_formatter(e){var r=e.token,t=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(n,"")}return _objectSpread({token:r},t)}function Thunk(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:function(){};this.fn=e;this.cont=r}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var t=tokens(e).map(function(e){if(e.token==="#\\ "){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return strip_s_comments(t)}}function strip_s_comments(e){var r=0;var t=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined$1?arguments[0]:null;if(e instanceof LSymbol){e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return new LSymbol(Symbol("#:".concat(e)))}r++;return new LSymbol(Symbol("#:g".concat(r)))}}();function QuotedPromise(e){var t=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined$1,type:undefined$1};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(r){Object.defineProperty(t,"__".concat(r,"__"),{enumerable:true,get:function e(){return n[r]}})});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};QuotedPromise.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};QuotedPromise.prototype.toString=function(){if(this.__pending__){return QuotedPromise.pending_str}if(this.__rejected__){return QuotedPromise.rejected_str}return"#")};QuotedPromise.pending_str="#";QuotedPromise.rejected_str="#";var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this._specials)},type:function e(r){return this.get(r).type},get:function e(r){return this._specials[r]},off:function e(r){var t=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return t.off(e,n)})}else if(n===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==n})}},on:function e(r,t){var n=this;if(Array.isArray(r)){r.forEach(function(e){return n.on(e,t)})}else if(!this._events[r]){this._events[r]=[t]}else{this._events[r].push(t)}},trigger:function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i",new LSymbol("quote-promise"),specials.LITERAL]];Object.defineProperty(specials,"builtin",{writable:false,value:defined_specials.map(function(e){return e[0]})});defined_specials.forEach(function(e){var r=slicedToArray(e,3),t=r[0],n=r[1],i=r[2];specials.append(t,n,i)});var Lexer=function(){function p(e){var r=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=t.whitespace,i=n===void 0?false:n;classCallCheck(this,p);Object.defineProperty(this,"__input__",{value:e.replace(/\r/g,""),enumerable:true});var a={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(t){Object.defineProperty(r,t,{configurable:false,enumerable:false,get:function e(){return a[t]},set:function e(r){a[t]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(p,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,t){this.__internal[r]=t}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var t=this._line;if(this._whitespace&&this._token==="\n"){--t}return{token:this._token,col:this._col,offset:this._i,line:t}}return this._token}},{key:"peek",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(this._i>=this.__input__.length){return eof}if(this._token){return this.token(r)}var t=this.next_token();if(t){this._token=this.__input__.substring(this._i,this._next);return this.token(r)}return eof}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var r=this.__input__.length;if(this._i>=r){return eof}for(var t=this._i;t=t){return eof}if(r+this._i>=t){return this.read_rest()}var n=this._i+r;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(this.__input__[this._i])}},{key:"read_char",value:function e(){var r=this.peek_char();this.skip_char();return r}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined$1?arguments[1]:{},n=t.prev_char,i=t["char"],a=t.next_char;var u=slicedToArray(r,4),o=u[0],c=u[1],s=u[2],l=u[3];if(r.length!==5){throw new Error("Lexer: Invald rule of length ".concat(r.length))}if(!i.match(o)){return false}if(!match_or_null(c,n)){return false}if(!match_or_null(s,a)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var r=true;e:for(var t=this._i,n=this.__input__.length;t2&&arguments[2]!==undefined$1?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;if(r.length===0){throw new Error("Lexer: invalid literal rule")}if(r.length===1){return[[r,n,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.env,n=r.meta,i=n===void 0?false:n,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",u,{hidden:true});read_only(this,"_meta",i,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",t)}createClass(o,[{key:"resolve",value:function e(r){return this.__env__&&this.__env__.get(r,{throwError:false})}},{key:"peek",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=this.__lexer__.peek(true);if(!(t===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(t.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(t.token==="#;")){r.next=14;break}this.skip();if(!(this.__lexer__.peek()===eof)){r.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:r.next=13;return this.read_object();case 13:return r.abrupt("continue",0);case 14:return r.abrupt("break",17);case 17:t=this._formatter(t);if(!this._meta){r.next=20;break}return r.abrupt("return",t);case 20:return r.abrupt("return",t.token);case 21:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"is_special",value:function e(r){return specials.names().includes(r)}},{key:"is_builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:t=r.sent;this.skip();return r.abrupt("return",t);case 5:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"is_open",value:function e(r){return["(","["].includes(r)}},{key:"is_close",value:function e(r){return[")","]"].includes(r)}},{key:"read_list",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=nil,n=t;case 1:r.next=4;return this.peek();case 4:i=r.sent;if(!(i===eof)){r.next=7;break}return r.abrupt("break",27);case 7:if(!this.is_close(i)){r.next=10;break}this.skip();return r.abrupt("break",27);case 10:if(!(i==="."&&t!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:n.cdr=r.sent;r.next=25;break;case 17:r.t0=Pair;r.next=20;return this.read_object();case 20:r.t1=r.sent;r.t2=nil;a=new r.t0(r.t1,r.t2);if(t===nil){t=a}else{n.cdr=a}n=a;case 25:r.next=1;break;case 27:return r.abrupt("return",t);case 28:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"read_value",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:t=r.sent;if(!(t===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(t));case 6:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"is_comment",value:function e(r){return r.match(/^;/)||r.match(/^#\|/)&&r.match(/\|#$/)}},{key:"evaluate",value:function e(r){return _evaluate(r,{env:this.__env__,error:function e(r){throw r}})}},{key:"read_object",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u,o,c;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:t=r.sent;if(!(t===eof)){r.next=5;break}return r.abrupt("return",t);case 5:if(!this.is_special(t)){r.next=35;break}n=specials.get(t);i=this.is_builtin(t);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(t)){r.next=19;break}return r.abrupt("return",o.call(this.__env__,u));case 19:if(!(u instanceof Pair)){r.next=21;break}return r.abrupt("return",o.apply(this.__env__,u.to_array(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(n.symbol));case 22:if(is_literal(t)){a=new Pair(n.symbol,new Pair(u,nil))}else{a=new Pair(n.symbol,u)}if(!i){r.next=25;break}return r.abrupt("return",a);case 25:if(!(o instanceof Macro)){r.next=34;break}r.next=28;return this.evaluate(a);case 28:c=r.sent;if(!(c instanceof Pair||c instanceof LSymbol)){r.next=31;break}return r.abrupt("return",Pair.fromArray([LSymbol("quote"),c]));case 31:return r.abrupt("return",c);case 34:throw new Error("Parser: invlid parser extension: ".concat(n.symbol));case 35:if(!this.is_open(t)){r.next=42;break}this.skip();r.next=39;return this.read_list();case 39:return r.abrupt("return",r.sent);case 42:r.next=44;return this.read_value();case 44:return r.abrupt("return",r.sent);case 45:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()}]);return o}();function parse(e,r){return _parse.apply(this,arguments)}function _parse(){_parse=wrapAsyncGenerator(regenerator.mark(function e(t,n){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(t,{env:n});case 2:r.next=5;return awaitAsyncGenerator(i.read_object());case 5:a=r.sent;if(!(a===eof)){r.next=8;break}return r.abrupt("break",12);case 8:r.next=10;return a;case 10:r.next=2;break;case 12:case"end":return r.stop()}}},e)}));return _parse.apply(this,arguments)}function unpromise(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:function(e){return e};var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var n=r.filter(is_promise);if(n.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},t)}return e(r)}if(is_plain_object(r)){var i=Object.keys(r);var a=i.map(function(e){return r[e]});var u=a.filter(is_promise);if(u.length){return unpromise(Promise.all(a),function(e){var n={};e.forEach(function(e,r){var t=i[r];n[t]=e});if(Object.isFrozen(r)){Object.freeze(n)}return n},t)}}if(is_promise(r)){var o=r.then(e);if(t===null){return o}else{return o["catch"](t)}}return e(r)}function read_only(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,r,{value:t,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(t){var n,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=[];i=true;a=false;r.prev=3;o=asyncIterator(t);case 5:r.next=7;return o.next();case 7:c=r.sent;i=c.done;r.next=11;return c.value;case 11:s=r.sent;if(i){r.next=18;break}l=s;n.push(l);case 15:i=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);a=true;u=r.t0;case 24:r.prev=24;r.prev=25;if(!(!i&&o["return"]!=null)){r.next=29;break}r.next=29;return o["return"]();case 29:r.prev=29;if(!a){r.next=32;break}throw u;case 32:return r.finish(29);case 33:return r.finish(24);case 34:return r.abrupt("return",n);case 35:case"end":return r.stop()}}},e,null,[[3,20,24,34],[25,,29,33]])}));return _uniterate_async.apply(this,arguments)}function matcher(e,r){if(r instanceof RegExp){return function(e){return String(e).match(r)}}else if(is_function(r)){return r}}function doc(e,r,t,n){if(typeof e!=="string"){r=arguments[0];t=arguments[1];n=arguments[2];e=null}if(t){if(n){r.__doc__=t}else{r.__doc__=trim_lines(t)}}if(e){r.__name__=e}else if(r.name&&!r[__lambda__]){r.__name__=r.name}return r}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:1;var t=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&t>=0){var n=1;while(n>0){var i=e[--t];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}t--}return e.slice(t+1)}function lineIndent(e){if(!e||!e.length){return 0}var r=e.length;if(e[r-1].token==="\n"){return 0}while(--r){if(e[r].token==="\n"){var t=(e[r+1]||{}).token;if(t){return t.length}}}return 0}function match(e,r){return l(e,r)===r.length;function l(t,n){function e(e,r){var t=_createForOfIteratorHelper(e),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;var a=l(i,r);if(a!==-1){return a}}}catch(e){t.e(e)}finally{t.f()}return-1}function r(){return t[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[o])}function i(){var e=t[a+1];var r=n[o+1];if(e!==undefined$1&&r!==undefined$1){return l([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var s=l(t[a],n.slice(o));if(s===-1||s+o>n.length){return-1}o+=s-1;a++;continue}else{return-1}a++}if(t.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var t=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},t)}var n=r&&r.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},t),r),{},{exceptions:{specials:[].concat(toConsumableArray(t.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(t.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var t=tokenize(this.__code__,true);return this._indent(t,r)};Formatter.exception_shift=function(a,e){function r(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var r=e.filter(function(e){return e instanceof RegExp});if(!r.length){return false}var t=_createForOfIteratorHelper(r),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;if(a.match(i)){return true}}}catch(e){t.e(e)}finally{t.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var t=e.exceptions.shift;for(var n=0,i=Object.entries(t);n0){n.offset=0}if(a.toString()===r.toString()&&balanced(a)){return n.offset+a[0].col}else if(a.length===1){return n.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,n);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,n)}if(c!==-1){return n.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return n.offset+a[1].col}return n.offset+a[3].col}else if(a[0].line===a[1].line){return n.offset+n.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var glob=Symbol["for"]("*");var sexp_or_atom=new Pattern([p_o,glob,p_e],[not_p],"+");var sexp=new Pattern([p_o,glob,p_e],"+");var symbol=new Pattern([Symbol["for"]("symbol")],"?");var symbols=new Pattern([Symbol["for"]("symbol")],"*");var identifiers=[p_o,symbols,p_e];var let_value=new Pattern([p_o,Symbol["for"]("symbol"),glob,p_e],"+");var def_lambda_re=keywords_re("define","lambda","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define|let(?:\*|rec|-env|-syntax)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,r=new Array(e),t=0;t0&&!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(n),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],_=s[2];f=f.valueOf();var p=f>0?u[f]:a;var h=match(l,p.filter(function(e){return e.trim()}));var d=t.slice(i).find(function(e){return e.trim()});if(h&&(_ instanceof Ahead&&_.match(d)||!_)){if(!t[i-1].trim()){t[i-1]="\n"}else{t.splice(i,0,"\n");i++}continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=t.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=tokenize(t,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o0&&arguments[0]!==undefined$1?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var r=new Pair;n.set(e,r);if(t){r.car=i(e.car)}else{r.car=e.car}r.cdr=i(e.cdr);r[__cycles__]=e[__cycles__];return r}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var r=[];if(this.car instanceof Pair){if(e){r.push(this.car.to_array())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.to_array())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||t&&e instanceof Array&&e[__data__]){return e}if(r===false){var n=nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=toConsumableArray(e)}var a=nil;var u=e.length;while(u--){var o=e[u];if(o instanceof Array){o=Pair.fromArray(o,r,t)}else if(typeof o==="string"){o=LString(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=LNumber(o)}a=new Pair(o,a)}return a};Pair.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var t={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var n=r.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}t[i]=a;r=r.cdr}else{break}}return t};Pair.fromPairs=function(e){return e.reduce(function(e,r){return new Pair(new Pair(new LSymbol(r[0]),r[1]),e)},nil)};Pair.fromObject=function(r){var e=Object.keys(r).map(function(e){return[e,r[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var r=this;var t=nil;while(true){if(r!==nil){t=e(t,r.car);r=r.cdr}else{break}}return t};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var r=nil;while(e!==nil){var t=e.cdr;e.cdr=r;r=e;e=t}return r};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=n(e.car);if(r instanceof Pair){r=i(r)}var t=n(e.cdr);if(t instanceof Pair){t=i(t)}return new Pair(r,t)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===nil?nil:this.cdr.map(e))}else{return nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof_1(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(e[__lambda__]||e.__doc__)}function user_repr(t){var e=t.constructor||Object;var n=is_plain_object(t);var i=is_function(t[Symbol.asyncIterator])||is_function(t[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(t.constructor===r&&(r===Object&&n&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];str_mapping.set(t,n)});function symbolize(t){if(t&&_typeof_1(t)==="object"){var n={};var e=Object.getOwnPropertySymbols(t);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[r]=toString(t[e])});var r=Object.getOwnPropertyNames(t);r.forEach(function(e){var r=t[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){n[e]=symbolize(r)}else{n[e]=toString(r)}});return n}return t}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,r){return e.hasOwnProperty(r)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var t=r.__name__;if(LString.isString(t)){t=t.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,function(e,r){var t=r.quote,n=r.skip_cycles,i=r.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[t].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var t=r.quote;if(t){return e.toString()}return e.valueOf()}],[LString,function(e,r){var t=r.quote;e=e.toString();if(t){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];instances.set(t,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var n=e.constructor;if(instances.has(n)){for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var l=e.constructor;if(!l){l=Object}var f;if(typeof l.__class__==="string"){f=l.__class__}else{if(is_prototype(e)){return"#"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}f=l.name}if(type(e)==="instance"&&!is_native_function(l)){f="instance"}if(is_iterator(e,Symbol.iterator)){if(f){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#")}return"#"}if(f!==""){return"#<"+f+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof_1(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[__cycles__]&&this[__cycles__][e])};function markCycles(e){var r=[];var i=[];var a=[];function u(e){if(!r.includes(e)){r.push(e)}}function o(e,r,t,n){if(t instanceof Pair){if(n.includes(t)){if(!a.includes(t)){a.push(t)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=t;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,t){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);t.push(r);var n=o(r,"car",r.car,t);var i=o(r,"cdr",r.cdr,t);if(!n){c(r.car,t.slice())}if(!i){return new Thunk(function(){return e(r.cdr,t.slice())})}}});function t(e,r){if(e[__cycles__][r]instanceof Pair){var t=n.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(t,"#")}}c(e,[]);var n=r.filter(function(e){return a.includes(e)});n.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){t(e,"car");t(e,"cdr")})}var pair_to_string=function(){var f=function e(r,t){var n=[];if(r[__ref__]){n.push(r[__ref__]+"(")}else if(!t){n.push("(")}return n};var _=function e(r,t){if(is_debug());if(!t||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,t){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=n.nested,a=i===void 0?false:i,u=n.result,o=u===void 0?[]:u,c=n.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(_(r,a)))}:c;o.push.apply(o,toConsumableArray(f(r,a)));var l;if(r[__cycles__]&&r[__cycles__].car){l=r[__cycles__].car}else{l=toString(r.car,t,true,{result:o,cont:s})}if(l!==undefined$1){o.push(l)}return new Thunk(function(){if(r.cdr instanceof Pair){if(r[__cycles__]&&r[__cycles__].cdr){o.push(" . ");o.push(r[__cycles__].cdr)}else{if(r.cdr[__ref__]){o.push(" . ")}else{o.push(" ")}return e(r.cdr,t,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,t))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.nested,n=t===void 0?false:t;if(is_debug()){var i=[];pair_to_string(this,e,{result:i});return i.join("")}var a=[];if(this[__ref__]){a.push(this[__ref__]+"(")}else if(!n){a.push("(")}var u;if(this[__cycles__]&&this[__cycles__].car){u=this[__cycles__].car}else{u=toString(this.car,e,true)}if(u!==undefined$1){a.push(u)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){a.push(" . ");a.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){a.push(" . ")}else{a.push(" ")}var o=this.cdr.toString(e,{nested:true});a.push(o)}}else if(this.cdr!==nil){a=a.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){a.push(")")}return a.join("")};Pair.prototype.set=function(e,r){this[e]=r;if(r instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var r=this;if(r.car===undefined$1){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==nil){while(true){if(r instanceof Pair&&r.cdr!==nil){r=r.cdr}else{break}}r.cdr=e}return this};function abs(e){return e<0?-e:e}function seq_compare(e,r){var t=toArray(r),n=t[0],i=t.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(n,o)){return false}var c=i;var s=toArray(c);n=s[0];i=s.slice(1)}return true}function equal(e,r){if(is_function(e)){return is_function(r)&&unbind(e)===unbind(r)}else if(e instanceof LNumber){if(!(r instanceof LNumber)){return false}var t;if(e.__type__===r.__type__){if(e.__type__==="complex"){t=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{t=true}if(t&&e.cmp(r)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),r.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(r)}if(e===Number.NEGATIVE_INFINITY){return r===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return r===Number.POSITIVE_INFINITY}return equal(LNumber(e),LNumber(r))}else if(e instanceof LCharacter){if(!(r instanceof LCharacter)){return false}return e.__char__===r.__char__}else{return e===r}}function same_atom(e,r){if(type(e)!==type(r)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===r.source}if(e instanceof LString){return e.valueOf()===r.valueOf()}return equal(e,r)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,t,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,r)}typecheck("Macro",e,"string",1);typecheck("Macro",r,"function",2);if(t){if(n){this.__doc__=t}else{this.__doc__=trim_lines(t)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,t,n){var i=new Macro(e,r,t,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,t){var n=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:t};var o=this.__fn__.call(n,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var t=asyncToGenerator(regenerator.mark(function e(t,h){var n,d,i;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=function e(){i=asyncToGenerator(regenerator.mark(function e(t,n,i){var a,u,o,c,s,l,f,_,p;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(t instanceof Pair&&t.car instanceof LSymbol)){r.next=26;break}if(!t[__data__]){r.next=3;break}return r.abrupt("return",t);case 3:a=i.get(t.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?t:t.cdr;r.next=8;return a.invoke(u,_objectSpread(_objectSpread({},h),{},{env:i}),true);case 8:o=r.sent;if(!(a instanceof Syntax)){r.next=17;break}c=o,s=c.expr,l=c.scope;if(!(s instanceof Pair)){r.next=16;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var t=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=t.expansion,F=t.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:false;A({code:r&&toString(r,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,r)}if(e instanceof LSymbol&&D.includes(e.valueOf())){var i=x.ref(r);if(LSymbol.is(r,e)){if(typeof i==="undefined"){return true}return i===F||i===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,w)){A(">> 0");if(r===nil){A({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,w)){var a=e.car.car.valueOf();var u=e.last_pair();if(LSymbol.is(u.car,w)){L["..."].symbols[a]=null;return true}else{return false}}var o=e.car.car.valueOf();if(L["..."].symbols[o]){throw new Error("syntax: named ellipsis can only "+"appear onces")}L["..."].symbols[o]=r}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,w)){if(e.cdr.cdr!==nil){if(e.cdr.cdr instanceof Pair){var c=e.cdr.cdr.length();var s=r.length();var l=r;while(s-1>c){l=l.cdr;s--}var f=l.cdr;l.cdr=nil;if(!E(e.cdr.cdr,f,t,n)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!t.includes(_)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(n){A("NIL");L["..."].symbols[_]=nil}else{A("NULL");L["..."].symbols[_]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+n);if(n){if(L["..."].symbols[_]){var p=L["..."].symbols[_];if(p===nil){p=new Pair(nil,new Pair(r,nil))}else{p=p.append(new Pair(r,nil))}L["..."].symbols[_]=p}else{L["..."].symbols[_]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[_]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+n);t.push(_);if(!L["..."].symbols[_]){L["..."].symbols[_]=new Pair(r,nil)}else{var h=L["..."].symbols[_];L["..."].symbols[_]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[_].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(t);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var m=r;while(m instanceof Pair){if(!E(e.car,m.car,d,true)){return false}m=m.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,w)){throw new Error("syntax: invalid usage of ellipsis")}A(">> 11");var v=e.__name__;if(D.includes(v)){return true}A({name:v,ellipsis:n});if(n){L["..."].symbols[v]=L["..."].symbols[v]||[];L["..."].symbols[v].push(r)}L.symbols[v]=r;if(!L.symbols[v]);return true}if(e instanceof Pair&&r instanceof Pair){A(">> 12");A({a:12,code:r&&r.toString(),pattern:e.toString()});if(r.cdr===nil){var y=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(y){if(!E(e.car,r.car,t,n)){return false}A(">> 12 | 1");var b=e.cdr.valueOf();if(!(b in L.symbols)){L.symbols[b]=nil}b=e.car.valueOf();if(!(b in L.symbols)){L.symbols[b]=r.car}return true}}A({pattern:e.toString(),code:r.toString()});if(e.cdr instanceof Pair&&e.car instanceof LSymbol&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,w)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,w)&&E(e.car,r.car,t,n)&&E(e.cdr.cdr.cdr,r.cdr,t,n)){var g=e.cdr.car.__name__;A({pattern:e.car.toString(),code:r.car.toString(),name:g});if(D.includes(g)){return true}L["..."].symbols[g]=null;return true}A("recur");if(E(e.car,r.car,t,n)&&E(e.cdr,r.cdr,t,n)){return true}}else if(e===nil&&(r===nil||r===undefined$1)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,w)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(E(e,r)){return L}}function clear_gensyms(e,i){function a(r){if(r instanceof Pair){if(!i.length){return r}var e=a(r.car);var t=a(r.cdr);return new Pair(e,t)}else if(r instanceof LSymbol){var n=i.find(function(e){return e.gensym===r});if(n){return LSymbol(n.name)}return r}else{return r}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:{};var A=e.bindings,r=e.expr,E=e.scope,u=e.symbols,a=e.names,S=e.ellipsis;var o={};function c(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof_1(e))}function P(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var t=e.valueOf();if(t===S){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof_1(t);if(["string","symbol"].includes(n)){if(t in A.symbols){return A.symbols[t]}else if(n==="string"&&t.match(/\./)){var i=t.split(".");var a=i[0];if(a in A.symbols){return Pair.fromArray([LSymbol("."),A.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(u.includes(t)){return LSymbol(t)}return s(t)}function C(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var t=gensym(e);if(r){var n=E.get(e);E.set(t,n)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(t,i)}}a.push({name:e,gensym:t});o[e]=t}return o[e]}function k(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=t.nested;C(" ==> "+e.toString(true));C(r);if(e instanceof LSymbol){var a=e.valueOf();C("[t 1");if(r[a]){if(r[a]instanceof Pair){var u=r[a],o=u.car,c=u.cdr;if(i){var s=o.car,l=o.cdr;if(l!==nil){n(a,new Pair(l,nil))}return s}if(c!==nil){n(a,c)}return o}else if(r[a]instanceof Array){n(a,r[a].slice(1));return r[a][0]}}return P(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){C("[t 2");var f=e.car.valueOf();var _=r[f];C({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){C({b:r[f].toString()});if(_ instanceof Pair){C("[t 2 Pair "+i);C({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){C("|| next 1");n(f,h)}C({car:p.toString()});return p}else{if(p.cdr!==nil){C("|| next 2");n(f,new Pair(p.cdr,h))}C({car:p.car.toString()});return p.car}}else if(_ instanceof Array){C("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){n(f,d)}return _[0]}}else{return _}}}C("[t 3 recur "+e.toString());var m=k(e.car,r,t,n);var v=k(e.cdr,r,t,n);return new Pair(m,v)}return e}function N(r,t){var e=Object.values(r);var n=Object.getOwnPropertySymbols(r);if(n.length){e.push.apply(e,toConsumableArray(n.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!t}return e instanceof Pair||e===nil||e instanceof Array&&e.length})}function O(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function B(i){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},r=e.disabled;C("traverse>> "+i.toString());if(i instanceof Pair){if(!r&&i.car instanceof Pair&&LSymbol.is(i.car.car,S)){return B(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,S)&&!r){C(">> 1");var t=A["..."].symbols;var n=Object.values(t);if(n.length&&n.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(t);var u=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,S);if(i.car instanceof Pair||u){if(A["..."].lists[0]===nil){return nil}var o=i.car;if(u){o=new Pair(i.car,new Pair(i.cdr.car,nil))}C(">> 2");var c;if(a.length){C(">> 2 (a)");var s=_objectSpread({},t);c=nil;var l=function e(){if(!N(s)){return"break"}var n={};var r=function e(r,t){n[r]=t};var t=k(o,s,{nested:true},r);if(t!==undefined$1){if(u){if(c===nil){c=t}else{c=c.append(t)}}else{c=new Pair(t,c)}}s=n};while(true){var f=l();if(f==="break")break}if(c!==nil&&!u){c=c.reverse()}if(i.cdr.cdr!==nil&&!LSymbol.is(i.cdr.cdr.car,S)){var _=B(i.cdr.cdr,{disabled:r});return c.append(_)}return c}else{C(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){C(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){C(">> 4 (a)")}else{C(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,t[h]);var m=t[h]===null;var v=nil;var y=function e(){if(!N(d,true)){C({bind:d});return"break"}var n={};var r=function e(r,t){n[r]=t;if(is_debug()){console.log({NEWBIND:n[r].toString()})}};var t=k(i,d,{nested:false},r);C({value:t.toString()});if(typeof t!=="undefined"){v=new Pair(t,v)}d=n};while(true){var b=y();if(b==="break")break}if(v!==nil){v=v.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var g=B(i.cdr.cdr,{disabled:r});if(m){return g}C("<<<< 1");v.append(g)}}C("<<<< 2");return v}}var D=B(i.car,{disabled:r});var w;var L;if(i.car instanceof LSymbol){var x=E.get(i.car,{throwError:false});L=x instanceof Macro&&x.__name__==="syntax-rules"}if(L){if(i.cdr.car instanceof LSymbol){w=new Pair(B(i.cdr.car,{disabled:r}),new Pair(i.cdr.cdr.car,B(i.cdr.cdr.cdr,{disabled:r})))}else{w=new Pair(i.cdr.car,B(i.cdr.cdr,{disabled:r}))}}else{w=B(i.cdr,{disabled:r})}C({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(D),rest:toString(w)});return new Pair(D,w)}if(i instanceof LSymbol){if(r&&LSymbol.is(i,S)){return i}var F=P(i);if(typeof F!=="undefined"){return F}}return i}return B(r,{})}function is_null(e){return typeof e==="undefined"||e===nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return e&&typeof e!=="undefined"&&is_function(e.then)}function box(e){switch(_typeof_1(e)){case"string":return LString(e);case"number":if(!Number.isNaN(e)){return LNumber(e)}}return e}function map_object(n,i){var e=Object.getOwnPropertyNames(n);var r=Object.getOwnPropertySymbols(n);e.concat(r).forEach(function(e){var r=i(n[e]);var t=Object.getOwnPropertyDescriptor(n,e);if(!t||t.writable&&n[e]!==r){n[e]=r}});return n}function unbox(r){var e=[LString,LCharacter,LNumber].some(function(e){return r instanceof e});if(e){return r.valueOf()}if(r instanceof Array){return r.map(unbox)}if(is_plain_object(r)){return map_object(r,unbox)}return r}function patch_value(e,r){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(r){return bind(e,r)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(r,e){if(r[Symbol["for"]("__bound__")]){return r}var t=r.bind(e);var n=Object.getOwnPropertyNames(r).filter(filter_fn_names);n.forEach(function(e){try{t[e]=r[e]}catch(e){}});hidden_prop(t,"__fn__",r);hidden_prop(t,"__context__",e);hidden_prop(t,"__bound__",true);if(is_native_function(r)){hidden_prop(t,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(t,"__method__",true)}t.valueOf=function(){return r};return t}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var r=e[__context__];if(r&&(r===lips||r.constructor&&r.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}var __context__=Symbol["for"]("__context__");var __fn__=Symbol["for"]("__fn__");var __data__=Symbol["for"]("__data__");var __ref__=Symbol["for"]("__ref__");var __cycles__=Symbol["for"]("__cycles__");var __class__=Symbol["for"]("__class__");var __method__=Symbol["for"]("__method__");var __prototype__=Symbol["for"]("__prototype__");var __lambda__=Symbol["for"]("__lambda__");var exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,r,t){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return t},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,t){try{Object.defineProperty(r,"length",{get:function e(){return t}});return r}catch(e){var n=new Array(t).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(r)}}function is_native_function(e){var r=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[r]===true||!e.name.match(/^bound /)&&!e[r])}function let_macro(e){var h;switch(e){case Symbol["for"]("letrec"):h="letrec";break;case Symbol["for"]("let"):h="let";break;case Symbol["for"]("let*"):h="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(h,function(r,e){var a=e.dynamic_scope,u=e.error,t=e.macro_expand;var o;if(r.car instanceof LSymbol){if(!(r.cdr.car instanceof Pair||r.cdr.car===nil)){throw new Error("let require list of pairs")}var n;if(r.cdr.car===nil){o=nil;n=nil}else{n=r.cdr.car.map(function(e){return e.car});o=r.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[r.car,Pair(LSymbol("lambda"),Pair(n,r.cdr.cdr))]],Pair(r.car,o)])}else if(t){return}var c=this;o=global_env.get("list->array")(r.car);var s=c.inherit(h);var l,f;if(h==="let*"){f=s}else if(h==="let"){l=[]}var _=0;function p(){var e=new Pair(new LSymbol("begin"),r.cdr);return _evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var t=o[_++];if(a){a=h==="let*"?s:c}if(!t){if(l&&l.length){var e=l.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return Promise.all(e).then(function(e){for(var r=0,t=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.dynamic_scope,n=r.error;var i=this;if(t){t=this}var a=e;var u=[];while(a instanceof Pair){u.push(_evaluate(a.car,{env:i,dynamic_scope:t,error:n}));a=a.cdr}var o=u.filter(is_promise).length;if(o){return Promise.all(u).then(c.bind(this))}else{return c.call(this,u)}})}function guardMathCall(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n2?n-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t1?e-1:0),t=1;t=u){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),t=0;t1){e=e.toLowerCase();if(LCharacter.__names__[e]){r=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{r=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(r){Object.defineProperty(this,"__name__",{value:r,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var r=LCharacter.__names__[e];LCharacter.__rev_names__[r]=e});LCharacter.prototype.toUpperCase=function(){return LCharacter(this.__char__.toUpperCase())};LCharacter.prototype.toLowerCase=function(){return LCharacter(this.__char__.toLowerCase())};LCharacter.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};LCharacter.prototype.valueOf=function(){return this.__char__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,r){typecheck("LString",e,"character",r+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=function e(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t0){t.push(this.__string__.substring(0,e))}t.push(r);if(e1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,r)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var t=LNumber.getType(e);if(LNumber.types[t]){return LNumber.types[t](e,r)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var a=e,u=slicedToArray(a,2),o=u[0],c=u[1];if(o instanceof LString){o=o.valueOf()}if(c instanceof LNumber){c=c.valueOf()}var s=o.match(/^([+-])/);var l=false;if(s){o=o.replace(/^[+-]/,"");if(s[1]==="-"){l=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var f;switch(c){case 8:f="0o";break;case 16:f="0x";break;case 2:f="0b";break;case 10:f="";break}if(typeof f==="undefined"){var _=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(_,BigInt(r))}).reduce(function(e,r){return e+r})}else{i=BigInt(f+o)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(construct(BN,toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(o,c),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,r){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:r,enumerable:true})};LNumber.types={float:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,t)},complex:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,t)},rational:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,t)}};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var t=r;r=e;e=t}while(true){r=r.rem(e);if(r.cmp(0)===0){return e}e=e.rem(r);if(e.cmp(0)===0){return r}}};LNumber.isFloat=function e(r){return r instanceof LFloat||Number(r)===r&&r%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var r=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return r};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,r){if(e instanceof LFloat||r instanceof LFloat){return LFloat}if(e instanceof LBigInteger||r instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.prototype.toString=LNumber.prototype.toJSON=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};LNumber.prototype.asType=function(e){var r=LNumber.getType(this);return LNumber.types[r]?LNumber.types[r](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](this.valueOf()))}}});LNumber.prototype.valueOf=function(){if(LNumber.isNative(this.__value__)){return Number(this.__value__)}else if(LNumber.isBN(this.__value__)){return this.__value__.toNumber()}};var matrix=function(){var e=function e(r,t){return[r,t]};return{bigint:{bigint:e,float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:function e(r,t){return[{num:r,denom:1},t]},complex:function e(r,t){return[{im:0,re:r},t]}},integer:{integer:e,float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:function e(r,t){return[{num:r,denom:1},t]},complex:function e(r,t){return[{im:0,re:r},t]}},float:{bigint:function e(r,t){return[r,t&&LFloat(t.valueOf())]},integer:function e(r,t){return[r,t&&LFloat(t.valueOf())]},float:e,rational:function e(r,t){return[r,t&&LFloat(t.valueOf())]},complex:function e(r,t){return[{re:r,im:LFloat(0)},t]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,t){var n=LNumber.coerce(r.__re__,t.__re__),i=slicedToArray(n,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,t.__im__),c=slicedToArray(o,2),s=c[0],l=c[1];return[{im:s,re:a},{im:l,re:u}]}},rational:{bigint:function e(r,t){return[r,t&&{num:t,denom:1}]},integer:function e(r,t){return[r,t&&{num:t,denom:1}]},float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:e,complex:function e(r,t){return[{im:coerce(r.__type__,t.__im__.__type__,0)[0],re:coerce(r.__type__,t.__re__.__type__,r)[0]},{im:coerce(r.__type__,t.__im__.__type__,t.__im__)[0],re:coerce(r.__type__,t.__re__.__type__,t.__re__)[0]}]}}};function r(t){return function(e,r){return[{im:coerce(t,e.__im__.__type__,0,e.__im__)[1],re:coerce(t,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(t,e.__im__.__type__,0,0)[1],re:coerce(t,r.__type__,0,r)[1]}]}}}();function coerce(e,r,t,n){return matrix[e][r](t,n)}LNumber.coerce=function(e,r){var t=LNumber.getType(e);var n=LNumber.getType(r);if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[t][n](e,r);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(r){rev_mapping[mapping[r]]=r;LNumber.prototype[r]=function(e){return this.op(mapping[r],e)}});LNumber._ops={"*":function e(r,t){return r*t},"+":function e(r,t){return r+t},"-":function e(r,t){if(typeof t==="undefined"){return-r}return r-t},"/":function e(r,t){return r/t},"%":function e(r,t){return r%t},"|":function e(r,t){return r|t},"&":function e(r,t){return r&t},"~":function e(r){return~r},">>":function e(r,t){return r>>t},"<<":function e(r,t){return r<1&&arguments[1]!==undefined$1?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LComplex)||typeof this==="undefined"){return new LComplex(e,r)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&r){if(!r){return Number(e)}}else if(!LNumber.isComplex(e)){throw new Error("Invalid constructor call for LComplex")}var t=e.im instanceof LNumber?e.im:LNumber(e.im);var n=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(t,n)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.constant=function(e,r){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:r,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var t=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:t})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,t,n){return{re:e.add(r),im:t.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var t,n;if(e instanceof LFloat){t=e.toRational().mul(e.toRational())}else{t=e.mul(e)}if(r instanceof LFloat){n=r.toRational().mul(r.toRational())}else{n=r.mul(r)}return t.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.conjugate=function(){return LComplex({re:this.__re__,im:this.__im__.sub()})};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,t;if(e.cmp(0)===0){r=t=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();t=this.__im__.div(r).div(2)}else{t=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){t=t.sub()}r=this.__im__.div(t).div(2)}return LComplex({im:t,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var r=this.__re__.div(e);var t=this.__im__.div(e);return LComplex({re:r,im:t})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var n=this.coerce(e),i=slicedToArray(n,2),a=i[0],u=i[1];var o=u.factor();var c=a.mul(u.conjugate());var s=c.__re__.op("/",o);var l=c.__im__.op("/",o);return LComplex({re:s,im:l})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,t,n){return{re:e.sub(r),im:t.sub(n)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,t,n){var i={re:e.mul(r).sub(t.mul(n)),im:e.mul(n).add(r.mul(t))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var t=function e(r,t){var n=i(a.__re__,r,a.__im__,t);if("im"in n&&"re"in n){if(n.im.cmp(0)===0&&!LNumber.isFloat(n.im)){return n.re}return LComplex(n,true)}return n};if(typeof r==="undefined"){return t()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var n=r.asType(0);r={__im__:n,__re__:r}}else if(!LNumber.isComplex(r)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var u=r.__re__ instanceof LNumber?r.__re__:this.__re__.asType(r.__re__);var o=r.__im__ instanceof LNumber?r.__im__:this.__im__.asType(r.__im__);return t(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var t=LComplex._op[e];return this[t](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=n.__re__.coerce(i.__re__),u=slicedToArray(a,2),o=u[0],c=u[1];var s=o.cmp(c);if(s!==0){return s}else{var l=n.__im__.coerce(i.__im__),f=slicedToArray(l,2),_=f[0],p=f[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var r=this.__im__.valueOf();var t=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var n=toString(this.__im__);if(!t&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var r=e+".0";return this._minus?"-"+r:r}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var t=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(t(this.__value__,r))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var r=function e(n,r,t){var i=function e(r,t){return t0){i=simplest_rational2(n,t)}else if(n.cmp(t)<=0){i=t}else if(t.cmp(0)>0){i=simplest_rational2(t,n)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),t.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var t=LNumber(e).floor();var n=LNumber(r).floor();if(e.cmp(t)<1){return t}else if(t.cmp(n)===0){var i=LNumber(1).div(r.sub(n));var a=LNumber(1).div(e.sub(t));return t.add(LNumber(1).div(simplest_rational2(i,a)))}else{return t.add(LNumber(1))}}function LRational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,r)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var t,n;if(e instanceof LRational){t=LNumber(e.__num__);n=LNumber(e.__denom__)}else{t=LNumber(e.num);n=LNumber(e.denom)}if(!r&&n.cmp(0)!==0){var i=t.op("%",n).cmp(0)===0;if(i){return LNumber(t.div(n))}}this.constant(t,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.constant=function(e,r){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:r,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var t=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:t,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var r=this.__denom__.sqrt();if(e instanceof LFloat){e=(readOnlyError("num"),e.toRational())}if(r instanceof LFloat){r=(readOnlyError("denom"),r.toRational())}return LRational({num:e,denom:r})};LRational.prototype.abs=function(){var e=this.__num__;var r=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(r.cmp(0)!==1){r=r.sub()}return LRational({num:e,denom:r})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var r,t;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}t=this.__denom__.div(e);if(t instanceof LRational){t=LNumber(t.valueOf(true))}}else{r=this.__num__;t=this.__denom__}var n=this.cmp(0)<0;if(n){if(r.abs().cmp(t.abs())===0){return r.toString()}}else if(r.cmp(t)===0){return r.toString()}return r.toString()+"/"+t.toString()};LRational.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__num__.mul(e.__num__);var t=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:t})}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];return a.mul(u)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__num__.mul(e.__denom__);var t=this.__denom__.mul(e.__num__);return LRational({num:r,denom:t})}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];var o=a.div(u);return o};LRational.prototype._op=function(e,r){return this[rev_mapping[e]](r)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=e.__num__.sub();var t=e.__denom__;return this.add(LRational({num:r,denom:t}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];return a.add(u)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__denom__;var t=e.__denom__;var n=this.__num__;var i=e.__num__;var a,u;if(r!==t){u=t.mul(n).add(i.mul(r));a=r.mul(t)}else{u=n.add(i);a=r}return LRational({num:u,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var o=LNumber.coerce(this,e),c=slicedToArray(o,2),s=c[0],l=c[1];return s.add(l)};function LBigInteger(e,r){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,r)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:r})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype._op=function(e,r){if(typeof r==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(r.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](r),false)}var t=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var n=this.op("%",r).cmp(0)===0;if(n){return LNumber(t)}return LRational({num:this,denom:r})}return LBigInteger(t,true)};LBigInteger.prototype.sqrt=function(){var e;var r=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(r?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=r?this.__value__.neg().sqrt():this.__value__.sqrt()}if(r){return LComplex({re:0,im:e})}return e};function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(r){typecheck("InputPort::__parser__",r,"parser");i=r}});this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(n.char_ready()){r.next=5;break}r.next=3;return n._read();case 3:t=r.sent;i=new Parser(t,{env:n});case 5:return r.abrupt("return",n.__parser__);case 6:case"end":return r.stop()}}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==eof};this._make_defaults()}InputPort.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,r){if(!LNumber.isInteger(r)){var t=LNumber.getType(r);typeErrorMessage("read-string",t,"integer")}return e.__lexer__.read_string(r.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(o,c){var s=this;return function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u=arguments;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return o.call(s);case 2:t=r.sent;for(n=u.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};OutputPort.prototype.toString=function(){return"#"};function OutputStringPort(r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");read_only(this,"__type__",text_port);read_only(this,"__buffer__",[]);this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}t.__buffer__.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.constructor=OutputStringPort;OutputStringPort.prototype.toString=function(){return"#"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",r.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}t.fs().write(t._fd,e,function(e){if(e){throw e}})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};OutputFilePort.prototype.internal=function(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(r,t){n.fs().close(n._fd,function(e){if(e){t(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var t=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");r=r||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!t.__parser__){t.__parser__=new Parser(e,{env:r})}return t.__parser__});read_only(this,"__type__",text_port);this._make_defaults()}InputStringPort.prototype.char_ready=function(){return true};InputStringPort.prototype=Object.create(InputPort.prototype);InputStringPort.prototype.constructor=InputStringPort;InputStringPort.prototype.toString=function(){return"#"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var t=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return t},set:function e(r){typecheck("InputByteVectorPort::__index__",r,"number");if(r instanceof LNumber){r=r.valueOf()}if(typeof r==="bigint"){r=Number(r)}if(Math.floor(r)!==r){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}t=r}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var r=this;read_only(this,"__vector__",nil);["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){r[e]=function(){throw new Error("Input-binary-port: port is closed")}});this.char_ready=function(){return false}};InputByteVectorPort.prototype.u8_ready=function(){return true};InputByteVectorPort.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return eof}return this.__vector__[this.__index__]};InputByteVectorPort.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};InputByteVectorPort.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};InputByteVectorPort.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===eof){return eof}return this.__vector__.slice(this.__index__,e)};function OutputByteVectorPort(){if(typeof this!=="undefined"&&!(this instanceof OutputByteVectorPort)||typeof this==="undefined"){return new OutputByteVectorPort}read_only(this,"__type__",binary_port);read_only(this,"_buffer",[],{hidden:true});this.write=function(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var r;(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}OutputByteVectorPort.prototype=Object.create(OutputPort.prototype);OutputByteVectorPort.prototype.constructor=OutputByteVectorPort;OutputByteVectorPort.prototype.close=function(){OutputPort.prototype.close.call(this);read_only(this,"_buffer",null,{hidden:true})};OutputByteVectorPort.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};OutputByteVectorPort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,r)}InputStringPort.call(this,e);typecheck("InputFilePort",r,"string");read_only(this,"__filename__",r)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,r)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",r,"string");read_only(this,"__filename__",r)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,r)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",r.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a,t;this.write=function(e){var n=this;typecheck("write",e,["number","uint8array"]);var i;if(!a){a=this.internal("fs")}if(!t){t=this.internal("Buffer")}if(LNumber.isNumber(e)){i=t.from([e.valueOf()])}else{i=t.from(Array.from(e))}return new Promise(function(r,t){a.write(n._fd,i,function(e){if(e){t(e)}else{r()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.stderr,n=r.stdin,i=r.stdout,a=objectWithoutProperties(r,["stderr","stdin","stdout"]);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:n,stdout:i,stderr:t},a))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,a);var u="**interaction-environment-defaults**";this.set(u,get_props(a).concat(u));var o=internal_env.inherit("internal-".concat(e));if(is_port(n)){o.set("stdin",n)}if(is_port(t)){o.set("stderr",t)}if(is_port(i)){o.set("stdout",i)}set_interaction_env(this.__env__,o)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;typecheck("Interpreter::exec",e,"string",1);typecheck("Interpreter::exec",r,"boolean",2);global_env.set("**interaction-environment**",this.__env__);if(t===null){t=this.__env__}return exec(e,t,r?t:false)};Interpreter.prototype.get=function(e){var r=this.__env__.get(e);if(is_function(r)){return r.bind(this.__env__)}return r};Interpreter.prototype.set=function(e,r){return this.__env__.set(e,r)};Interpreter.prototype.constant=function(e,r){return this.__env__.constant(e,r)};function Environment(e,r,t){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;t=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=t||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};if(_typeof_1(e)==="object"){r=e}if(!e||_typeof_1(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(r||{},this,e)};Environment.prototype.doc=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(r){if(!t){r=trim_lines(r)}this.__docs__.set(e,r);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};Environment.prototype.newFrame=function(e,r){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=n.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var t=r.get("parent.frame");return t(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;n.set("arguments",r);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var r=this;var t={};Object.keys(this.__env__).forEach(function(e){t[e]=r.__env__[e]});return new Environment(t,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(r,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var t=r.throwError,n=t===void 0?true:t;var i=e;if(i instanceof LSymbol||i instanceof LString){i=i.valueOf()}var a=this._lookup(i);if(a instanceof Value){if(Value.isUndefined(a)){return undefined$1}return patch_value(a.valueOf())}if(typeof i==="string"){var u=i.split(".").filter(Boolean);if(u.length>0){var o=toArray(u),c=o[0],s=o.slice(1);a=this._lookup(c);if(s.length){try{if(a instanceof Value){a=a.valueOf()}else{a=get(root,c);if(is_function(a)){a=unbind(a)}}return get.apply(void 0,[a].concat(toConsumableArray(s)))}catch(e){}}else if(a instanceof Value){return patch_value(a.valueOf())}}a=get(root,i)}if(typeof a!=="undefined"){return a}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(r)){r=LNumber(r)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=r;if(t){this.doc(e,t)}return this};Environment.prototype.constant=function(r,e){var t=this;if(this.__env__.hasOwnProperty(r)){throw new Error("Environment::constant: ".concat(r," already exists"))}if(arguments.length===1&&is_plain_object(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){t.constant(r,n[e])})}else{Object.defineProperty(this.__env__,r,{value:e,enumerable:true})}return this};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var r=this;while(true){if(!r){break}if(r.has(e)){return r}r=r.__parent__}};Environment.prototype.parents=function(){var e=this;var r=[];while(e){r.unshift(e);e=e.__parent__}return r};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n Function get character from string port or EOF object if no more\n data in string port."),"read-line":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-line",e,"input-port");return e.read_line()},"(read-char port)\n\n Function read next character from input port."),"read-char":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u,o,c,s,l,f=arguments;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=f.length>0&&f[0]!==undefined$1?f[0]:null;if(!LString.isString(t)){r.next=35;break}n=true;i=false;r.prev=4;u=asyncIterator(parse(t,this));case 6:r.next=8;return u.next();case 8:o=r.sent;n=o.done;r.next=12;return o.value;case 12:c=r.sent;if(n){r.next=19;break}s=c;return r.abrupt("return",s);case 16:n=true;r.next=6;break;case 19:r.next=25;break;case 21:r.prev=21;r.t0=r["catch"](4);i=true;a=r.t0;case 25:r.prev=25;r.prev=26;if(!(!n&&u["return"]!=null)){r.next=30;break}r.next=30;return u["return"]();case 30:r.prev=30;if(!i){r.next=33;break}throw a;case 33:return r.finish(30);case 34:return r.finish(25);case 35:if(t===null){l=internal(this,"stdin")}else{l=t}typecheck_text_port("read",l,"input-port");return r.abrupt("return",l.read.call(this));case 38:case"end":return r.stop()}}},e,this,[[4,21,25,35],[26,,30,34]])}));function r(){return e.apply(this,arguments)}return r}(),"(read [string])\n\n Function if used with string will parse the string and return\n list structure of LIPS code. If called without an argument it\n will read string from standard input (using browser prompt or\n user defined way) and call itself with that string (parse is)\n function can be used together with eval to evaluate code from\n string"),pprint:doc(function e(r){if(r instanceof Pair){r=new lips.Formatter(r.toString(true))["break"]().format();global_env.get("display").call(global_env,r)}else{global_env.get("write").call(global_env,r)}global_env.get("newline").call(global_env)},"(pprint expression)\n\n Pretty print list expression, if called with non-pair it just call\n print function with passed argument."),print:doc(function e(){var r=global_env.get("display");var t=global_env.get("newline");for(var n=arguments.length,i=new Array(n),a=0;a1?t-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var c=global_env.get("repr");r=r.replace(a,function(e){var r=e[1];if(r==="~"){return"~"}else if(r==="%"){return"\n"}else{var t=n[o++];if(r==="a"){return c(t)}else{return c(t,true)}}});u=r.match(/~([\S])/);if(u){throw new Error("format: Unrecognized escape seqence ".concat(u[1]))}return r},"(format string n1 n2 ...)\n\n Function accepts string template and replacing any escape sequences\n by arguments:\n\n * ~a value as if printed with display\n * ~s value as if printed with write\n * ~% newline character\n * ~~ literal tilde '~' is inserted\n\n if there missing arguments or other escape character it throw exception."),display:doc(function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(t===null){t=internal(this,"stdout")}else{typecheck("display",t,"output-port")}var n=global_env.get("repr")(r);t.write.call(global_env,n)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var t=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.dynamic_scope,n=r.error;if(t){t=this}var i=this;var u;var o=_evaluate(e.cdr.car,{env:this,dynamic_scope:t,error:n});o=resolve_promises(o);function c(r,t,n){if(is_promise(r)){return r.then(function(e){return c(r,e,n)})}if(is_promise(t)){return t.then(function(e){return c(r,e,n)})}if(is_promise(n)){return n.then(function(e){return c(r,t,e)})}i.get("set-obj!").call(i,r,t,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var s=e.car.cdr.car;var l=e.car.cdr.cdr.car;var f=_evaluate(s,{env:this,dynamic_scope:t,error:n});var _=_evaluate(l,{env:this,dynamic_scope:t,error:n});return c(f,_,o)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var p=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=p.split(".");if(r.length>1){var t=r.pop();var n=r.join(".");var i=a.get(n,{throwError:false});if(i){c(i,t,e);return}}throw new Error("Unbound variable `"+p+"'")}u.set(p,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable (mutate)\n it search the scope chain until it finds first non emtpy slot and set it."),"unset!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var r=e.car;var t=this.ref(r);if(t){delete t.__env__[r.__name__]}}),"(unset! name)\n\n Function delete specified name from environment."),"set-car!":doc("set-car!",function(e,r){typecheck("set-car!",e,"pair");e.car=r},"(set-car! obj value)\n\n Function that set car (head) of the list/pair to specified value.\n It can destroy the list. Old value is lost."),"set-cdr!":doc("set-cdr!",function(e,r){typecheck("set-cdr!",e,"pair");e.cdr=r},"(set-cdr! obj value)\n\n Function that set cdr (tail) of the list/pair to specified value.\n It can destroy the list. Old value is lost."),"empty?":doc("empty?",function(e){return typeof e==="undefined"||e===nil},"(empty? object)\n\n Function return true if value is undfined empty list."),gensym:doc("gensym",gensym,"(gensym)\n\n Function generate unique symbol, to use with macros as meta name."),load:doc(function e(r,t){typecheck("load",r,"string");var n=this;if(n.__name__==="__frame__"){n=n.__parent__}if(!(t instanceof Environment)){if(n===global_env){t=n}else{t=this.get("**interaction-environment**")}}var i="**module-path**";var a=global_env.get(i,{throwError:false});r=r.valueOf();if(!r.match(/.[^.]+$/)){r+=".scm"}function u(e){if(type(e)==="buffer"){e=e.toString()}return exec(e.replace(/^#!.*/,""),t)}if(is_node()){return new Promise(function(t,n){var e=nodeRequire("path");if(a){a=a.valueOf();r=e.join(a,r)}global_env.set(i,e.dirname(r));nodeRequire("fs").readFile(r,function(e,r){if(e){n(e);global_env.set(i,a)}else{try{u(r).then(function(){t();global_env.set(i,a)})["catch"](n)}catch(e){n(e)}}})})}if(a){a=a.valueOf();r=a+"/"+r.replace(/^\.?\/?/,"")}return root.fetch(r).then(function(e){return e.text()}).then(function(e){global_env.set(i,r.replace(/\/[^/]*$/,""));return u(e)}).then(function(){})["finally"](function(){global_env.set(i,a)})},"(load filename)\n (load filename environment)\n\n Function fetch the file and evaluate its content as LIPS code,\n If second argument is provided and it's environment the evaluation\n will happen in that environment."),do:doc(new Macro("do",function(){var t=asyncToGenerator(regenerator.mark(function e(t,n){var i,a,u,o,c,s,l,f,_,p,h;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=n.dynamic_scope,a=n.error;u=this;if(i){i=u}o=u.inherit("do");c=t.car;s=t.cdr.car;l=t.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};_=c;case 10:if(!(_!==nil)){r.next=21;break}p=_.car;r.t0=o;r.t1=p.car;r.next=16;return _evaluate(p.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);_=_.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var t,n,i,a,u;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(l!==nil)){r.next=3;break}r.next=3;return lips.evaluate(l,f);case 3:t=c;n={};case 5:if(!(t!==nil)){r.next=15;break}i=t.car;if(!(i.cdr.cdr!==nil)){r.next=12;break}r.next=10;return _evaluate(i.cdr.cdr.car,f);case 10:a=r.sent;n[i.car.valueOf()]=a;case 12:t=t.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(n);Object.keys(n).concat(u).forEach(function(e){o.set(e,n[e])});case 17:case"end":return r.stop()}}},e)});case 23:r.next=25;return _evaluate(s.car,f);case 25:r.t3=r.sent;if(!(r.t3===false)){r.next=30;break}return r.delegateYield(h(),"t4",28);case 28:r.next=23;break;case 30:if(!(s.cdr!==nil)){r.next=34;break}r.next=33;return _evaluate(s.cdr.car,f);case 33:return r.abrupt("return",r.sent);case 34:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()),"(do (( )) (test expression) . body)\n\n Iteration macro that evaluate the expression body in scope of the variables.\n On Eeach loop it increase the variables according to next expression and run\n test to check if the loop should continue. If test is signle call the macro\n will not return anything. If the test is pair of expression and value the\n macro will return that value after finish."),if:doc(new Macro("if",function(t,e){var n=e.dynamic_scope,i=e.error;if(n){n=this}var a=this;var r=function e(r){if(r===false){return _evaluate(t.cdr.cdr.car,{env:a,dynamic_scope:n,error:i})}else{return _evaluate(t.cdr.car,{env:a,dynamic_scope:n,error:i})}};if(t===nil){throw new Error("too few expressions for `if`")}var u=_evaluate(t.car,{env:a,dynamic_scope:n,error:i});return unpromise(u,r)}),"(if cond true-expr false-expr)\n\n Macro evaluate condition expression and if the value is true, it\n evaluate and return true expression if not it evaluate and return\n false expression"),"let-env":new Macro("let-env",function(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};var t=e.dynamic_scope,n=e.error;typecheck("let-env",r,"pair");var i=_evaluate(r.car,{env:this,dynamic_scope:t,error:n});return unpromise(i,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:t,error:n})})},"(let-env env . body)\n\n Special macro that evaluate body in context of given environment\n object."),letrec:doc(let_macro(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b)) body)\n\n Macro that creates new environment, then evaluate and assign values to\n names and then evaluate the body in context of that environment.\n Values are evaluated sequentialy and next value can access to\n previous values/names."),"letrec*":doc(let_macro(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b)) body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so use can use recursive code as well as reference previous binding.\n In LIPS both letrec and letrec* behave the same."),"let*":doc(let_macro(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b)) body)\n\n Macro similar to `let` but next argument get environment\n from previous let variable, so they you can define one variable,\n and use in next argument."),let:doc(let_macro(Symbol["for"]("let")),"(let ((a value-a) (b value-b)) body)\n\n Macro that creates new environment, then evaluate and assign values to\n names and then evaluate the body in context of that environment.\n Values are evaluated sequentialy but you can't access\n previous values/names when next are evaluated. You can only get them\n from body of let expression."),"begin*":doc(pararel("begin*",function(e){return e.pop()}),"(begin* . expr)\n\n This macro is parallel version of begin. It evaluate each expression and\n if it's a promise it will evaluate it in parallel and return value\n of last expression."),begin:doc(new Macro("begin",function(e,r){var n=Object.assign({},r);var i=global_env.get("list->array")(e);if(n.dynamic_scope){n.dynamic_scope=this}n.env=this;var a;return function r(){if(i.length){var e=i.shift();var t=_evaluate(e,n);return unpromise(t,function(e){a=e;return r()})}else{return a}}()}),"(begin . args)\n\n Macro runs list of expression and return valuate of the list one.\n It can be used in place where you can only have single exression,\n like if expression."),ignore:new Macro("ignore",function(e,r){var t=r.dynamic_scope,n=r.error;var i={env:this,error:n};if(t){i.dynamic_scope=this}_evaluate(new Pair(new LSymbol("begin"),e),i)},"(ignore expression)\n\n Macro that will evaluate expression and swallow any promises that may\n be created. It wil run and ignore any value that may be returned by\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),define:doc(Macro.defmacro("define",function(t,e){var n=this;if(t.car instanceof Pair&&t.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(t.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(t.car.cdr,t.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=t.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",t.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=t.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(t.cdr.cdr instanceof Pair&&LString.isString(t.cdr.cdr.car)){r=t.cdr.cdr.car.valueOf()}n.set(t.car,e,r,true)})}),"(define name expression)\n (define (function-name . args) body)\n\n Macro for defining values. It can be used to define variables,\n or function. If first argument is list it will create function\n with name beeing first element of the list. The macro evalute\n code `(define function (lambda args body))`"),"set-obj!":doc("set-obj!",function(e,r,t){var n=_typeof_1(e);if(is_null(e)||n!=="object"&&n!=="function"){var i=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(i)}e=unbind(e);r=r.valueOf();if(arguments.length===2){delete e[r]}else if(is_prototype(e)&&is_function(t)){e[r]=unbind(t);e[r][__prototype__]=true}else if(is_function(t)||is_native(t)||t===nil){e[r]=t}else{e[r]=t?t.valueOf():t}},"(set-obj! obj key value)\n\n Function set property of JavaScript object"),"null-environment":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Function return new base environment with std lib."),values:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var d;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){d=f.cdr.car.valueOf()}function m(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var t=0;var n;if(typeof this!=="undefined"&&!(this instanceof Environment)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}e.set("this",this)}for(var i=arguments.length,a=new Array(i),u=0;u2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(t(n)){n=r(n)}if(t(i)){i=r(i)}if(is_promise(n)||is_promise(i)){return Promise.all([n,i]).then(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return new Pair(t,n)})}else{return new Pair(n,i)}}return e}function u(e,r){if(e instanceof Pair){if(r!==nil){e.append(r)}}else{e=new Pair(e,r)}return e}function t(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function f(e,n,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var t;if(n+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&t[0]===nil)){return t[0]}}t=t.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var n=d(i.cdr,0,1);if(n===nil&&t[0]===nil){return undefined$1}return unpromise(n,function(e){if(t[0]===nil){return e}if(t.length===1){return u(t[0],e)}var r=t.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,t){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,t)}if(LSymbol.is(e.car,"quasiquote")){var n=d(e.cdr,r,t+1);return new Pair(e.car,n)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===t&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var i=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),p(i,r+2,t)),nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==nil){if(e.car.cdr.car instanceof Pair){var a=[];return function r(t){if(t===nil){return Pair.fromArray(a)}return unpromise(_evaluate(t.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(t.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,t))}if(LSymbol.is(e.car,"unquote")){r++;if(rt){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==nil){if(e.cdr.car instanceof Pair){var u=[];return function r(t){if(t===nil){return Pair.fromArray(u)}return unpromise(_evaluate(t.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(t.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:s,dynamic_scope:o,error:c})}}else{return e.cdr}}return l(e,function(e){return d(e,r,t)})}else if(is_plain_object(e)){return _(e,r,t)}else if(e instanceof Array){return f(e,r,t)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!t(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!t(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=d(e.car,0,1);return unpromise(i,function(e){n(e);return quote(e)})},"(quasiquote list ,value ,@value)\n\n Similar macro to `quote` but inside it you can use special\n expressions unquote abbreviated to , that will evaluate expresion inside\n and return its value or unquote-splicing abbreviated to ,@ that will\n evaluate expression but return value without parenthesis (it will join)\n the list with its value. Best used with macros but it can be used outside"),clone:doc(function e(r){typecheck("clone",r,"pair");return r.clone()},"(clone list)\n\n Function return clone of the list."),append:doc(function e(){var r;for(var t=arguments.length,n=new Array(t),i=0;iarray")(r).reverse();return global_env.get("array->list")(t)}else if(!(r instanceof Array)){throw new Error(typeErrorMessage("reverse",type(r),"array or pair"))}else{return r.reverse()}},"(reverse list)\n\n Function will reverse the list or array. If value is not a list\n or array it will throw exception."),nth:doc(function e(r,t){typecheck("nth",r,"number");typecheck("nth",t,["array","pair"]);if(t instanceof Pair){var n=t;var i=0;while(iarray")(t).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,t){typecheck("split",r,["regex","string"]);typecheck("split",t,"string");return global_env.get("array->list")(t.split(r))},"(split separator string)\n\n Function create list by splitting string by separatar that can\n be a string or regular expression."),replace:doc(function e(r,t,n){typecheck("replace",r,["regex","string"]);typecheck("replace",t,["string","function"]);typecheck("replace",n,"string");return n.replace(r,t)},"(replace pattern replacement string)\n\n Function change pattern to replacement inside string. Pattern can be string\n or regex and replacement can be function or string."),match:doc(function e(r,t){typecheck("match",r,["regex","string"]);typecheck("match",t,"string");var n=t.match(r);return n?global_env.get("array->list")(n):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,t){typecheck("search",r,["regex","string"]);typecheck("search",t,"string");return t.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,t){return toString(r,t)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(e.valueOf())},"(escape-regex string)\n\n Function return new string where all special operators used in regex,\n are escaped with slash so they can be used in RegExp constructor\n to match literal string"),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__).map(LSymbol);var t;if(r.length){t=Pair.fromArray(r)}else{t=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(t)}return t},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment and it's parents."),new:doc("new",function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n2&&arguments[2]!==undefined$1?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",r,"symbol",2);specials.append(e.valueOf(),r,t)},'(set-special! symbol name [type])\n\n Add special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional and it can be constant value\n lips.specials.SPLICE if this constant is used it will transform\n `#(1 2 3)` into (x 1 2 3) that is required by # that define vectors.'),get:get,".":get,unbind:doc(unbind,"(unbind fn)\n\n Function remove bidning from function so you can get props from it."),type:doc(type,"(type object)\n\n Function return type of an object as string."),debugger:doc("debugger",function(){debugger},"(debugger)\n\n Function stop JavaScript code in debugger."),in:doc("in",function(e,r){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(r)},"(in key value)\n\n Function use is in operator to check if value is in object."),instanceof:doc("instanceof",function(e,r){return r instanceof unbind(e)},"(instanceof type obj)\n\n Function check of object is instance of object."),"prototype?":doc("prototype?",is_prototype,"(prototype? obj)\n\n Function check if value is JavaScript Object prototype."),"macro?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Function check if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Function check if value is a function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Function check if value is real number."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Function check if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Function check if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Function check if value is a pair or list structure."),"regex?":doc(function(e){return e instanceof RegExp},"(regex? expression)\n\n Function check if value is regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Function check if value is nulish."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Function check if value is boolean."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Function check if value is LIPS symbol"),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Function check if value is an arrray."),"object?":doc("object?",function(e){return e!==nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof_1(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Function check if value is an plain object."),flatten:doc(function e(r){typecheck("flatten",r,"pair");return r.flatten()},"(flatten list)\n\n Return shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function convert JavaScript array to LIPS list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,n))},"(apply fn list)\n\n Function that call function with list of arguments."),length:doc(function e(r){if(!r){return LNumber(0)}if(r instanceof Pair){return LNumber(r.length())}if("length"in r){return LNumber(r.length)}},"(length expression)\n\n Function return length of the object, the object can be list\n or any object that have length property."),"string->number":doc("string->number",function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",r,"number",2);e=e.valueOf();r=r.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,r)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,r)}else{var t=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&t||e.match(int_re)){return parse_integer(e,r)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function convert string to number."),try:doc(new Macro("try",function(r,e){var s=this;var l=e.dynamic_scope,f=e.error;return new Promise(function(i,n){var a,u;if(LSymbol.is(r.cdr.car.car,"catch")){a=r.cdr.car;if(r.cdr.cdr instanceof Pair&&LSymbol.is(r.cdr.cdr.car.car,"finally")){u=r.cdr.cdr.car}}else if(LSymbol.is(r.cdr.car.car,"finally")){u=r.cdr.car}if(!(u||a)){throw new Error("try: invalid syntax")}var o=i;if(u){o=function e(r,t){o=n;unpromise(_evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){t(r)})}}var c={env:s,error:function e(r){var t=s.inherit("try");if(a){t.set(a.cdr.car.car,r);var n={env:t,error:f};if(l){n.dynamic_scope=s}unpromise(_evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),n),function(e){o(e,i)})}else{o(r,f)}}};if(l){c.dynamic_scope=s}var e=_evaluate(r.car,c);if(is_promise(e)){e.then(function(e){o(e,i)})["catch"](c.error)}else{o(e,i)}})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro execute user code and catch exception. If catch is provided\n it's executed when expression expr throw error. If finally is provide\n it's always executed at the end."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throw new expection."),find:doc(function r(t,n){typecheck("find",t,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return nil}var e=matcher("find",t);return unpromise(e(n.car),function(e){if(e&&e!==nil){return n.car}return r(t,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher order Function find first value for which function return true.\n If called with regex it will create matcher function."),"for-each":doc("for-each",function(e){var r;typecheck("for-each",e,"function");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?r-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),u=3;uarray")(t);var a=[];var u=matcher("filter",r);return function r(t){function e(e){if(e&&e!==nil){a.push(n)}return r(++t)}if(t===i.length){return Pair.fromArray(a)}var n=i[t];return unpromise(u(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher order function that call `fn` for each element of the list\n and return list for only those elements for which funtion return\n true value. If called with regex it will create matcher function."),compose:doc(compose,"(compose . fns)\n\n Higher order function and create new function that apply all functions\n From right to left and return it's value. Reverse of compose.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 3)\n 11\n "),pipe:doc(pipe,"(pipe . fns)\n\n Higher order function and create new function that apply all functions\n From left to right and return it's value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 3)\n 15"),curry:doc(curry,"(curry fn . args)\n\n Higher order function that create curried version of the function.\n The result function will have parially applied arguments and it\n will keep returning functions until all arguments are added\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;no?a%=o:o%=a}a=abs(c*t[u])/(a+o)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function return the least common multiple of their arguments."),"odd?":doc("odd?",singleMathOp(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Function check if number os odd."),"even?":doc("even?",singleMathOp(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Function check if number is even."),"*":doc("*",reduceMathOp(function(e,r){return LNumber(e).mul(r)},LNumber(1)),"(* . numbers)\n\n Multiplicate all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduceMathOp(function(e,r){return LNumber(e).add(r)},LNumber(0)),"(+ . numbers)\n\n Sum all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,r=new Array(e),t=0;t":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"),"<":doc("<",function(){for(var e=arguments.length,r=new Array(e),t=0;t=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t=",r,"number");return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nondecreasing"),"eq?":doc("eq?",equal,"(eq? a b)\n\n Function compare two values if they are identical."),or:doc(new Macro("or",function(e,r){var i=r.dynamic_scope,a=r.error;var u=global_env.get("list->array")(e);var o=this;if(i){i=o}if(!u.length){return false}var c;return function r(){function e(e){c=e;if(c!==false){return c}else{return r()}}if(!u.length){if(c!==false){return c}else{return false}}else{var t=u.shift();var n=_evaluate(t,{env:o,dynamic_scope:i,error:a});return unpromise(n,e)}}()}),"(or . expressions)\n\n Macro execute the values one by one and return the one that is truthy value.\n If there are no expression that evaluate to true it return false."),and:doc(new Macro("and",function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},i=r.dynamic_scope,a=r.error;var u=global_env.get("list->array")(e);var o=this;if(i){i=o}if(!u.length){return true}var c;return function r(){function e(e){c=e;if(c===false){return false}else{return r()}}var t=u.shift();if(typeof t==="undefined"){if(c!==false){return c}else{return false}}else{var n=_evaluate(t,{env:o,dynamic_scope:i,error:a});return unpromise(n,e)}}()}),"(and . expressions)\n\n Macro evalute each expression in sequence if any value return false it will\n return false. If each value return true it will return the last value.\n If it's called without arguments it will return true."),"|":doc("|",function(e,r){return LNumber(e).or(r)},"(& a b)\n\n Function calculate or bit operation."),"&":doc("&",function(e,r){return LNumber(e).and(r)},"(& a b)\n\n Function calculate and bit operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function negate the value."),">>":doc(">>",function(e,r){return LNumber(e).shr(r)},"(>> a b)\n\n Function right shit the value a by value b."),"<<":doc(function(e,r){return LNumber(e).shl(r)},"(<< a b)\n\n Function left shit the value a by value b."),not:doc(function e(r){if(is_null(r)){return true}return!r},"(not object)\n\n Function return negation of the argument.")},undefined$1,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(e,r){e.constant("**internal-env**",r);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are internal type\n of variables that can't be redefined, defining variable with same name\n will throw an error.");global_env.set("**interaction-environment**",e)}set_interaction_env(user_env,internal_env);global_env.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contain references to stdin, stdout and stderr.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var t=e[r]?e[r]:r;global_env.set(t,doc(t,function(e){typecheck(t,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(t," number)\n\n Function calculate ").concat(t," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var t=allPossibleCases(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(t instanceof Array){if(t.length===1){t=t[0]}else{var a=t[t.length-1];t=t.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(t,", got ").concat(r).concat(i)}function typecheck_args(t,e,n){e.forEach(function(e,r){typecheck(t,e,n,r+1)})}function typecheck_text_port(e,r,t){typecheck(e,r,t);if(r.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(t instanceof Pair){t=t.to_array()}if(t instanceof Array){t=t.map(function(e){return e.valueOf()})}if(t instanceof Array){t=t.map(function(e){return e.valueOf().toLowerCase()});if(t.includes(i)){a=true}}else{t=t.valueOf().toLowerCase()}if(!a&&i!==t){throw new Error(typeErrorMessage(e,i,t,n))}}function self_evaluated(e){var r=_typeof_1(e);return["string","function"].includes(r)||_typeof_1(e)==="symbol"||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,r){if(e===null){return false}return _typeof_1(e)==="object"&&r in Object.getOwnPropertySymbols(e)}function is_iterator(e,r){if(has_own_symbol(e,r)||has_own_symbol(e.__proto__,r)){return is_function(e[r])}}function type(e){var r={pair:Pair,symbol:LSymbol,character:LCharacter,values:Values,"input-port":InputPort,"output-port":OutputPort,number:LNumber,regex:RegExp,syntax:Syntax,macro:Macro,string:LString,array:Array,"native-symbol":Symbol};if(Number.isNaN(e)){return"NaN"}if(e===nil){return"nil"}if(e===null){return"null"}for(var t=0,n=Object.entries(r);t2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,t=r.error,o=t===void 0?function(){}:t;e=evaluate_args(e,{env:a,dynamic_scope:u,error:o});return unpromise(e,function(e){if(is_raw_lambda(i)){i=unbind(i)}e=prepare_fn_args(i,e);var r=e.slice();var t=(u||a).newFrame(i,r);var n=resolve_promises(i.apply(t,e));return unpromise(n,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}if(Number.isNaN(e)){return e}if(typeof e==="number"){return LNumber(e)}if(typeof e==="string"){return LString(e)}return e},o)})}function _evaluate(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=e.env,n=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(n===true){t=n=t||global_env}else if(t===true){t=n=global_env}else{t=t||global_env}var u={env:t,dynamic_scope:n,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return t.get(r)}if(!(r instanceof Pair)){return r}var c=r.car;var s=r.cdr;if(c instanceof Pair){o=resolve_promises(_evaluate(c,u));if(is_promise(o)){return o.then(function(e){return _evaluate(new Pair(e,r.cdr),u)})}else if(!is_function(o)){throw new Error(type(o)+" "+t.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=t.get(c)}else if(is_function(c)){o=c}var l;if(o instanceof Syntax){l=evaluate_syntax(o,r,u)}else if(o instanceof Macro){l=evaluate_macro(o,s,u)}else if(is_function(o)){l=apply(o,s,u)}else if(r instanceof Pair){o=c&&c.toString();throw new Error("".concat(type(c)," ").concat(o," is not a function"))}else if(!is_function(o)){if(o){var f="".concat(type(o)," `").concat(o,"' is not a function");throw new Error(f)}throw new Error("Unknown function `".concat(c.toString(),"'"))}else{return r}var _=t.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){l=l.then(function(e){if(e instanceof Pair&&!o[__data__]){return _evaluate(e,u)}return e});return new QuotedPromise(l)}return l}catch(e){a&&a.call(t,e,r)}}function exec(e,r,t){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(t,n,i){var a,u,o,c,s,l,f,_,p;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(i===true){n=i=n||user_env}else if(n===true){n=i=user_env}else{n=n||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(t));case 6:r.next=8;return s.next();case 8:l=r.sent;u=l.done;r.next=12;return l.value;case 12:f=r.sent;if(u){r.next=28;break}_=f;p=_evaluate(_,{env:n,dynamic_scope:i,error:function e(r,t){if(r&&r.message){if(r.message.match(/^Error:/)){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1")}else{r.message="Error: ".concat(r.message)}if(t){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(t.toString(true))}}throw r}});if(is_promise(p)){r.next=20;break}a.push(p);r.next=25;break;case 20:r.t0=a;r.next=23;return p;case 23:r.t1=r.sent;r.t0.push.call(r.t0,r.t1);case 25:u=true;r.next=6;break;case 28:r.next=34;break;case 30:r.prev=30;r.t2=r["catch"](4);o=true;c=r.t2;case 34:r.prev=34;r.prev=35;if(!(!u&&s["return"]!=null)){r.next=39;break}r.next=39;return s["return"]();case 39:r.prev=39;if(!o){r.next=42;break}throw c;case 42:return r.finish(39);case 43:return r.finish(34);case 44:return r.abrupt("return",a);case 45:case"end":return r.stop()}}},e,null,[[4,30,34,44],[35,,39,43]])}));return _exec.apply(this,arguments)}function balanced(e){var r={"[":"]","(":")"};var t;if(typeof e==="string"){t=tokenize(e)}else{t=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(r);var i=Object.values(r).concat(n);t=t.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(t),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(n.includes(c)){a.push(c)}else if(!a.is_empty()){var s=a.top();var l=r[s];if(c===l){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(l))}}else{throw new Error("Syntax error: not matched closing ".concat(c))}}}catch(e){u.e(e)}finally{u.f()}return a.is_empty()}function fworker(e){var r="("+e.toString()+")()";var t=window.URL||window.webkitURL;var n;try{n=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(r);n=n.getBlob()}return new root.Worker(t.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:"";if(e===""){if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/"}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/")}}else if(!e.match(/\/$/)){e+="/"}var r=global_env.get("load");return r.call(lips.env,"".concat(e,"dist/std.scm"),global_env)}function Worker(e){this.url=e;var u=this.worker=fworker(function(){var u;var o;self.addEventListener("message",function(e){var t=e.data;var r=t.id;if(t.type!=="RPC"||r===null){return}function n(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(t.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=t.params[0];var r=t.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(t.method==="init"){var a=t.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));u=new lips.Interpreter("worker");o=bootstrap(a);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(r,t){var a=++n;return new Promise(function(n,i){u.addEventListener("message",function e(r){var t=r.data;if(t&&t.type==="RPC"&&t.id===a){if(t.error){i(t.error)}else{n(t.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:t})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return this.rpc("eval",[e,r])}}Pair.unDry=function(e){return new Pair(e.car,e.cdr)};Pair.prototype.toDry=function(){return{value:{car:this.car,cdr:this.cdr}}};Nil.prototype.toDry=function(){return{value:null}};Nil.unDry=function(){return nil};LSymbol.prototype.toDry=function(){return{value:{name:this.__name__}}};LSymbol.unDry=function(e){return new LSymbol(e.__name__)};function execError(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}))}}function init(){var u=["text/x-lips","text/x-scheme"];var o;function c(t){return new Promise(function(r){var e=t.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(exec).then(r)["catch"](function(e){execError(e);r()})}else{return exec(t.innerHTML).then(r)["catch"](function(e){execError(e);r()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var r=a.shift();if(!r){i()}else{var t=r.getAttribute("type");if(u.includes(t)){var n=r.getAttribute("bootstrap");if(!o&&typeof n==="string"){bootstrap(n).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(t&&t.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+t)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var t=r.getAttribute("bootstrap");if(typeof t==="string"){return bootstrap(t).then(function(){o=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Tue, 16 Mar 2021 12:52:41 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var t=function e(r){return r.toString().padStart(2,"0")};var n=r.getFullYear();var i=[n,t(r.getMonth()+1),t(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables.\nYou can also use (help name) to display help for specic function or macro and\n(apropos name) to display list of matched names in environment.\n").replace(/^.*\n/,"");return a}();Ahead.__class__="ahead";Pattern.__class__="pattern";Formatter.__class__="formatter";Macro.__class__="macro";Syntax.__class__="syntax";Environment.__class__="environment";InputPort.__class__="input-port";OutputPort.__class__="output-port";OutputStringPort.__class__="output-string-port";InputStringPort.__class__="input-string-port";InputFilePort.__class__="input-file-port";OutputFilePort.__class__="output-file-port";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";QuotedPromise.__class__="promise";var lips={version:"DEV",banner:banner,date:"Tue, 16 Mar 2021 12:52:41 +0000",exec:exec,parse:compose(uniterate_async,parse),tokenize:tokenize,evaluate:_evaluate,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,quote:quote,InputPort:InputPort,OutputPort:OutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,rationalize:rationalize};global_env.set("lips",lips);return lips})})(); \ No newline at end of file +(function(){"use strict";function _readOnlyError(e){throw new Error('"'+e+'" is read-only')}var readOnlyError=_readOnlyError;function createCommonjsModule(e,r){return r={exports:{}},e(r,r.exports),r.exports}var setPrototypeOf=createCommonjsModule(function(t){function n(e,r){t.exports=n=Object.setPrototypeOf||function e(r,t){r.__proto__=t;return r};return n(e,r)}t.exports=n});function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true}catch(e){return false}}var isNativeReflectConstruct=_isNativeReflectConstruct;var construct=createCommonjsModule(function(n){function i(e,r,t){if(isNativeReflectConstruct()){n.exports=i=Reflect.construct}else{n.exports=i=function e(r,t,n){var i=[null];i.push.apply(i,t);var a=Function.bind.apply(r,i);var u=new a;if(n)setPrototypeOf(u,n.prototype);return u}}return i.apply(null,arguments)}n.exports=i});function _arrayWithHoles(e){if(Array.isArray(e))return e}var arrayWithHoles=_arrayWithHoles;function _iterableToArray(e){if(typeof Symbol!=="undefined"&&Symbol.iterator in Object(e))return Array.from(e)}var iterableToArray=_iterableToArray;function _arrayLikeToArray(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t=0;--r){var i=this.tryEntries[r];var a=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e){this.complete(t.completion,t.afterLoc);S(t);return m}}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if(n.type==="throw"){var i=n.arg;S(t)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){this.delegate={iterator:C(e),resultName:r,nextLoc:t};if(this.method==="next"){this.arg=c}return m}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,t,n,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){t(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(n,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,t){var n=o.apply(e,u);function i(e){asyncGeneratorStep(n,r,t,i,a,"next",e)}function a(e){asyncGeneratorStep(n,r,t,i,a,"throw",e)}i(undefined)})}}var asyncToGenerator=_asyncToGenerator;function _classCallCheck(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var classCallCheck=_classCallCheck;function _defineProperties(e,r){for(var t=0;t=0)continue;t[i]=e[i]}return t}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var t=objectWithoutPropertiesLoose(e,r);var n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var t=[];var n=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){t.push(o.value);if(r&&t.length===r)break}}catch(e){i=true;a=e}finally{try{if(!n&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return t}var iterableToArrayLimit=_iterableToArrayLimit;function _slicedToArray(e,r){return arrayWithHoles(e)||iterableToArrayLimit(e,r)||unsupportedIterableToArray(e,r)||nonIterableRest()}var slicedToArray=_slicedToArray;var _typeof_1=createCommonjsModule(function(r){function t(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=t=function e(r){return typeof r}}else{r.exports=t=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return t(e)}r.exports=t});function _asyncIterator(e){var r;if(typeof Symbol!=="undefined"){if(Symbol.asyncIterator){r=e[Symbol.asyncIterator];if(r!=null)return r.call(e)}if(Symbol.iterator){r=e[Symbol.iterator];if(r!=null)return r.call(e)}}throw new TypeError("Object is not async iterable")}var asyncIterator=_asyncIterator;function _AwaitValue(e){this.wrapped=e}var AwaitValue=_AwaitValue;function _awaitAsyncGenerator(e){return new AwaitValue(e)}var awaitAsyncGenerator=_awaitAsyncGenerator;function AsyncGenerator(a){var u,o;function e(n,i){return new Promise(function(e,r){var t={key:n,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=t}else{u=o=t;c(n,i)}})}function c(r,e){try{var t=a[r](e);var n=t.value;var i=n instanceof AwaitValue;Promise.resolve(i?n.wrapped:n).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(t.done?"return":"normal",e)},function(e){c("throw",e)})}catch(e){s("throw",e)}}function s(e,r){switch(e){case"return":u.resolve({value:r,done:true});break;case"throw":u.reject(r);break;default:u.resolve({value:r,done:false});break}u=u.next;if(u){c(u.key,u.arg)}else{o=null}}this._invoke=e;if(typeof a["return"]!=="function"){this["return"]=undefined}}if(typeof Symbol==="function"&&Symbol.asyncIterator){AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}}AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)};AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e)};AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e)};var AsyncGenerator_1=AsyncGenerator;function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator_1(e.apply(this,arguments))}}var wrapAsyncGenerator=_wrapAsyncGenerator;function _createForOfIteratorHelper(r,e){var t;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(t=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(t)r=t;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=r.length)return{done:true};return{done:false,value:r[n++]}},e:function e(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=true,u=false,o;return{s:function e(){t=r[Symbol.iterator]()},n:function e(){var r=t.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&t["return"]!=null)t["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor)t=e.constructor.name;if(t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t1&&arguments[1]!==undefined$1?arguments[1]:null;var n=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(t===null||t instanceof RegExp&&t.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(n){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env&&user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.fetch=function(i,a){a=a||{};return new Promise(function(e,r){var t=new XMLHttpRequest;t.open(a.method||"get",i,true);for(var n in a.headers){t.setRequestHeader(n,a.headers[n])}t.withCredentials=a.credentials=="include";t.onload=function(){e(o())};t.onerror=r;t.send(a.body||null);function o(){var n=[],i=[],a={},u;t.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,t){n.push(r=r.toLowerCase());i.push([r,t]);u=a[r];a[r]=u?"".concat(u,",").concat(t):t});return{ok:(t.status/100|0)==2,status:t.status,statusText:t.statusText,url:t.responseURL,clone:o,text:function e(){return Promise.resolve(t.responseText)},json:function e(){return Promise.resolve(t.responseText).then(JSON.parse)},blob:function e(){return Promise.resolve(new Blob([t.response]))},headers:{keys:function e(){return n},entries:function e(){return i},get:function e(r){return a[r.toLowerCase()]},has:function e(r){return r.toLowerCase()in a}}}}})}}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,r){return"".concat(num_mnemicic_re(e),"[+-]?").concat(r,"+/").concat(r,"+")}function gen_complex_re(e,r){return"".concat(num_mnemicic_re(e),"(?:[+-]?(?:").concat(r,"+/").concat(r,"+|nan.0|inf.0|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function gen_integer_re(e,r){return"".concat(num_mnemicic_re(e),"[+-]?").concat(r,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var complex_float_stre="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var t=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(t,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+|[+-]?").concat(r,"+|[+-])i$"),"i")}var complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var r=slicedToArray(e,3),t=r[0],n=r[1],i=r[2];a[t]=make_complex_match_re(n,i)});return a}();var characters={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function ucs2decode(e){var r=[];var t=0;var n=e.length;while(t=55296&&i<=56319&&t1&&arguments[1]!==undefined$1?arguments[1]:10;var t=num_pre_parse(e);var n=t.number.split("/");var i=LRational({num:LNumber([n[0],t.radix||r]),denom:LNumber([n[1],t.radix||r])});if(t.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var t=num_pre_parse(e);if(t.inexact){return LFloat(parseInt(t.number,t.radix||r))}return LNumber([t.number,t.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var t;if(r){var n=parseInt(r[1],16);t=String.fromCodePoint(n)}else{r=e.match(/#\\(.+)$/);if(r){t=r[1]}}if(t){return LCharacter(t)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;function r(e){var r;if(e==="+"){r=LNumber(1)}else if(e==="-"){r=LNumber(-1)}else if(e.match(int_bare_re)){r=LNumber([e,i])}else if(e.match(rational_bare_re)){var t=e.split("/");r=LRational({num:LNumber([t[0],i]),denom:LNumber([t[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(r.valueOf())}return r}var a=num_pre_parse(e);i=a.radix||i;var t;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){t=n}else{t=a.number.match(complex_list_re[i])}var u,o;o=r(t[2]);if(t[1]){u=r(t[1])}else{u=LNumber(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return u}return LComplex({im:o,re:u})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(e){var r=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(r){var t=parseInt(r[4],10);var n;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}t=LFloat(t);if(r.exact){return t.toRational()}return t}function parse_string(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,r){return"\\u"+r.padStart(4,"0")}).replace(/\n/g,"\\n");var r=e.match(/(\\*)(\\x[0-9A-F])/i);if(r&&r[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(r[2]))}try{return LString(JSON.parse(e))}catch(e){throw new Error("Invalid string literal")}}function parse_symbol(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var t={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,r){return String.fromCharCode(parseInt("0"+r,16))}).replace(/\\(.)/g,function(e,r){return t[r]||r})}return new LSymbol(e)}function parse_argument(e){var r=e.match(re_re);if(r){return new RegExp(r[1],r[2])}else if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e.match(char_re)){return parse_character(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}else if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e==="nil"){return nil}else if(["+nan.0","-nan.0"].includes(e)){return LNumber(NaN)}else if(["true","#t","#true"].includes(e)){return true}else if(["false","#f","#false"].includes(e)){return false}else if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant")}else{var t=e.match(/#\\(.+)/);if(t&&ucs2decode(t[1]).length===1){return parse_character(e)}return parse_symbol(e)}}function is_symbol_string(e){return!(["(",")","[","]"].includes(e)||e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var r=/([-\\^$[\]()+{}?*.|])/g;return e.replace(r,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};Stack.prototype.top=function(){return this.data[this.data.length-1]};Stack.prototype.pop=function(){return this.data.pop()};Stack.prototype.is_empty=function(){return!this.data.length};function tokens(e){if(e instanceof LString){e=e.valueOf()}var r=new Lexer(e,{whitespace:true});var t=[];while(true){var n=r.peek(true);if(n===eof){break}t.push(n);r.skip()}return t}function multiline_formatter(e){var r=e.token,t=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(n,"")}return _objectSpread({token:r},t)}function Thunk(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:function(){};this.fn=e;this.cont=r}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var t=tokens(e).map(function(e){if(e.token==="#\\ "){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return strip_s_comments(t)}}function strip_s_comments(e){var r=0;var t=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined$1?arguments[0]:null;if(e instanceof LSymbol){e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return new LSymbol(Symbol("#:".concat(e)))}r++;return new LSymbol(Symbol("#:g".concat(r)))}}();function QuotedPromise(e){var t=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined$1,type:undefined$1};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(r){Object.defineProperty(t,"__".concat(r,"__"),{enumerable:true,get:function e(){return n[r]}})});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};QuotedPromise.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};QuotedPromise.prototype.toString=function(){if(this.__pending__){return QuotedPromise.pending_str}if(this.__rejected__){return QuotedPromise.rejected_str}return"#")};QuotedPromise.pending_str="#";QuotedPromise.rejected_str="#";var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this._specials)},type:function e(r){return this.get(r).type},get:function e(r){return this._specials[r]},off:function e(r){var t=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return t.off(e,n)})}else if(n===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==n})}},on:function e(r,t){var n=this;if(Array.isArray(r)){r.forEach(function(e){return n.on(e,t)})}else if(!this._events[r]){this._events[r]=[t]}else{this._events[r].push(t)}},trigger:function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i",new LSymbol("quote-promise"),specials.LITERAL]];Object.defineProperty(specials,"builtin",{writable:false,value:defined_specials.map(function(e){return e[0]})});defined_specials.forEach(function(e){var r=slicedToArray(e,3),t=r[0],n=r[1],i=r[2];specials.append(t,n,i)});var Lexer=function(){function p(e){var r=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=t.whitespace,i=n===void 0?false:n;classCallCheck(this,p);Object.defineProperty(this,"__input__",{value:e.replace(/\r/g,""),enumerable:true});var a={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(t){Object.defineProperty(r,t,{configurable:false,enumerable:false,get:function e(){return a[t]},set:function e(r){a[t]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(p,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,t){this.__internal[r]=t}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var t=this._line;if(this._whitespace&&this._token==="\n"){--t}return{token:this._token,col:this._col,offset:this._i,line:t}}return this._token}},{key:"peek",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(this._i>=this.__input__.length){return eof}if(this._token){return this.token(r)}var t=this.next_token();if(t){this._token=this.__input__.substring(this._i,this._next);return this.token(r)}return eof}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var r=this.__input__.length;if(this._i>=r){return eof}for(var t=this._i;t=t){return eof}if(r+this._i>=t){return this.read_rest()}var n=this._i+r;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(this.__input__[this._i])}},{key:"read_char",value:function e(){var r=this.peek_char();this.skip_char();return r}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined$1?arguments[1]:{},n=t.prev_char,i=t["char"],a=t.next_char;var u=slicedToArray(r,4),o=u[0],c=u[1],s=u[2],l=u[3];if(r.length!==5){throw new Error("Lexer: Invald rule of length ".concat(r.length))}if(!i.match(o)){return false}if(!match_or_null(c,n)){return false}if(!match_or_null(s,a)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function e(){if(this._i>=this.__input__.length){return false}var r=true;e:for(var t=this._i,n=this.__input__.length;t2&&arguments[2]!==undefined$1?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;if(r.length===0){throw new Error("Lexer: invalid literal rule")}if(r.length===1){return[[r,n,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.env,n=r.meta,i=n===void 0?false:n,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",u,{hidden:true});read_only(this,"_meta",i,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",t)}createClass(o,[{key:"resolve",value:function e(r){return this.__env__&&this.__env__.get(r,{throwError:false})}},{key:"peek",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=this.__lexer__.peek(true);if(!(t===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(t.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(t.token==="#;")){r.next=14;break}this.skip();if(!(this.__lexer__.peek()===eof)){r.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:r.next=13;return this.read_object();case 13:return r.abrupt("continue",0);case 14:return r.abrupt("break",17);case 17:t=this._formatter(t);if(!this._meta){r.next=20;break}return r.abrupt("return",t);case 20:return r.abrupt("return",t.token);case 21:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"is_special",value:function e(r){return specials.names().includes(r)}},{key:"is_builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:t=r.sent;this.skip();return r.abrupt("return",t);case 5:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"is_open",value:function e(r){return["(","["].includes(r)}},{key:"is_close",value:function e(r){return[")","]"].includes(r)}},{key:"read_list",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=nil,n=t;case 1:r.next=4;return this.peek();case 4:i=r.sent;if(!(i===eof)){r.next=7;break}return r.abrupt("break",27);case 7:if(!this.is_close(i)){r.next=10;break}this.skip();return r.abrupt("break",27);case 10:if(!(i==="."&&t!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:n.cdr=r.sent;r.next=25;break;case 17:r.t0=Pair;r.next=20;return this.read_object();case 20:r.t1=r.sent;r.t2=nil;a=new r.t0(r.t1,r.t2);if(t===nil){t=a}else{n.cdr=a}n=a;case 25:r.next=1;break;case 27:return r.abrupt("return",t);case 28:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"read_value",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:t=r.sent;if(!(t===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(t));case 6:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"is_comment",value:function e(r){return r.match(/^;/)||r.match(/^#\|/)&&r.match(/\|#$/)}},{key:"evaluate",value:function e(r){return _evaluate(r,{env:this.__env__,error:function e(r){throw r}})}},{key:"read_object",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u,o,c;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:t=r.sent;if(!(t===eof)){r.next=5;break}return r.abrupt("return",t);case 5:if(!this.is_special(t)){r.next=35;break}n=specials.get(t);i=this.is_builtin(t);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(t)){r.next=19;break}return r.abrupt("return",o.call(this.__env__,u));case 19:if(!(u instanceof Pair)){r.next=21;break}return r.abrupt("return",o.apply(this.__env__,u.to_array(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(n.symbol));case 22:if(is_literal(t)){a=new Pair(n.symbol,new Pair(u,nil))}else{a=new Pair(n.symbol,u)}if(!i){r.next=25;break}return r.abrupt("return",a);case 25:if(!(o instanceof Macro)){r.next=34;break}r.next=28;return this.evaluate(a);case 28:c=r.sent;if(!(c instanceof Pair||c instanceof LSymbol)){r.next=31;break}return r.abrupt("return",Pair.fromArray([LSymbol("quote"),c]));case 31:return r.abrupt("return",c);case 34:throw new Error("Parser: invlid parser extension: ".concat(n.symbol));case 35:if(!this.is_open(t)){r.next=42;break}this.skip();r.next=39;return this.read_list();case 39:return r.abrupt("return",r.sent);case 42:r.next=44;return this.read_value();case 44:return r.abrupt("return",r.sent);case 45:case"end":return r.stop()}}},e,this)}));function r(){return e.apply(this,arguments)}return r}()}]);return o}();function parse(e,r){return _parse.apply(this,arguments)}function _parse(){_parse=wrapAsyncGenerator(regenerator.mark(function e(t,n){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(t,{env:n});case 2:r.next=5;return awaitAsyncGenerator(i.read_object());case 5:a=r.sent;if(!(a===eof)){r.next=8;break}return r.abrupt("break",12);case 8:r.next=10;return a;case 10:r.next=2;break;case 12:case"end":return r.stop()}}},e)}));return _parse.apply(this,arguments)}function unpromise(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:function(e){return e};var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var n=r.filter(is_promise);if(n.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},t)}return e(r)}if(is_plain_object(r)){var i=Object.keys(r);var a=i.map(function(e){return r[e]});var u=a.filter(is_promise);if(u.length){return unpromise(Promise.all(a),function(e){var n={};e.forEach(function(e,r){var t=i[r];n[t]=e});if(Object.isFrozen(r)){Object.freeze(n)}return n},t)}}if(is_promise(r)){var o=r.then(e);if(t===null){return o}else{return o["catch"](t)}}return e(r)}function read_only(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,r,{value:t,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(t){var n,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=[];i=true;a=false;r.prev=3;o=asyncIterator(t);case 5:r.next=7;return o.next();case 7:c=r.sent;i=c.done;r.next=11;return c.value;case 11:s=r.sent;if(i){r.next=18;break}l=s;n.push(l);case 15:i=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);a=true;u=r.t0;case 24:r.prev=24;r.prev=25;if(!(!i&&o["return"]!=null)){r.next=29;break}r.next=29;return o["return"]();case 29:r.prev=29;if(!a){r.next=32;break}throw u;case 32:return r.finish(29);case 33:return r.finish(24);case 34:return r.abrupt("return",n);case 35:case"end":return r.stop()}}},e,null,[[3,20,24,34],[25,,29,33]])}));return _uniterate_async.apply(this,arguments)}function matcher(e,r){if(r instanceof RegExp){return function(e){return String(e).match(r)}}else if(is_function(r)){return r}}function doc(e,r,t,n){if(typeof e!=="string"){r=arguments[0];t=arguments[1];n=arguments[2];e=null}if(t){if(n){r.__doc__=t}else{r.__doc__=trim_lines(t)}}if(e){r.__name__=e}else if(r.name&&!r[__lambda__]){r.__name__=r.name}return r}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:1;var t=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&t>=0){var n=1;while(n>0){var i=e[--t];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}t--}return e.slice(t+1)}function lineIndent(e){if(!e||!e.length){return 0}var r=e.length;if(e[r-1].token==="\n"){return 0}while(--r){if(e[r].token==="\n"){var t=(e[r+1]||{}).token;if(t){return t.length}}}return 0}function match(e,r){return l(e,r)===r.length;function l(t,n){function e(e,r){var t=_createForOfIteratorHelper(e),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;var a=l(i,r);if(a!==-1){return a}}}catch(e){t.e(e)}finally{t.f()}return-1}function r(){return t[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[o])}function i(){var e=t[a+1];var r=n[o+1];if(e!==undefined$1&&r!==undefined$1){return l([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var s=l(t[a],n.slice(o));if(s===-1||s+o>n.length){return-1}o+=s-1;a++;continue}else{return-1}a++}if(t.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var t=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},t)}var n=r&&r.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},t),r),{},{exceptions:{specials:[].concat(toConsumableArray(t.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(t.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var t=tokenize(this.__code__,true);return this._indent(t,r)};Formatter.exception_shift=function(a,e){function r(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var r=e.filter(function(e){return e instanceof RegExp});if(!r.length){return false}var t=_createForOfIteratorHelper(r),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;if(a.match(i)){return true}}}catch(e){t.e(e)}finally{t.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var t=e.exceptions.shift;for(var n=0,i=Object.entries(t);n0){n.offset=0}if(a.toString()===r.toString()&&balanced(a)){return n.offset+a[0].col}else if(a.length===1){return n.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,n);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,n)}if(c!==-1){return n.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return n.offset+a[1].col}return n.offset+a[3].col}else if(a[0].line===a[1].line){return n.offset+n.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var glob=Symbol["for"]("*");var sexp_or_atom=new Pattern([p_o,glob,p_e],[not_p],"+");var sexp=new Pattern([p_o,glob,p_e],"+");var symbol=new Pattern([Symbol["for"]("symbol")],"?");var symbols=new Pattern([Symbol["for"]("symbol")],"*");var identifiers=[p_o,symbols,p_e];var let_value=new Pattern([p_o,Symbol["for"]("symbol"),glob,p_e],"+");var def_lambda_re=keywords_re("define","lambda","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define|let(?:\*|rec|-env|-syntax)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,r=new Array(e),t=0;t0&&!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(n),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],_=s[2];f=f.valueOf();var p=f>0?u[f]:a;var h=match(l,p.filter(function(e){return e.trim()}));var d=t.slice(i).find(function(e){return e.trim()});if(h&&(_ instanceof Ahead&&_.match(d)||!_)){if(!t[i-1].trim()){t[i-1]="\n"}else{t.splice(i,0,"\n");i++}continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=t.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var n=tokenize(t,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o0&&arguments[0]!==undefined$1?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var r=new Pair;n.set(e,r);if(t){r.car=i(e.car)}else{r.car=e.car}r.cdr=i(e.cdr);r[__cycles__]=e[__cycles__];return r}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var r=[];if(this.car instanceof Pair){if(e){r.push(this.car.to_array())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.to_array())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||t&&e instanceof Array&&e[__data__]){return e}if(r===false){var n=nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=toConsumableArray(e)}var a=nil;var u=e.length;while(u--){var o=e[u];if(o instanceof Array){o=Pair.fromArray(o,r,t)}else if(typeof o==="string"){o=LString(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=LNumber(o)}a=new Pair(o,a)}return a};Pair.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var t={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var n=r.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}t[i]=a;r=r.cdr}else{break}}return t};Pair.fromPairs=function(e){return e.reduce(function(e,r){return new Pair(new Pair(new LSymbol(r[0]),r[1]),e)},nil)};Pair.fromObject=function(r){var e=Object.keys(r).map(function(e){return[e,r[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var r=this;var t=nil;while(true){if(r!==nil){t=e(t,r.car);r=r.cdr}else{break}}return t};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var r=nil;while(e!==nil){var t=e.cdr;e.cdr=r;r=e;e=t}return r};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=n(e.car);if(r instanceof Pair){r=i(r)}var t=n(e.cdr);if(t instanceof Pair){t=i(t)}return new Pair(r,t)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===nil?nil:this.cdr.map(e))}else{return nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof_1(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(e[__lambda__]||e.__doc__)}function user_repr(t){var e=t.constructor||Object;var n=is_plain_object(t);var i=is_function(t[Symbol.asyncIterator])||is_function(t[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(t.constructor===r&&(r===Object&&n&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];str_mapping.set(t,n)});function symbolize(t){if(t&&_typeof_1(t)==="object"){var n={};var e=Object.getOwnPropertySymbols(t);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[r]=toString(t[e])});var r=Object.getOwnPropertyNames(t);r.forEach(function(e){var r=t[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){n[e]=symbolize(r)}else{n[e]=toString(r)}});return n}return t}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,r){return e.hasOwnProperty(r)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var t=r.__name__;if(LString.isString(t)){t=t.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,function(e,r){var t=r.quote,n=r.skip_cycles,i=r.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[t].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var t=r.quote;if(t){return e.toString()}return e.valueOf()}],[LString,function(e,r){var t=r.quote;e=e.toString();if(t){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];instances.set(t,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var n=e.constructor;if(instances.has(n)){for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var l=e.constructor;if(!l){l=Object}var f;if(typeof l.__class__==="string"){f=l.__class__}else{if(is_prototype(e)){return"#"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}f=l.name}if(type(e)==="instance"&&!is_native_function(l)){f="instance"}if(is_iterator(e,Symbol.iterator)){if(f){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#")}return"#"}if(f!==""){return"#<"+f+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof_1(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[__cycles__]&&this[__cycles__][e])};function markCycles(e){var r=[];var i=[];var a=[];function u(e){if(!r.includes(e)){r.push(e)}}function o(e,r,t,n){if(t instanceof Pair){if(n.includes(t)){if(!a.includes(t)){a.push(t)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=t;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,t){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);t.push(r);var n=o(r,"car",r.car,t);var i=o(r,"cdr",r.cdr,t);if(!n){c(r.car,t.slice())}if(!i){return new Thunk(function(){return e(r.cdr,t.slice())})}}});function t(e,r){if(e[__cycles__][r]instanceof Pair){var t=n.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(t,"#")}}c(e,[]);var n=r.filter(function(e){return a.includes(e)});n.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){t(e,"car");t(e,"cdr")})}var pair_to_string=function(){var f=function e(r,t){var n=[];if(r[__ref__]){n.push(r[__ref__]+"(")}else if(!t){n.push("(")}return n};var _=function e(r,t){if(is_debug());if(!t||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,t){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=n.nested,a=i===void 0?false:i,u=n.result,o=u===void 0?[]:u,c=n.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(_(r,a)))}:c;o.push.apply(o,toConsumableArray(f(r,a)));var l;if(r[__cycles__]&&r[__cycles__].car){l=r[__cycles__].car}else{l=toString(r.car,t,true,{result:o,cont:s})}if(l!==undefined$1){o.push(l)}return new Thunk(function(){if(r.cdr instanceof Pair){if(r[__cycles__]&&r[__cycles__].cdr){o.push(" . ");o.push(r[__cycles__].cdr)}else{if(r.cdr[__ref__]){o.push(" . ")}else{o.push(" ")}return e(r.cdr,t,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,t))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.nested,n=t===void 0?false:t;if(is_debug()){var i=[];pair_to_string(this,e,{result:i});return i.join("")}var a=[];if(this[__ref__]){a.push(this[__ref__]+"(")}else if(!n){a.push("(")}var u;if(this[__cycles__]&&this[__cycles__].car){u=this[__cycles__].car}else{u=toString(this.car,e,true)}if(u!==undefined$1){a.push(u)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){a.push(" . ");a.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){a.push(" . ")}else{a.push(" ")}var o=this.cdr.toString(e,{nested:true});a.push(o)}}else if(this.cdr!==nil){a=a.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){a.push(")")}return a.join("")};Pair.prototype.set=function(e,r){this[e]=r;if(r instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var r=this;if(r.car===undefined$1){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==nil){while(true){if(r instanceof Pair&&r.cdr!==nil){r=r.cdr}else{break}}r.cdr=e}return this};function abs(e){return e<0?-e:e}function seq_compare(e,r){var t=toArray(r),n=t[0],i=t.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(n,o)){return false}var c=i;var s=toArray(c);n=s[0];i=s.slice(1)}return true}function equal(e,r){if(is_function(e)){return is_function(r)&&unbind(e)===unbind(r)}else if(e instanceof LNumber){if(!(r instanceof LNumber)){return false}var t;if(e.__type__===r.__type__){if(e.__type__==="complex"){t=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{t=true}if(t&&e.cmp(r)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),r.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(r)}if(e===Number.NEGATIVE_INFINITY){return r===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return r===Number.POSITIVE_INFINITY}return equal(LNumber(e),LNumber(r))}else if(e instanceof LCharacter){if(!(r instanceof LCharacter)){return false}return e.__char__===r.__char__}else{return e===r}}function same_atom(e,r){if(type(e)!==type(r)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===r.source}if(e instanceof LString){return e.valueOf()===r.valueOf()}return equal(e,r)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,t,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,r)}typecheck("Macro",e,"string",1);typecheck("Macro",r,"function",2);if(t){if(n){this.__doc__=t}else{this.__doc__=trim_lines(t)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,t,n){var i=new Macro(e,r,t,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,t){var n=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:t};var o=this.__fn__.call(n,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var t=asyncToGenerator(regenerator.mark(function e(t,h){var n,d,i;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=function e(){i=asyncToGenerator(regenerator.mark(function e(t,n,i){var a,u,o,c,s,l,f,_,p;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(t instanceof Pair&&t.car instanceof LSymbol)){r.next=26;break}if(!t[__data__]){r.next=3;break}return r.abrupt("return",t);case 3:a=i.get(t.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?t:t.cdr;r.next=8;return a.invoke(u,_objectSpread(_objectSpread({},h),{},{env:i}),true);case 8:o=r.sent;if(!(a instanceof Syntax)){r.next=17;break}c=o,s=c.expr,l=c.scope;if(!(s instanceof Pair)){r.next=16;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var t=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=t.expansion,F=t.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:false;A({code:r&&toString(r,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,r)}if(e instanceof LSymbol&&D.includes(e.valueOf())){var i=x.ref(r);if(LSymbol.is(r,e)){if(typeof i==="undefined"){return true}return i===F||i===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,w)){A(">> 0");if(r===nil){A({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,w)){var a=e.car.car.valueOf();var u=e.last_pair();if(LSymbol.is(u.car,w)){L["..."].symbols[a]=null;return true}else{return false}}var o=e.car.car.valueOf();if(L["..."].symbols[o]){throw new Error("syntax: named ellipsis can only "+"appear onces")}L["..."].symbols[o]=r}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,w)){if(e.cdr.cdr!==nil){if(e.cdr.cdr instanceof Pair){var c=e.cdr.cdr.length();var s=r.length();var l=r;while(s-1>c){l=l.cdr;s--}var f=l.cdr;l.cdr=nil;if(!E(e.cdr.cdr,f,t,n)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!t.includes(_)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(n){A("NIL");L["..."].symbols[_]=nil}else{A("NULL");L["..."].symbols[_]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+n);if(n){if(L["..."].symbols[_]){var p=L["..."].symbols[_];if(p===nil){p=new Pair(nil,new Pair(r,nil))}else{p=p.append(new Pair(r,nil))}L["..."].symbols[_]=p}else{L["..."].symbols[_]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[_]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+n);t.push(_);if(!L["..."].symbols[_]){L["..."].symbols[_]=new Pair(r,nil)}else{var h=L["..."].symbols[_];L["..."].symbols[_]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[_].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(t);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var m=r;while(m instanceof Pair){if(!E(e.car,m.car,d,true)){return false}m=m.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,w)){throw new Error("syntax: invalid usage of ellipsis")}A(">> 11");var v=e.__name__;if(D.includes(v)){return true}A({name:v,ellipsis:n});if(n){L["..."].symbols[v]=L["..."].symbols[v]||[];L["..."].symbols[v].push(r)}L.symbols[v]=r;if(!L.symbols[v]);return true}if(e instanceof Pair&&r instanceof Pair){A(">> 12");A({a:12,code:r&&r.toString(),pattern:e.toString()});if(r.cdr===nil){var y=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(y){if(!E(e.car,r.car,t,n)){return false}A(">> 12 | 1");var b=e.cdr.valueOf();if(!(b in L.symbols)){L.symbols[b]=nil}b=e.car.valueOf();if(!(b in L.symbols)){L.symbols[b]=r.car}return true}}A({pattern:e.toString(),code:r.toString()});if(e.cdr instanceof Pair&&e.car instanceof LSymbol&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,w)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,w)&&E(e.car,r.car,t,n)&&E(e.cdr.cdr.cdr,r.cdr,t,n)){var g=e.cdr.car.__name__;A({pattern:e.car.toString(),code:r.car.toString(),name:g});if(D.includes(g)){return true}L["..."].symbols[g]=null;return true}A("recur");if(E(e.car,r.car,t,n)&&E(e.cdr,r.cdr,t,n)){return true}}else if(e===nil&&(r===nil||r===undefined$1)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,w)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(E(e,r)){return L}}function clear_gensyms(e,i){function a(r){if(r instanceof Pair){if(!i.length){return r}var e=a(r.car);var t=a(r.cdr);return new Pair(e,t)}else if(r instanceof LSymbol){var n=i.find(function(e){return e.gensym===r});if(n){return LSymbol(n.name)}return r}else{return r}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:{};var A=e.bindings,r=e.expr,E=e.scope,u=e.symbols,a=e.names,S=e.ellipsis;var o={};function c(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof_1(e))}function P(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var t=e.valueOf();if(t===S){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof_1(t);if(["string","symbol"].includes(n)){if(t in A.symbols){return A.symbols[t]}else if(n==="string"&&t.match(/\./)){var i=t.split(".");var a=i[0];if(a in A.symbols){return Pair.fromArray([LSymbol("."),A.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(u.includes(t)){return LSymbol(t)}return s(t)}function C(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var t=gensym(e);if(r){var n=E.get(e);E.set(t,n)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(t,i)}}a.push({name:e,gensym:t});o[e]=t}return o[e]}function k(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=t.nested;C(" ==> "+e.toString(true));C(r);if(e instanceof LSymbol){var a=e.valueOf();C("[t 1");if(r[a]){if(r[a]instanceof Pair){var u=r[a],o=u.car,c=u.cdr;if(i){var s=o.car,l=o.cdr;if(l!==nil){n(a,new Pair(l,nil))}return s}if(c!==nil){n(a,c)}return o}else if(r[a]instanceof Array){n(a,r[a].slice(1));return r[a][0]}}return P(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){C("[t 2");var f=e.car.valueOf();var _=r[f];C({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){C({b:r[f].toString()});if(_ instanceof Pair){C("[t 2 Pair "+i);C({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){C("|| next 1");n(f,h)}C({car:p.toString()});return p}else{if(p.cdr!==nil){C("|| next 2");n(f,new Pair(p.cdr,h))}C({car:p.car.toString()});return p.car}}else if(_ instanceof Array){C("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){n(f,d)}return _[0]}}else{return _}}}C("[t 3 recur "+e.toString());var m=k(e.car,r,t,n);var v=k(e.cdr,r,t,n);return new Pair(m,v)}return e}function N(r,t){var e=Object.values(r);var n=Object.getOwnPropertySymbols(r);if(n.length){e.push.apply(e,toConsumableArray(n.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!t}return e instanceof Pair||e===nil||e instanceof Array&&e.length})}function O(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function B(i){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},r=e.disabled;C("traverse>> "+i.toString());if(i instanceof Pair){if(!r&&i.car instanceof Pair&&LSymbol.is(i.car.car,S)){return B(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,S)&&!r){C(">> 1");var t=A["..."].symbols;var n=Object.values(t);if(n.length&&n.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(t);var u=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,S);if(i.car instanceof Pair||u){if(A["..."].lists[0]===nil){return nil}var o=i.car;if(u){o=new Pair(i.car,new Pair(i.cdr.car,nil))}C(">> 2");var c;if(a.length){C(">> 2 (a)");var s=_objectSpread({},t);c=nil;var l=function e(){if(!N(s)){return"break"}var n={};var r=function e(r,t){n[r]=t};var t=k(o,s,{nested:true},r);if(t!==undefined$1){if(u){if(c===nil){c=t}else{c=c.append(t)}}else{c=new Pair(t,c)}}s=n};while(true){var f=l();if(f==="break")break}if(c!==nil&&!u){c=c.reverse()}if(i.cdr.cdr!==nil&&!LSymbol.is(i.cdr.cdr.car,S)){var _=B(i.cdr.cdr,{disabled:r});return c.append(_)}return c}else{C(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){C(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){C(">> 4 (a)")}else{C(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,t[h]);var m=t[h]===null;var v=nil;var y=function e(){if(!N(d,true)){C({bind:d});return"break"}var n={};var r=function e(r,t){n[r]=t;if(is_debug()){console.log({NEWBIND:n[r].toString()})}};var t=k(i,d,{nested:false},r);C({value:t.toString()});if(typeof t!=="undefined"){v=new Pair(t,v)}d=n};while(true){var b=y();if(b==="break")break}if(v!==nil){v=v.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var g=B(i.cdr.cdr,{disabled:r});if(m){return g}C("<<<< 1");v.append(g)}}C("<<<< 2");return v}}var D=B(i.car,{disabled:r});var w;var L;if(i.car instanceof LSymbol){var x=E.get(i.car,{throwError:false});L=x instanceof Macro&&x.__name__==="syntax-rules"}if(L){if(i.cdr.car instanceof LSymbol){w=new Pair(B(i.cdr.car,{disabled:r}),new Pair(i.cdr.cdr.car,B(i.cdr.cdr.cdr,{disabled:r})))}else{w=new Pair(i.cdr.car,B(i.cdr.cdr,{disabled:r}))}}else{w=B(i.cdr,{disabled:r})}C({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(D),rest:toString(w)});return new Pair(D,w)}if(i instanceof LSymbol){if(r&&LSymbol.is(i,S)){return i}var F=P(i);if(typeof F!=="undefined"){return F}}return i}return B(r,{})}function is_null(e){return typeof e==="undefined"||e===nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return e&&typeof e!=="undefined"&&is_function(e.then)}function box(e){switch(_typeof_1(e)){case"string":return LString(e);case"number":if(!Number.isNaN(e)){return LNumber(e)}}return e}function map_object(n,i){var e=Object.getOwnPropertyNames(n);var r=Object.getOwnPropertySymbols(n);e.concat(r).forEach(function(e){var r=i(n[e]);var t=Object.getOwnPropertyDescriptor(n,e);if(!t||t.writable&&n[e]!==r){n[e]=r}});return n}function unbox(r){var e=[LString,LCharacter,LNumber].some(function(e){return r instanceof e});if(e){return r.valueOf()}if(r instanceof Array){return r.map(unbox)}if(is_plain_object(r)){return map_object(r,unbox)}return r}function patch_value(e,r){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(r){return bind(e,r)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(r,e){if(r[Symbol["for"]("__bound__")]){return r}var t=r.bind(e);var n=Object.getOwnPropertyNames(r).filter(filter_fn_names);n.forEach(function(e){try{t[e]=r[e]}catch(e){}});hidden_prop(t,"__fn__",r);hidden_prop(t,"__context__",e);hidden_prop(t,"__bound__",true);if(is_native_function(r)){hidden_prop(t,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(t,"__method__",true)}t.valueOf=function(){return r};return t}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var r=e[__context__];if(r&&(r===lips||r.constructor&&r.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}var __context__=Symbol["for"]("__context__");var __fn__=Symbol["for"]("__fn__");var __data__=Symbol["for"]("__data__");var __ref__=Symbol["for"]("__ref__");var __cycles__=Symbol["for"]("__cycles__");var __class__=Symbol["for"]("__class__");var __method__=Symbol["for"]("__method__");var __prototype__=Symbol["for"]("__prototype__");var __lambda__=Symbol["for"]("__lambda__");var exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,r,t){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return t},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,t){try{Object.defineProperty(r,"length",{get:function e(){return t}});return r}catch(e){var n=new Array(t).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(r)}}function is_native_function(e){var r=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[r]===true||!e.name.match(/^bound /)&&!e[r])}function let_macro(e){var h;switch(e){case Symbol["for"]("letrec"):h="letrec";break;case Symbol["for"]("let"):h="let";break;case Symbol["for"]("let*"):h="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(h,function(r,e){var a=e.dynamic_scope,u=e.error,t=e.macro_expand;var o;if(r.car instanceof LSymbol){if(!(r.cdr.car instanceof Pair||r.cdr.car===nil)){throw new Error("let require list of pairs")}var n;if(r.cdr.car===nil){o=nil;n=nil}else{n=r.cdr.car.map(function(e){return e.car});o=r.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[r.car,Pair(LSymbol("lambda"),Pair(n,r.cdr.cdr))]],Pair(r.car,o)])}else if(t){return}var c=this;o=global_env.get("list->array")(r.car);var s=c.inherit(h);var l,f;if(h==="let*"){f=s}else if(h==="let"){l=[]}var _=0;function p(){var e=new Pair(new LSymbol("begin"),r.cdr);return _evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var t=o[_++];if(a){a=h==="let*"?s:c}if(!t){if(l&&l.length){var e=l.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return Promise.all(e).then(function(e){for(var r=0,t=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.dynamic_scope,n=r.error;var i=this;if(t){t=this}var a=e;var u=[];while(a instanceof Pair){u.push(_evaluate(a.car,{env:i,dynamic_scope:t,error:n}));a=a.cdr}var o=u.filter(is_promise).length;if(o){return Promise.all(u).then(c.bind(this))}else{return c.call(this,u)}})}function guardMathCall(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n2?n-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t1?e-1:0),t=1;t=u){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),t=0;t1){e=e.toLowerCase();if(LCharacter.__names__[e]){r=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{r=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(r){Object.defineProperty(this,"__name__",{value:r,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var r=LCharacter.__names__[e];LCharacter.__rev_names__[r]=e});LCharacter.prototype.toUpperCase=function(){return LCharacter(this.__char__.toUpperCase())};LCharacter.prototype.toLowerCase=function(){return LCharacter(this.__char__.toLowerCase())};LCharacter.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};LCharacter.prototype.valueOf=function(){return this.__char__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,r){typecheck("LString",e,"character",r+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=function e(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t0){t.push(this.__string__.substring(0,e))}t.push(r);if(e1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,r)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var t=LNumber.getType(e);if(LNumber.types[t]){return LNumber.types[t](e,r)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var a=e,u=slicedToArray(a,2),o=u[0],c=u[1];if(o instanceof LString){o=o.valueOf()}if(c instanceof LNumber){c=c.valueOf()}var s=o.match(/^([+-])/);var l=false;if(s){o=o.replace(/^[+-]/,"");if(s[1]==="-"){l=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var f;switch(c){case 8:f="0o";break;case 16:f="0x";break;case 2:f="0b";break;case 10:f="";break}if(typeof f==="undefined"){var _=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(_,BigInt(r))}).reduce(function(e,r){return e+r})}else{i=BigInt(f+o)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(construct(BN,toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(o,c),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,r){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:r,enumerable:true})};LNumber.types={float:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,t)},complex:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,t)},rational:function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,t)}};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var t=r;r=e;e=t}while(true){r=r.rem(e);if(r.cmp(0)===0){return e}e=e.rem(r);if(e.cmp(0)===0){return r}}};LNumber.isFloat=function e(r){return r instanceof LFloat||Number(r)===r&&r%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var r=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return r};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,r){if(e instanceof LFloat||r instanceof LFloat){return LFloat}if(e instanceof LBigInteger||r instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.prototype.toString=LNumber.prototype.toJSON=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};LNumber.prototype.asType=function(e){var r=LNumber.getType(this);return LNumber.types[r]?LNumber.types[r](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](this.valueOf()))}}});LNumber.prototype.valueOf=function(){if(LNumber.isNative(this.__value__)){return Number(this.__value__)}else if(LNumber.isBN(this.__value__)){return this.__value__.toNumber()}};var matrix=function(){var e=function e(r,t){return[r,t]};return{bigint:{bigint:e,float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:function e(r,t){return[{num:r,denom:1},t]},complex:function e(r,t){return[{im:0,re:r},t]}},integer:{integer:e,float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:function e(r,t){return[{num:r,denom:1},t]},complex:function e(r,t){return[{im:0,re:r},t]}},float:{bigint:function e(r,t){return[r,t&&LFloat(t.valueOf())]},integer:function e(r,t){return[r,t&&LFloat(t.valueOf())]},float:e,rational:function e(r,t){return[r,t&&LFloat(t.valueOf())]},complex:function e(r,t){return[{re:r,im:LFloat(0)},t]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,t){var n=LNumber.coerce(r.__re__,t.__re__),i=slicedToArray(n,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,t.__im__),c=slicedToArray(o,2),s=c[0],l=c[1];return[{im:s,re:a},{im:l,re:u}]}},rational:{bigint:function e(r,t){return[r,t&&{num:t,denom:1}]},integer:function e(r,t){return[r,t&&{num:t,denom:1}]},float:function e(r,t){return[LFloat(r.valueOf()),t]},rational:e,complex:function e(r,t){return[{im:coerce(r.__type__,t.__im__.__type__,0)[0],re:coerce(r.__type__,t.__re__.__type__,r)[0]},{im:coerce(r.__type__,t.__im__.__type__,t.__im__)[0],re:coerce(r.__type__,t.__re__.__type__,t.__re__)[0]}]}}};function r(t){return function(e,r){return[{im:coerce(t,e.__im__.__type__,0,e.__im__)[1],re:coerce(t,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(t,e.__im__.__type__,0,0)[1],re:coerce(t,r.__type__,0,r)[1]}]}}}();function coerce(e,r,t,n){return matrix[e][r](t,n)}LNumber.coerce=function(e,r){var t=LNumber.getType(e);var n=LNumber.getType(r);if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[t][n](e,r);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(r){rev_mapping[mapping[r]]=r;LNumber.prototype[r]=function(e){return this.op(mapping[r],e)}});LNumber._ops={"*":function e(r,t){return r*t},"+":function e(r,t){return r+t},"-":function e(r,t){if(typeof t==="undefined"){return-r}return r-t},"/":function e(r,t){return r/t},"%":function e(r,t){return r%t},"|":function e(r,t){return r|t},"&":function e(r,t){return r&t},"~":function e(r){return~r},">>":function e(r,t){return r>>t},"<<":function e(r,t){return r<1&&arguments[1]!==undefined$1?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LComplex)||typeof this==="undefined"){return new LComplex(e,r)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&r){if(!r){return Number(e)}}else if(!LNumber.isComplex(e)){throw new Error("Invalid constructor call for LComplex")}var t=e.im instanceof LNumber?e.im:LNumber(e.im);var n=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(t,n)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.constant=function(e,r){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:r,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var t=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:t})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,t,n){return{re:e.add(r),im:t.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var t,n;if(e instanceof LFloat){t=e.toRational().mul(e.toRational())}else{t=e.mul(e)}if(r instanceof LFloat){n=r.toRational().mul(r.toRational())}else{n=r.mul(r)}return t.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.conjugate=function(){return LComplex({re:this.__re__,im:this.__im__.sub()})};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,t;if(e.cmp(0)===0){r=t=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();t=this.__im__.div(r).div(2)}else{t=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){t=t.sub()}r=this.__im__.div(t).div(2)}return LComplex({im:t,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var r=this.__re__.div(e);var t=this.__im__.div(e);return LComplex({re:r,im:t})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var n=this.coerce(e),i=slicedToArray(n,2),a=i[0],u=i[1];var o=u.factor();var c=a.mul(u.conjugate());var s=c.__re__.op("/",o);var l=c.__im__.op("/",o);return LComplex({re:s,im:l})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,t,n){return{re:e.sub(r),im:t.sub(n)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,t,n){var i={re:e.mul(r).sub(t.mul(n)),im:e.mul(n).add(r.mul(t))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var t=function e(r,t){var n=i(a.__re__,r,a.__im__,t);if("im"in n&&"re"in n){if(n.im.cmp(0)===0&&!LNumber.isFloat(n.im)){return n.re}return LComplex(n,true)}return n};if(typeof r==="undefined"){return t()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var n=r.asType(0);r={__im__:n,__re__:r}}else if(!LNumber.isComplex(r)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var u=r.__re__ instanceof LNumber?r.__re__:this.__re__.asType(r.__re__);var o=r.__im__ instanceof LNumber?r.__im__:this.__im__.asType(r.__im__);return t(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var t=LComplex._op[e];return this[t](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=n.__re__.coerce(i.__re__),u=slicedToArray(a,2),o=u[0],c=u[1];var s=o.cmp(c);if(s!==0){return s}else{var l=n.__im__.coerce(i.__im__),f=slicedToArray(l,2),_=f[0],p=f[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var r=this.__im__.valueOf();var t=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var n=toString(this.__im__);if(!t&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var r=e+".0";return this._minus?"-"+r:r}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var t=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(t(this.__value__,r))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var r=function e(n,r,t){var i=function e(r,t){return t0){i=simplest_rational2(n,t)}else if(n.cmp(t)<=0){i=t}else if(t.cmp(0)>0){i=simplest_rational2(t,n)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),t.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var t=LNumber(e).floor();var n=LNumber(r).floor();if(e.cmp(t)<1){return t}else if(t.cmp(n)===0){var i=LNumber(1).div(r.sub(n));var a=LNumber(1).div(e.sub(t));return t.add(LNumber(1).div(simplest_rational2(i,a)))}else{return t.add(LNumber(1))}}function LRational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,r)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var t,n;if(e instanceof LRational){t=LNumber(e.__num__);n=LNumber(e.__denom__)}else{t=LNumber(e.num);n=LNumber(e.denom)}if(!r&&n.cmp(0)!==0){var i=t.op("%",n).cmp(0)===0;if(i){return LNumber(t.div(n))}}this.constant(t,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.constant=function(e,r){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:r,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var t=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:t,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var r=this.__denom__.sqrt();if(e instanceof LFloat){e=(readOnlyError("num"),e.toRational())}if(r instanceof LFloat){r=(readOnlyError("denom"),r.toRational())}return LRational({num:e,denom:r})};LRational.prototype.abs=function(){var e=this.__num__;var r=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(r.cmp(0)!==1){r=r.sub()}return LRational({num:e,denom:r})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var r,t;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}t=this.__denom__.div(e);if(t instanceof LRational){t=LNumber(t.valueOf(true))}}else{r=this.__num__;t=this.__denom__}var n=this.cmp(0)<0;if(n){if(r.abs().cmp(t.abs())===0){return r.toString()}}else if(r.cmp(t)===0){return r.toString()}return r.toString()+"/"+t.toString()};LRational.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__num__.mul(e.__num__);var t=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:t})}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];return a.mul(u)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__num__.mul(e.__denom__);var t=this.__denom__.mul(e.__num__);return LRational({num:r,denom:t})}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];var o=a.div(u);return o};LRational.prototype._op=function(e,r){return this[rev_mapping[e]](r)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=e.__num__.sub();var t=e.__denom__;return this.add(LRational({num:r,denom:t}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=slicedToArray(n,2),a=i[0],u=i[1];return a.add(u)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var r=this.__denom__;var t=e.__denom__;var n=this.__num__;var i=e.__num__;var a,u;if(r!==t){u=t.mul(n).add(i.mul(r));a=r.mul(t)}else{u=n.add(i);a=r}return LRational({num:u,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var o=LNumber.coerce(this,e),c=slicedToArray(o,2),s=c[0],l=c[1];return s.add(l)};function LBigInteger(e,r){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,r)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:r})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype._op=function(e,r){if(typeof r==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(r.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](r),false)}var t=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var n=this.op("%",r).cmp(0)===0;if(n){return LNumber(t)}return LRational({num:this,denom:r})}return LBigInteger(t,true)};LBigInteger.prototype.sqrt=function(){var e;var r=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(r?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=r?this.__value__.neg().sqrt():this.__value__.sqrt()}if(r){return LComplex({re:0,im:e})}return e};function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(r){typecheck("InputPort::__parser__",r,"parser");i=r}});this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(n.char_ready()){r.next=5;break}r.next=3;return n._read();case 3:t=r.sent;i=new Parser(t,{env:n});case 5:return r.abrupt("return",n.__parser__);case 6:case"end":return r.stop()}}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==eof};this._make_defaults()}InputPort.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,r){if(!LNumber.isInteger(r)){var t=LNumber.getType(r);typeErrorMessage("read-string",t,"integer")}return e.__lexer__.read_string(r.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(o,c){var s=this;return function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u=arguments;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return o.call(s);case 2:t=r.sent;for(n=u.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};OutputPort.prototype.toString=function(){return"#"};function OutputStringPort(r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");read_only(this,"__type__",text_port);read_only(this,"__buffer__",[]);this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}t.__buffer__.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.constructor=OutputStringPort;OutputStringPort.prototype.toString=function(){return"#"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",r.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}t.fs().write(t._fd,e,function(e){if(e){throw e}})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};OutputFilePort.prototype.internal=function(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(r,t){n.fs().close(n._fd,function(e){if(e){t(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var t=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");r=r||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!t.__parser__){t.__parser__=new Parser(e,{env:r})}return t.__parser__});read_only(this,"__type__",text_port);this._make_defaults()}InputStringPort.prototype.char_ready=function(){return true};InputStringPort.prototype=Object.create(InputPort.prototype);InputStringPort.prototype.constructor=InputStringPort;InputStringPort.prototype.toString=function(){return"#"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var t=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return t},set:function e(r){typecheck("InputByteVectorPort::__index__",r,"number");if(r instanceof LNumber){r=r.valueOf()}if(typeof r==="bigint"){r=Number(r)}if(Math.floor(r)!==r){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}t=r}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var r=this;read_only(this,"__vector__",nil);["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){r[e]=function(){throw new Error("Input-binary-port: port is closed")}});this.char_ready=function(){return false}};InputByteVectorPort.prototype.u8_ready=function(){return true};InputByteVectorPort.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return eof}return this.__vector__[this.__index__]};InputByteVectorPort.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};InputByteVectorPort.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};InputByteVectorPort.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===eof){return eof}return this.__vector__.slice(this.__index__,e)};function OutputByteVectorPort(){if(typeof this!=="undefined"&&!(this instanceof OutputByteVectorPort)||typeof this==="undefined"){return new OutputByteVectorPort}read_only(this,"__type__",binary_port);read_only(this,"_buffer",[],{hidden:true});this.write=function(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var r;(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}OutputByteVectorPort.prototype=Object.create(OutputPort.prototype);OutputByteVectorPort.prototype.constructor=OutputByteVectorPort;OutputByteVectorPort.prototype.close=function(){OutputPort.prototype.close.call(this);read_only(this,"_buffer",null,{hidden:true})};OutputByteVectorPort.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};OutputByteVectorPort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,r)}InputStringPort.call(this,e);typecheck("InputFilePort",r,"string");read_only(this,"__filename__",r)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,r)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",r,"string");read_only(this,"__filename__",r)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,r){if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,r)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",r.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a,t;this.write=function(e){var n=this;typecheck("write",e,["number","uint8array"]);var i;if(!a){a=this.internal("fs")}if(!t){t=this.internal("Buffer")}if(LNumber.isNumber(e)){i=t.from([e.valueOf()])}else{i=t.from(Array.from(e))}return new Promise(function(r,t){a.write(n._fd,i,function(e){if(e){t(e)}else{r()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.stderr,n=r.stdin,i=r.stdout,a=objectWithoutProperties(r,["stderr","stdin","stdout"]);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:n,stdout:i,stderr:t},a))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,a);var u="**interaction-environment-defaults**";this.set(u,get_props(a).concat(u));var o=internal_env.inherit("internal-".concat(e));if(is_port(n)){o.set("stdin",n)}if(is_port(t)){o.set("stderr",t)}if(is_port(i)){o.set("stdout",i)}set_interaction_env(this.__env__,o)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;typecheck("Interpreter::exec",e,"string",1);typecheck("Interpreter::exec",r,"boolean",2);global_env.set("**interaction-environment**",this.__env__);if(t===null){t=this.__env__}return exec(e,t,r?t:false)};Interpreter.prototype.get=function(e){var r=this.__env__.get(e);if(is_function(r)){return r.bind(this.__env__)}return r};Interpreter.prototype.set=function(e,r){return this.__env__.set(e,r)};Interpreter.prototype.constant=function(e,r){return this.__env__.constant(e,r)};function Environment(e,r,t){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;t=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=t||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};if(_typeof_1(e)==="object"){r=e}if(!e||_typeof_1(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(r||{},this,e)};Environment.prototype.doc=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(r){if(!t){r=trim_lines(r)}this.__docs__.set(e,r);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};Environment.prototype.newFrame=function(e,r){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=n.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var t=r.get("parent.frame");return t(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;n.set("arguments",r);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var r=this;var t={};Object.keys(this.__env__).forEach(function(e){t[e]=r.__env__[e]});return new Environment(t,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(r,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var t=r.throwError,n=t===void 0?true:t;var i=e;if(i instanceof LSymbol||i instanceof LString){i=i.valueOf()}var a=this._lookup(i);if(a instanceof Value){if(Value.isUndefined(a)){return undefined$1}return patch_value(a.valueOf())}if(typeof i==="string"){var u=i.split(".").filter(Boolean);if(u.length>0){var o=toArray(u),c=o[0],s=o.slice(1);a=this._lookup(c);if(s.length){try{if(a instanceof Value){a=a.valueOf()}else{a=get(root,c);if(is_function(a)){a=unbind(a)}}return get.apply(void 0,[a].concat(toConsumableArray(s)))}catch(e){}}else if(a instanceof Value){return patch_value(a.valueOf())}}a=get(root,i)}if(typeof a!=="undefined"){return a}if(n){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(r)){r=LNumber(r)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=r;if(t){this.doc(e,t)}return this};Environment.prototype.constant=function(r,e){var t=this;if(this.__env__.hasOwnProperty(r)){throw new Error("Environment::constant: ".concat(r," already exists"))}if(arguments.length===1&&is_plain_object(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){t.constant(r,n[e])})}else{Object.defineProperty(this.__env__,r,{value:e,enumerable:true})}return this};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var r=this;while(true){if(!r){break}if(r.has(e)){return r}r=r.__parent__}};Environment.prototype.parents=function(){var e=this;var r=[];while(e){r.unshift(e);e=e.__parent__}return r};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n Function get character from string port or EOF object if no more\n data in string port."),"read-line":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-line",e,"input-port");return e.read_line()},"(read-char port)\n\n Function read next character from input port."),"read-char":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var e=asyncToGenerator(regenerator.mark(function e(){var t,n,i,a,u,o,c,s,l,f=arguments;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=f.length>0&&f[0]!==undefined$1?f[0]:null;if(!LString.isString(t)){r.next=35;break}n=true;i=false;r.prev=4;u=asyncIterator(parse(t,this));case 6:r.next=8;return u.next();case 8:o=r.sent;n=o.done;r.next=12;return o.value;case 12:c=r.sent;if(n){r.next=19;break}s=c;return r.abrupt("return",s);case 16:n=true;r.next=6;break;case 19:r.next=25;break;case 21:r.prev=21;r.t0=r["catch"](4);i=true;a=r.t0;case 25:r.prev=25;r.prev=26;if(!(!n&&u["return"]!=null)){r.next=30;break}r.next=30;return u["return"]();case 30:r.prev=30;if(!i){r.next=33;break}throw a;case 33:return r.finish(30);case 34:return r.finish(25);case 35:if(t===null){l=internal(this,"stdin")}else{l=t}typecheck_text_port("read",l,"input-port");return r.abrupt("return",l.read.call(this));case 38:case"end":return r.stop()}}},e,this,[[4,21,25,35],[26,,30,34]])}));function r(){return e.apply(this,arguments)}return r}(),"(read [string])\n\n Function if used with string will parse the string and return\n list structure of LIPS code. If called without an argument it\n will read string from standard input (using browser prompt or\n user defined way) and call itself with that string (parse is)\n function can be used together with eval to evaluate code from\n string"),pprint:doc(function e(r){if(r instanceof Pair){r=new lips.Formatter(r.toString(true))["break"]().format();global_env.get("display").call(global_env,r)}else{global_env.get("write").call(global_env,r)}global_env.get("newline").call(global_env)},"(pprint expression)\n\n Pretty print list expression, if called with non-pair it just call\n print function with passed argument."),print:doc(function e(){var r=global_env.get("display");var t=global_env.get("newline");for(var n=arguments.length,i=new Array(n),a=0;a1?t-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var c=global_env.get("repr");r=r.replace(a,function(e){var r=e[1];if(r==="~"){return"~"}else if(r==="%"){return"\n"}else{var t=n[o++];if(r==="a"){return c(t)}else{return c(t,true)}}});u=r.match(/~([\S])/);if(u){throw new Error("format: Unrecognized escape seqence ".concat(u[1]))}return r},"(format string n1 n2 ...)\n\n Function accepts string template and replacing any escape sequences\n by arguments:\n\n * ~a value as if printed with display\n * ~s value as if printed with write\n * ~% newline character\n * ~~ literal tilde '~' is inserted\n\n if there missing arguments or other escape character it throw exception."),display:doc(function e(r){var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(t===null){t=internal(this,"stdout")}else{typecheck("display",t,"output-port")}var n=global_env.get("repr")(r);t.write.call(global_env,n)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var t=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},t=r.dynamic_scope,n=r.error;if(t){t=this}var i=this;var u;var o=_evaluate(e.cdr.car,{env:this,dynamic_scope:t,error:n});o=resolve_promises(o);function c(r,t,n){if(is_promise(r)){return r.then(function(e){return c(r,e,n)})}if(is_promise(t)){return t.then(function(e){return c(r,e,n)})}if(is_promise(n)){return n.then(function(e){return c(r,t,e)})}i.get("set-obj!").call(i,r,t,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var s=e.car.cdr.car;var l=e.car.cdr.cdr.car;var f=_evaluate(s,{env:this,dynamic_scope:t,error:n});var _=_evaluate(l,{env:this,dynamic_scope:t,error:n});return c(f,_,o)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var p=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=p.split(".");if(r.length>1){var t=r.pop();var n=r.join(".");var i=a.get(n,{throwError:false});if(i){c(i,t,e);return}}throw new Error("Unbound variable `"+p+"'")}u.set(p,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable (mutate)\n it search the scope chain until it finds first non emtpy slot and set it."),"unset!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var r=e.car;var t=this.ref(r);if(t){delete t.__env__[r.__name__]}}),"(unset! name)\n\n Function delete specified name from environment."),"set-car!":doc("set-car!",function(e,r){typecheck("set-car!",e,"pair");e.car=r},"(set-car! obj value)\n\n Function that set car (head) of the list/pair to specified value.\n It can destroy the list. Old value is lost."),"set-cdr!":doc("set-cdr!",function(e,r){typecheck("set-cdr!",e,"pair");e.cdr=r},"(set-cdr! obj value)\n\n Function that set cdr (tail) of the list/pair to specified value.\n It can destroy the list. Old value is lost."),"empty?":doc("empty?",function(e){return typeof e==="undefined"||e===nil},"(empty? object)\n\n Function return true if value is undfined empty list."),gensym:doc("gensym",gensym,"(gensym)\n\n Function generate unique symbol, to use with macros as meta name."),load:doc(function e(r,t){typecheck("load",r,"string");var n=this;if(n.__name__==="__frame__"){n=n.__parent__}if(!(t instanceof Environment)){if(n===global_env){t=n}else{t=this.get("**interaction-environment**")}}var i="**module-path**";var a=global_env.get(i,{throwError:false});r=r.valueOf();if(!r.match(/.[^.]+$/)){r+=".scm"}function u(e){if(type(e)==="buffer"){e=e.toString()}return exec(e.replace(/^#!.*/,""),t)}if(is_node()){return new Promise(function(t,n){var e=nodeRequire("path");if(a){a=a.valueOf();r=e.join(a,r)}global_env.set(i,e.dirname(r));nodeRequire("fs").readFile(r,function(e,r){if(e){n(e);global_env.set(i,a)}else{try{u(r).then(function(){t();global_env.set(i,a)})["catch"](n)}catch(e){n(e)}}})})}if(a){a=a.valueOf();r=a+"/"+r.replace(/^\.?\/?/,"")}return root.fetch(r).then(function(e){return e.text()}).then(function(e){global_env.set(i,r.replace(/\/[^/]*$/,""));return u(e)}).then(function(){})["finally"](function(){global_env.set(i,a)})},"(load filename)\n (load filename environment)\n\n Function fetch the file and evaluate its content as LIPS code,\n If second argument is provided and it's environment the evaluation\n will happen in that environment."),do:doc(new Macro("do",function(){var t=asyncToGenerator(regenerator.mark(function e(t,n){var i,a,u,o,c,s,l,f,_,p,h;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=n.dynamic_scope,a=n.error;u=this;if(i){i=u}o=u.inherit("do");c=t.car;s=t.cdr.car;l=t.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};_=c;case 10:if(!(_!==nil)){r.next=21;break}p=_.car;r.t0=o;r.t1=p.car;r.next=16;return _evaluate(p.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);_=_.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var t,n,i,a,u;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(l!==nil)){r.next=3;break}r.next=3;return lips.evaluate(l,f);case 3:t=c;n={};case 5:if(!(t!==nil)){r.next=15;break}i=t.car;if(!(i.cdr.cdr!==nil)){r.next=12;break}r.next=10;return _evaluate(i.cdr.cdr.car,f);case 10:a=r.sent;n[i.car.valueOf()]=a;case 12:t=t.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(n);Object.keys(n).concat(u).forEach(function(e){o.set(e,n[e])});case 17:case"end":return r.stop()}}},e)});case 23:r.next=25;return _evaluate(s.car,f);case 25:r.t3=r.sent;if(!(r.t3===false)){r.next=30;break}return r.delegateYield(h(),"t4",28);case 28:r.next=23;break;case 30:if(!(s.cdr!==nil)){r.next=34;break}r.next=33;return _evaluate(s.cdr.car,f);case 33:return r.abrupt("return",r.sent);case 34:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()),"(do (( )) (test expression) . body)\n\n Iteration macro that evaluate the expression body in scope of the variables.\n On Eeach loop it increase the variables according to next expression and run\n test to check if the loop should continue. If test is signle call the macro\n will not return anything. If the test is pair of expression and value the\n macro will return that value after finish."),if:doc(new Macro("if",function(t,e){var n=e.dynamic_scope,i=e.error;if(n){n=this}var a=this;var r=function e(r){if(r===false){return _evaluate(t.cdr.cdr.car,{env:a,dynamic_scope:n,error:i})}else{return _evaluate(t.cdr.car,{env:a,dynamic_scope:n,error:i})}};if(t===nil){throw new Error("too few expressions for `if`")}var u=_evaluate(t.car,{env:a,dynamic_scope:n,error:i});return unpromise(u,r)}),"(if cond true-expr false-expr)\n\n Macro evaluate condition expression and if the value is true, it\n evaluate and return true expression if not it evaluate and return\n false expression"),"let-env":new Macro("let-env",function(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{};var t=e.dynamic_scope,n=e.error;typecheck("let-env",r,"pair");var i=_evaluate(r.car,{env:this,dynamic_scope:t,error:n});return unpromise(i,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:t,error:n})})},"(let-env env . body)\n\n Special macro that evaluate body in context of given environment\n object."),letrec:doc(let_macro(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b)) body)\n\n Macro that creates new environment, then evaluate and assign values to\n names and then evaluate the body in context of that environment.\n Values are evaluated sequentialy and next value can access to\n previous values/names."),"letrec*":doc(let_macro(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b)) body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so use can use recursive code as well as reference previous binding.\n In LIPS both letrec and letrec* behave the same."),"let*":doc(let_macro(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b)) body)\n\n Macro similar to `let` but next argument get environment\n from previous let variable, so they you can define one variable,\n and use in next argument."),let:doc(let_macro(Symbol["for"]("let")),"(let ((a value-a) (b value-b)) body)\n\n Macro that creates new environment, then evaluate and assign values to\n names and then evaluate the body in context of that environment.\n Values are evaluated sequentialy but you can't access\n previous values/names when next are evaluated. You can only get them\n from body of let expression."),"begin*":doc(pararel("begin*",function(e){return e.pop()}),"(begin* . expr)\n\n This macro is parallel version of begin. It evaluate each expression and\n if it's a promise it will evaluate it in parallel and return value\n of last expression."),begin:doc(new Macro("begin",function(e,r){var n=Object.assign({},r);var i=global_env.get("list->array")(e);if(n.dynamic_scope){n.dynamic_scope=this}n.env=this;var a;return function r(){if(i.length){var e=i.shift();var t=_evaluate(e,n);return unpromise(t,function(e){a=e;return r()})}else{return a}}()}),"(begin . args)\n\n Macro runs list of expression and return valuate of the list one.\n It can be used in place where you can only have single exression,\n like if expression."),ignore:new Macro("ignore",function(e,r){var t=r.dynamic_scope,n=r.error;var i={env:this,error:n};if(t){i.dynamic_scope=this}_evaluate(new Pair(new LSymbol("begin"),e),i)},"(ignore expression)\n\n Macro that will evaluate expression and swallow any promises that may\n be created. It wil run and ignore any value that may be returned by\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),define:doc(Macro.defmacro("define",function(t,e){var n=this;if(t.car instanceof Pair&&t.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(t.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(t.car.cdr,t.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=t.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",t.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=t.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(t.cdr.cdr instanceof Pair&&LString.isString(t.cdr.cdr.car)){r=t.cdr.cdr.car.valueOf()}n.set(t.car,e,r,true)})}),"(define name expression)\n (define (function-name . args) body)\n\n Macro for defining values. It can be used to define variables,\n or function. If first argument is list it will create function\n with name beeing first element of the list. The macro evalute\n code `(define function (lambda args body))`"),"set-obj!":doc("set-obj!",function(e,r,t){var n=_typeof_1(e);if(is_null(e)||n!=="object"&&n!=="function"){var i=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(i)}e=unbind(e);r=r.valueOf();if(arguments.length===2){delete e[r]}else if(is_prototype(e)&&is_function(t)){e[r]=unbind(t);e[r][__prototype__]=true}else if(is_function(t)||is_native(t)||t===nil){e[r]=t}else{e[r]=t?t.valueOf():t}},"(set-obj! obj key value)\n\n Function set property of JavaScript object"),"null-environment":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Function return new base environment with std lib."),values:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var d;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){d=f.cdr.car.valueOf()}function m(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var t=0;var n;if(typeof this!=="undefined"&&!(this instanceof Environment)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}e.set("this",this)}for(var i=arguments.length,a=new Array(i),u=0;u2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(t(n)){n=r(n)}if(t(i)){i=r(i)}if(is_promise(n)||is_promise(i)){return Promise.all([n,i]).then(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return new Pair(t,n)})}else{return new Pair(n,i)}}return e}function u(e,r){if(e instanceof Pair){if(r!==nil){e.append(r)}}else{e=new Pair(e,r)}return e}function t(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function f(e,n,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var t;if(n+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&t[0]===nil)){return t[0]}}t=t.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var n=d(i.cdr,0,1);if(n===nil&&t[0]===nil){return undefined$1}return unpromise(n,function(e){if(t[0]===nil){return e}if(t.length===1){return u(t[0],e)}var r=t.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,t){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,t)}if(LSymbol.is(e.car,"quasiquote")){var n=d(e.cdr,r,t+1);return new Pair(e.car,n)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===t&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var i=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),p(i,r+2,t)),nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==nil){if(e.car.cdr.car instanceof Pair){var a=[];return function r(t){if(t===nil){return Pair.fromArray(a)}return unpromise(_evaluate(t.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(t.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,t))}if(LSymbol.is(e.car,"unquote")){r++;if(rt){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==nil){if(e.cdr.car instanceof Pair){var u=[];return function r(t){if(t===nil){return Pair.fromArray(u)}return unpromise(_evaluate(t.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(t.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:s,dynamic_scope:o,error:c})}}else{return e.cdr}}return l(e,function(e){return d(e,r,t)})}else if(is_plain_object(e)){return _(e,r,t)}else if(e instanceof Array){return f(e,r,t)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!t(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!t(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=d(e.car,0,1);return unpromise(i,function(e){n(e);return quote(e)})},"(quasiquote list ,value ,@value)\n\n Similar macro to `quote` but inside it you can use special\n expressions unquote abbreviated to , that will evaluate expresion inside\n and return its value or unquote-splicing abbreviated to ,@ that will\n evaluate expression but return value without parenthesis (it will join)\n the list with its value. Best used with macros but it can be used outside"),clone:doc(function e(r){typecheck("clone",r,"pair");return r.clone()},"(clone list)\n\n Function return clone of the list."),append:doc(function e(){var r;for(var t=arguments.length,n=new Array(t),i=0;iarray")(r).reverse();return global_env.get("array->list")(t)}else if(!(r instanceof Array)){throw new Error(typeErrorMessage("reverse",type(r),"array or pair"))}else{return r.reverse()}},"(reverse list)\n\n Function will reverse the list or array. If value is not a list\n or array it will throw exception."),nth:doc(function e(r,t){typecheck("nth",r,"number");typecheck("nth",t,["array","pair"]);if(t instanceof Pair){var n=t;var i=0;while(iarray")(t).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,t){typecheck("split",r,["regex","string"]);typecheck("split",t,"string");return global_env.get("array->list")(t.split(r))},"(split separator string)\n\n Function create list by splitting string by separatar that can\n be a string or regular expression."),replace:doc(function e(r,t,n){typecheck("replace",r,["regex","string"]);typecheck("replace",t,["string","function"]);typecheck("replace",n,"string");return n.replace(r,t)},"(replace pattern replacement string)\n\n Function change pattern to replacement inside string. Pattern can be string\n or regex and replacement can be function or string."),match:doc(function e(r,t){typecheck("match",r,["regex","string"]);typecheck("match",t,"string");var n=t.match(r);return n?global_env.get("array->list")(n):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,t){typecheck("search",r,["regex","string"]);typecheck("search",t,"string");return t.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,t){return toString(r,t)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(e.valueOf())},"(escape-regex string)\n\n Function return new string where all special operators used in regex,\n are escaped with slash so they can be used in RegExp constructor\n to match literal string"),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__).map(LSymbol);var t;if(r.length){t=Pair.fromArray(r)}else{t=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(t)}return t},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment and it's parents."),new:doc("new",function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n2&&arguments[2]!==undefined$1?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",r,"symbol",2);specials.append(e.valueOf(),r,t)},'(set-special! symbol name [type])\n\n Add special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional and it can be constant value\n lips.specials.SPLICE if this constant is used it will transform\n `#(1 2 3)` into (x 1 2 3) that is required by # that define vectors.'),get:get,".":get,unbind:doc(unbind,"(unbind fn)\n\n Function remove bidning from function so you can get props from it."),type:doc(type,"(type object)\n\n Function return type of an object as string."),debugger:doc("debugger",function(){debugger},"(debugger)\n\n Function stop JavaScript code in debugger."),in:doc("in",function(e,r){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(r)},"(in key value)\n\n Function use is in operator to check if value is in object."),instanceof:doc("instanceof",function(e,r){return r instanceof unbind(e)},"(instanceof type obj)\n\n Function check of object is instance of object."),"prototype?":doc("prototype?",is_prototype,"(prototype? obj)\n\n Function check if value is JavaScript Object prototype."),"macro?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Function check if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Function check if value is a function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Function check if value is real number."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Function check if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Function check if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Function check if value is a pair or list structure."),"regex?":doc(function(e){return e instanceof RegExp},"(regex? expression)\n\n Function check if value is regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Function check if value is nulish."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Function check if value is boolean."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Function check if value is LIPS symbol"),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Function check if value is an arrray."),"object?":doc("object?",function(e){return e!==nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof_1(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Function check if value is an plain object."),flatten:doc(function e(r){typecheck("flatten",r,"pair");return r.flatten()},"(flatten list)\n\n Return shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function convert JavaScript array to LIPS list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,n))},"(apply fn list)\n\n Function that call function with list of arguments."),length:doc(function e(r){if(!r){return LNumber(0)}if(r instanceof Pair){return LNumber(r.length())}if("length"in r){return LNumber(r.length)}},"(length expression)\n\n Function return length of the object, the object can be list\n or any object that have length property."),"string->number":doc("string->number",function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",r,"number",2);e=e.valueOf();r=r.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,r)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,r)}else{var t=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&t||e.match(int_re)){return parse_integer(e,r)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function convert string to number."),try:doc(new Macro("try",function(r,e){var s=this;var l=e.dynamic_scope,f=e.error;return new Promise(function(i,n){var a,u;if(LSymbol.is(r.cdr.car.car,"catch")){a=r.cdr.car;if(r.cdr.cdr instanceof Pair&&LSymbol.is(r.cdr.cdr.car.car,"finally")){u=r.cdr.cdr.car}}else if(LSymbol.is(r.cdr.car.car,"finally")){u=r.cdr.car}if(!(u||a)){throw new Error("try: invalid syntax")}var o=i;if(u){o=function e(r,t){o=n;unpromise(_evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){t(r)})}}var c={env:s,error:function e(r){var t=s.inherit("try");if(a){t.set(a.cdr.car.car,r);var n={env:t,error:f};if(l){n.dynamic_scope=s}unpromise(_evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),n),function(e){o(e,i)})}else{o(r,f)}}};if(l){c.dynamic_scope=s}var e=_evaluate(r.car,c);if(is_promise(e)){e.then(function(e){o(e,i)})["catch"](c.error)}else{o(e,i)}})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro execute user code and catch exception. If catch is provided\n it's executed when expression expr throw error. If finally is provide\n it's always executed at the end."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throw new expection."),find:doc(function r(t,n){typecheck("find",t,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return nil}var e=matcher("find",t);return unpromise(e(n.car),function(e){if(e&&e!==nil){return n.car}return r(t,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher order Function find first value for which function return true.\n If called with regex it will create matcher function."),"for-each":doc("for-each",function(e){var r;typecheck("for-each",e,"function");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i1?r-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),u=3;uarray")(t);var a=[];var u=matcher("filter",r);return function r(t){function e(e){if(e&&e!==nil){a.push(n)}return r(++t)}if(t===i.length){return Pair.fromArray(a)}var n=i[t];return unpromise(u(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher order function that call `fn` for each element of the list\n and return list for only those elements for which funtion return\n true value. If called with regex it will create matcher function."),compose:doc(compose,"(compose . fns)\n\n Higher order function and create new function that apply all functions\n From right to left and return it's value. Reverse of compose.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 3)\n 11\n "),pipe:doc(pipe,"(pipe . fns)\n\n Higher order function and create new function that apply all functions\n From left to right and return it's value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 3)\n 15"),curry:doc(curry,"(curry fn . args)\n\n Higher order function that create curried version of the function.\n The result function will have parially applied arguments and it\n will keep returning functions until all arguments are added\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;no?a%=o:o%=a}a=abs(c*t[u])/(a+o)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function return the least common multiple of their arguments."),"odd?":doc("odd?",singleMathOp(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Function check if number os odd."),"even?":doc("even?",singleMathOp(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Function check if number is even."),"*":doc("*",reduceMathOp(function(e,r){return LNumber(e).mul(r)},LNumber(1)),"(* . numbers)\n\n Multiplicate all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduceMathOp(function(e,r){return LNumber(e).add(r)},LNumber(0)),"(+ . numbers)\n\n Sum all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,r=new Array(e),t=0;t":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"),"<":doc("<",function(){for(var e=arguments.length,r=new Array(e),t=0;t=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t=",r,"number");return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nondecreasing"),"eq?":doc("eq?",equal,"(eq? a b)\n\n Function compare two values if they are identical."),or:doc(new Macro("or",function(e,r){var i=r.dynamic_scope,a=r.error;var u=global_env.get("list->array")(e);var o=this;if(i){i=o}if(!u.length){return false}var c;return function r(){function e(e){c=e;if(c!==false){return c}else{return r()}}if(!u.length){if(c!==false){return c}else{return false}}else{var t=u.shift();var n=_evaluate(t,{env:o,dynamic_scope:i,error:a});return unpromise(n,e)}}()}),"(or . expressions)\n\n Macro execute the values one by one and return the one that is truthy value.\n If there are no expression that evaluate to true it return false."),and:doc(new Macro("and",function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},i=r.dynamic_scope,a=r.error;var u=global_env.get("list->array")(e);var o=this;if(i){i=o}if(!u.length){return true}var c;return function r(){function e(e){c=e;if(c===false){return false}else{return r()}}var t=u.shift();if(typeof t==="undefined"){if(c!==false){return c}else{return false}}else{var n=_evaluate(t,{env:o,dynamic_scope:i,error:a});return unpromise(n,e)}}()}),"(and . expressions)\n\n Macro evalute each expression in sequence if any value return false it will\n return false. If each value return true it will return the last value.\n If it's called without arguments it will return true."),"|":doc("|",function(e,r){return LNumber(e).or(r)},"(& a b)\n\n Function calculate or bit operation."),"&":doc("&",function(e,r){return LNumber(e).and(r)},"(& a b)\n\n Function calculate and bit operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function negate the value."),">>":doc(">>",function(e,r){return LNumber(e).shr(r)},"(>> a b)\n\n Function right shit the value a by value b."),"<<":doc(function(e,r){return LNumber(e).shl(r)},"(<< a b)\n\n Function left shit the value a by value b."),not:doc(function e(r){if(is_null(r)){return true}return!r},"(not object)\n\n Function return negation of the argument.")},undefined$1,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(e,r){e.constant("**internal-env**",r);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are internal type\n of variables that can't be redefined, defining variable with same name\n will throw an error.");global_env.set("**interaction-environment**",e)}set_interaction_env(user_env,internal_env);global_env.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contain references to stdin, stdout and stderr.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var t=e[r]?e[r]:r;global_env.set(t,doc(t,function(e){typecheck(t,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(t," number)\n\n Function calculate ").concat(t," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var t=allPossibleCases(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(t instanceof Array){if(t.length===1){t=t[0]}else{var a=t[t.length-1];t=t.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(t,", got ").concat(r).concat(i)}function typecheck_args(t,e,n){e.forEach(function(e,r){typecheck(t,e,n,r+1)})}function typecheck_text_port(e,r,t){typecheck(e,r,t);if(r.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(t instanceof Pair){t=t.to_array()}if(t instanceof Array){t=t.map(function(e){return e.valueOf()})}if(t instanceof Array){t=t.map(function(e){return e.valueOf().toLowerCase()});if(t.includes(i)){a=true}}else{t=t.valueOf().toLowerCase()}if(!a&&i!==t){throw new Error(typeErrorMessage(e,i,t,n))}}function self_evaluated(e){var r=_typeof_1(e);return["string","function"].includes(r)||_typeof_1(e)==="symbol"||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,r){if(e===null){return false}return _typeof_1(e)==="object"&&r in Object.getOwnPropertySymbols(e)}function is_iterator(e,r){if(has_own_symbol(e,r)||has_own_symbol(e.__proto__,r)){return is_function(e[r])}}function type(e){var r={pair:Pair,symbol:LSymbol,character:LCharacter,values:Values,"input-port":InputPort,"output-port":OutputPort,number:LNumber,regex:RegExp,syntax:Syntax,macro:Macro,string:LString,array:Array,"native-symbol":Symbol};if(Number.isNaN(e)){return"NaN"}if(e===nil){return"nil"}if(e===null){return"null"}for(var t=0,n=Object.entries(r);t2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,t=r.error,o=t===void 0?function(){}:t;e=evaluate_args(e,{env:a,dynamic_scope:u,error:o});return unpromise(e,function(e){if(is_raw_lambda(i)){i=unbind(i)}e=prepare_fn_args(i,e);var r=e.slice();var t=(u||a).newFrame(i,r);var n=resolve_promises(i.apply(t,e));return unpromise(n,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}if(Number.isNaN(e)){return e}if(typeof e==="number"){return LNumber(e)}if(typeof e==="string"){return LString(e)}return e},o)})}function _evaluate(r){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=e.env,n=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(n===true){t=n=t||global_env}else if(t===true){t=n=global_env}else{t=t||global_env}var u={env:t,dynamic_scope:n,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return t.get(r)}if(!(r instanceof Pair)){return r}var c=r.car;var s=r.cdr;if(c instanceof Pair){o=resolve_promises(_evaluate(c,u));if(is_promise(o)){return o.then(function(e){return _evaluate(new Pair(e,r.cdr),u)})}else if(!is_function(o)){throw new Error(type(o)+" "+t.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=t.get(c)}else if(is_function(c)){o=c}var l;if(o instanceof Syntax){l=evaluate_syntax(o,r,u)}else if(o instanceof Macro){l=evaluate_macro(o,s,u)}else if(is_function(o)){l=apply(o,s,u)}else if(r instanceof Pair){o=c&&c.toString();throw new Error("".concat(type(c)," ").concat(o," is not a function"))}else if(!is_function(o)){if(o){var f="".concat(type(o)," `").concat(o,"' is not a function");throw new Error(f)}throw new Error("Unknown function `".concat(c.toString(),"'"))}else{return r}var _=t.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){l=l.then(function(e){if(e instanceof Pair&&!o[__data__]){return _evaluate(e,u)}return e});return new QuotedPromise(l)}return l}catch(e){a&&a.call(t,e,r)}}function exec(e,r,t){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(t,n,i){var a,u,o,c,s,l,f,_,p;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(i===true){n=i=n||user_env}else if(n===true){n=i=user_env}else{n=n||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(t));case 6:r.next=8;return s.next();case 8:l=r.sent;u=l.done;r.next=12;return l.value;case 12:f=r.sent;if(u){r.next=28;break}_=f;p=_evaluate(_,{env:n,dynamic_scope:i,error:function e(r,t){if(r&&r.message){if(r.message.match(/^Error:/)){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1")}else{r.message="Error: ".concat(r.message)}if(t){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(t.toString(true))}}throw r}});if(is_promise(p)){r.next=20;break}a.push(p);r.next=25;break;case 20:r.t0=a;r.next=23;return p;case 23:r.t1=r.sent;r.t0.push.call(r.t0,r.t1);case 25:u=true;r.next=6;break;case 28:r.next=34;break;case 30:r.prev=30;r.t2=r["catch"](4);o=true;c=r.t2;case 34:r.prev=34;r.prev=35;if(!(!u&&s["return"]!=null)){r.next=39;break}r.next=39;return s["return"]();case 39:r.prev=39;if(!o){r.next=42;break}throw c;case 42:return r.finish(39);case 43:return r.finish(34);case 44:return r.abrupt("return",a);case 45:case"end":return r.stop()}}},e,null,[[4,30,34,44],[35,,39,43]])}));return _exec.apply(this,arguments)}function balanced(e){var r={"[":"]","(":")"};var t;if(typeof e==="string"){t=tokenize(e)}else{t=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(r);var i=Object.values(r).concat(n);t=t.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(t),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(n.includes(c)){a.push(c)}else if(!a.is_empty()){var s=a.top();var l=r[s];if(c===l){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(l))}}else{throw new Error("Syntax error: not matched closing ".concat(c))}}}catch(e){u.e(e)}finally{u.f()}return a.is_empty()}function fworker(e){var r="("+e.toString()+")()";var t=window.URL||window.webkitURL;var n;try{n=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(r);n=n.getBlob()}return new root.Worker(t.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:"";if(e===""){if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/"}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/")}}else if(!e.match(/\/$/)){e+="/"}var r=global_env.get("load");return r.call(lips.env,"".concat(e,"dist/std.scm"),global_env)}function Worker(e){this.url=e;var u=this.worker=fworker(function(){var u;var o;self.addEventListener("message",function(e){var t=e.data;var r=t.id;if(t.type!=="RPC"||r===null){return}function n(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(t.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=t.params[0];var r=t.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(t.method==="init"){var a=t.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));u=new lips.Interpreter("worker");o=bootstrap(a);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(r,t){var a=++n;return new Promise(function(n,i){u.addEventListener("message",function e(r){var t=r.data;if(t&&t.type==="RPC"&&t.id===a){if(t.error){i(t.error)}else{n(t.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:t})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return this.rpc("eval",[e,r])}}Pair.unDry=function(e){return new Pair(e.car,e.cdr)};Pair.prototype.toDry=function(){return{value:{car:this.car,cdr:this.cdr}}};Nil.prototype.toDry=function(){return{value:null}};Nil.unDry=function(){return nil};LSymbol.prototype.toDry=function(){return{value:{name:this.__name__}}};LSymbol.unDry=function(e){return new LSymbol(e.__name__)};function execError(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}))}}function init(){var u=["text/x-lips","text/x-scheme"];var o;function c(t){return new Promise(function(r){var e=t.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(exec).then(r)["catch"](function(e){execError(e);r()})}else{return exec(t.innerHTML).then(r)["catch"](function(e){execError(e);r()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var r=a.shift();if(!r){i()}else{var t=r.getAttribute("type");if(u.includes(t)){var n=r.getAttribute("bootstrap");if(!o&&typeof n==="string"){bootstrap(n).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(t&&t.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+t)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var t=r.getAttribute("bootstrap");if(typeof t==="string"){return bootstrap(t).then(function(){o=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Tue, 16 Mar 2021 12:53:59 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var t=function e(r){return r.toString().padStart(2,"0")};var n=r.getFullYear();var i=[n,t(r.getMonth()+1),t(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.12 (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables.\nYou can also use (help name) to display help for specic function or macro and\n(apropos name) to display list of matched names in environment.\n").replace(/^.*\n/,"");return a}();Ahead.__class__="ahead";Pattern.__class__="pattern";Formatter.__class__="formatter";Macro.__class__="macro";Syntax.__class__="syntax";Environment.__class__="environment";InputPort.__class__="input-port";OutputPort.__class__="output-port";OutputStringPort.__class__="output-string-port";InputStringPort.__class__="input-string-port";InputFilePort.__class__="input-file-port";OutputFilePort.__class__="output-file-port";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";QuotedPromise.__class__="promise";var lips={version:"1.0.0-beta.12",banner:banner,date:"Tue, 16 Mar 2021 12:53:59 +0000",exec:exec,parse:compose(uniterate_async,parse),tokenize:tokenize,evaluate:_evaluate,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,quote:quote,InputPort:InputPort,OutputPort:OutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,rationalize:rationalize};global_env.set("lips",lips);return lips})})(); \ No newline at end of file diff --git a/package.json b/package.json index 556d0df11..cf4c7272a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jcubic/lips", - "version": "1.0.0-beta.11", + "version": "1.0.0-beta.12", "description": "Simple Scheme Like Lisp in JavaScript", "main": "src/lips.js", "unpkg": "dist/lips.min.js",