From d542aace2ba04f51fcf64595bac7f8e9661a9078 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Apr 2019 12:22:58 +0200 Subject: [PATCH] version 0.9.1 --- Makefile | 2 +- README.md | 6 +++--- dist/lips.js | 6 +++--- dist/lips.min.js | 6 +++--- package.json | 2 +- src/lips.js | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 55adf532..6f834035 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: publish test coveralls lint -VERSION=0.9.0 +VERSION=0.9.1 BRANCH=`git branch | grep '^*' | sed 's/* //'` DATE=`date -uR` SPEC_CHECKSUM=`md5sum spec/lips.spec.js | cut -d' ' -f 1` diff --git a/README.md b/README.md index 02fb395d..a25366bb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ ## LIPS is Pretty Simple -[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) -[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=devel&40c49f76782cb75bb5bc79230bdb951585ecf92a)](https://travis-ci.org/jcubic/jquery.terminal) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&4605127ab4ae61bb9393947f167c7edb)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![npm](https://img.shields.io/badge/npm-0.9.1-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) +[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=master&2be4561b06b6bc701c3d2ca69d1d334e9836cb14)](https://travis-ci.org/jcubic/jquery.terminal) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&4605127ab4ae61bb9393947f167c7edb)](https://coveralls.io/github/jcubic/lips?branch=master) LIPS is very simple Lisp, similar to Scheme written in JavaScript. diff --git a/dist/lips.js b/dist/lips.js index 2c4e2d60..8b24ea54 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -1,12 +1,12 @@ /**@license - * LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. DEV + * LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. 0.9.1 * * Copyright (c) 2018-2019 Jakub T. Jankiewicz * Released under the MIT license * * includes unfetch by Jason Miller (@developit) MIT License * - * build: Mon, 15 Apr 2019 10:19:18 +0000 + * build: Mon, 15 Apr 2019 10:27:16 +0000 */ (function () { 'use strict'; @@ -4973,7 +4973,7 @@ function _typeof(obj) { }); // -------------------------------------- return { - version: 'DEV', + version: '0.9.1', exec: exec, parse: parse, tokenize: tokenize, diff --git a/dist/lips.min.js b/dist/lips.min.js index 0bb86181..3c3becf5 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -1,12 +1,12 @@ /**@license - * LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. DEV + * LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. 0.9.1 * * Copyright (c) 2018-2019 Jakub T. Jankiewicz * Released under the MIT license * * includes unfetch by Jason Miller (@developit) MIT License * - * build: Mon, 15 Apr 2019 10:19:18 +0000 + * build: Mon, 15 Apr 2019 10:27:16 +0000 */ (function(){"use strict";function n(e){if(Array.isArray(e))return e}function t(e,r){var n=[];var t=true;var i=false;var a=undefined;try{for(var o=e[Symbol.iterator](),u;!(t=(u=o.next()).done);t=true){n.push(u.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&o["return"]!=null)o["return"]()}finally{if(i)throw a}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function re(e,r){return n(e)||t(e,r)||i()}function a(e,r){a=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return a(e,r)}function o(){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}}function ne(e,r,n){if(o()){ne=Reflect.construct}else{ne=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var o=new a;if(t)setPrototypeOf(o,t.prototype);return o}}return ne.apply(null,arguments)}function e(e,r){return r={exports:{}},e(r,r.exports),r.exports}var r=e(function(e){var r=function(a){var e=Object.prototype;var f=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var n=r.asyncIterator||"@@asyncIterator";var t=r.toStringTag||"@@toStringTag";function o(e,r,n,t){var i=r&&r.prototype instanceof u?r:u;var a=Object.create(i.prototype);var o=new j(t||[]);a._invoke=E(e,n,o);return a}a.wrap=o;function s(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var l="suspendedStart";var h="suspendedYield";var p="executing";var v="completed";var d={};function u(){}function y(){}function m(){}var g={};g[i]=function(){return this};var w=Object.getPrototypeOf;var b=w&&w(w(O([])));if(b&&b!==e&&f.call(b,i)){g=b}var x=m.prototype=u.prototype=Object.create(g);y.prototype=x.constructor=m;m.constructor=y;m[t]=y.displayName="GeneratorFunction";function k(e){["next","throw","return"].forEach(function(r){e[r]=function(e){return this._invoke(r,e)}})}a.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===y||(r.displayName||r.name)==="GeneratorFunction":false};a.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,m)}else{e.__proto__=m;if(!(t in e)){e[t]="GeneratorFunction"}}e.prototype=Object.create(x);return e};a.awrap=function(e){return{__await:e}};function _(u){function c(e,r,n,t){var i=s(u[e],u,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var o=a.value;if(o&&typeof o==="object"&&f.call(o,"__await")){return Promise.resolve(o.__await).then(function(e){c("next",e,n,t)},function(e){c("throw",e,n,t)})}return Promise.resolve(o).then(function(e){a.value=e;n(a)},function(e){return c("throw",e,n,t)})}}var r;function e(n,t){function e(){return new Promise(function(e,r){c(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}k(_.prototype);_.prototype[n]=function(){return this};a.AsyncIterator=_;a.async=function(e,r,n,t){var i=new _(o(e,r,n,t));return a.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})};function E(o,u,c){var f=l;return function e(r,n){if(f===p){throw new Error("Generator is already running")}if(f===v){if(r==="throw"){throw n}return L()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===d)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(f===l){f=v;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}f=p;var a=s(o,u,c);if(a.type==="normal"){f=c.done?v:h;if(a.arg===d){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){f=v;c.method="throw";c.arg=a.arg}}}}function A(e,r){var n=e.iterator[r.method];if(n===c){r.delegate=null;if(r.method==="throw"){if(e.iterator["return"]){r.method="return";r.arg=c;A(e,r);if(r.method==="throw"){return d}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var t=s(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return d}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return d}if(i.done){r[e.resultName]=i.value;r.next=e.nextLoc;if(r.method!=="return"){r.method="next";r.arg=c}}else{return i}r.delegate=null;return d}k(x);x[t]="Generator";x[i]=function(){return this};x.toString=function(){return"[object Generator]"};function S(e){var r={tryLoc:e[0]};if(1 in e){r.catchLoc=e[1]}if(2 in e){r.finallyLoc=e[2];r.afterLoc=e[3]}this.tryEntries.push(r)}function N(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function j(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(S,this);this.reset(true)}a.keys=function(n){var t=[];for(var e in n){t.push(e)}t.reverse();return function e(){while(t.length){var r=t.pop();if(r in n){e.value=r;e.done=false;return e}}e.done=true;return e}};function O(r){if(r){var e=r[i];if(e){return e.call(r)}if(typeof r.next==="function"){return r}if(!isNaN(r.length)){var n=-1,t=function e(){while(++n=0;--r){var i=this.tryEntries[r];var a=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var o=f.call(i,"catchLoc");var u=f.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&f.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);N(n);return d}}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===e){var t=n.completion;if(t.type==="throw"){var i=t.arg;N(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:O(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return a}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var te=r;function c(e,r,n,t,i,a,o){try{var u=e[a](o);var c=u.value}catch(e){n(e);return}if(u.done){r(c)}else{Promise.resolve(c).then(t,i)}}function ie(u){return function(){var e=this,o=arguments;return new Promise(function(r,n){var t=u.apply(e,o);function i(e){c(t,r,n,i,a,"next",e)}function a(e){c(t,r,n,i,a,"throw",e)}i(undefined)})}}function u(e){if(Array.isArray(e)){for(var r=0,n=new Array(e.length);r1){a.pop();if(a[a.length-1].length===1&&a[a.length-1][0]instanceof w){a[a.length-1].push(e)}else if(a[a.length-1].length===0){a[a.length-1]=e}else if(a[a.length-1]instanceof k){if(a[a.length-1].cdr instanceof k){a[a.length-1]=new k(a[a.length-1],k.fromArray(e))}else{a[a.length-1].cdr=k.fromArray(e)}}else{a[a.length-1].push(e)}}}e.forEach(function(e){var r=a[a.length-1];if(c.indexOf(e)!==-1){p++;u=e;a.push([y[u]]);if(!u){h=[]}h.push(u)}else{if(u){l.push(h);h=[]}if(e==="("){s=true;f++;a.push([]);u=null;p=0}else if(e==="."&&!s){a[a.length-1]=k.fromArray(r)}else if(e===")"){f--;if(!a.length){throw new Error("Unbalanced parenthesis")}if(a.length===1){o.push(a.pop())}else if(a.length>1){var n=a.pop();r=a[a.length-1];if(r instanceof Array){r.push(n)}else if(r instanceof k){r.append(k.fromArray(n))}if(l.length){h=l.pop();while(h.length){v();h.pop()}}else{v()}}if(f===0&&a.length){o.push(a.pop())}}else{s=false;var t=d(e);if(u){while(p--){a[a.length-1][1]=t;t=a.pop()}p=0;u=false}r=a[a.length-1];if(r instanceof k){var i=r;while(true){if(i.cdr===x){if(t instanceof Array){i.cdr=k.fromArray(t)}else{i.cdr=t}break}else{i=i.cdr}}}else if(!a.length){o.push(t)}else{r.push(t)}}}});if(a.length){throw new Error("Unbalanced parenthesis 2")}return o.map(function(e){if(e instanceof Array){return k.fromArray(e)}return e})}function m(e){var r=1;var n=e.length;while(r>0){var t=e[--n];if(!t){return}if(t.token==="("){r--}else if(t.token===")"){r++}}return e.slice(n)}function g(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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function c(e){this._code=e.replace(/\r/g,"")}c.defaults={offset:0,indent:2,specials:["define","lambda","let","let*","define-macro"]};c.prototype._options=function e(r){var n=c.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.specials||[];return Object.assign({},n,r,{specials:n.specials.concat(t)})};c.prototype.indent=function e(r){var n=p(this._code,true);return this._indent(n,r)};c.prototype._indent=function e(r,n){var t=this._options(n);var i=g(r);var a=t.specials;var o=m(r);if(o){if(o[0].line>0){t.offset=0}if(o.length===1){return t.offset+o[0].col+1}else if(a.indexOf(o[1].token)!==-1){return t.offset+o[0].col+t.indent}else if(o[0].line3&&o[1].line===o[3].line){if(o[1].token==="("){return t.offset+o[1].col}return t.offset+o[3].col}else if(o[0].line===o[1].line){return t.offset+t.indent+o[0].col}else{var u=o.slice(2);for(var c=0;c")}else if(typeof this.car==="string"){e.push(JSON.stringify(this.car))}else if(this.car instanceof w){e.push(this.car.toString())}else if(typeof this.car!=="undefined"){e.push(this.car)}if(this.cdr instanceof k){e.push(" ");e.push(this.cdr.toString().replace(/^\(|\)$/g,""))}else if(typeof this.cdr!=="undefined"&&this.cdr!==x){if(typeof this.cdr==="string"){e=e.concat([" . ",JSON.stringify(this.cdr)])}else{e=e.concat([" . ",this.cdr])}}}e.push(")");return e.join("")};k.prototype.append=function(e){if(e instanceof Array){return this.append(k.fromArray(e))}var r=this;if(r.car===h){if(e instanceof k){this.car=e.car;this.cdr=e.cdr}else{return e}}else{while(true){if(r instanceof k&&r.cdr!==x){r=r.cdr}else{break}}r.cdr=e}return this};function E(e,r){if(e instanceof F&&r instanceof F){return e.cmp(r)===0}else if(typeof e==="number"||typeof r==="number"){return F(e).cmp(F(r))}else if(e instanceof w&&r instanceof w){return e.name===r.name}else{return e===r}}function A(e){return e instanceof k&&e.isEmptyList()||e===x}function S(e,r){if(typeof this!=="undefined"&&this.constructor!==S||typeof this==="undefined"){return new S(e,r)}this.name=e;this.fn=r}S.defmacro=function(e,r){var n=new S(e,r);n.defmacro=true;return n};S.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var o={dynamic_scope:i,error:a,macro_expand:n};var u=this.fn.call(t,e,o,this.name);return n?I(u):u};S.prototype.toString=function(){return"#"};var N="define-macro";function j(a){return function(){var n=ie(te.mark(function e(n,c){var f,s,t,i;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=function e(){t=ie(te.mark(function e(n){var t,i,a,o,u;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(n instanceof k&&n.car instanceof w)){r.next=13;break}r.prev=1;t=f.get(n.car);if(!(t instanceof S&&t.defmacro)){r.next=9;break}r.next=6;return t.invoke(n.cdr,c,true);case 6:i=r.sent;if(!(i instanceof k)){r.next=9;break}return r.abrupt("return",i);case 9:r.next=13;break;case 11:r.prev=11;r.t0=r["catch"](1);case 13:a=n.car;if(!(a instanceof k)){r.next=18;break}r.next=17;return s(a);case 17:a=r.sent;case 18:o=n.cdr;if(!(o instanceof k)){r.next=23;break}r.next=22;return s(o);case 22:o=r.sent;case 23:u=new k(a,o);return r.abrupt("return",u);case 25:case"end":return r.stop()}}},e,null,[[1,11]])}));return t.apply(this,arguments)};s=function e(r){return t.apply(this,arguments)};f=c["env"]=this;i=n;if(!a){r.next=12;break}r.t0=I;r.next=8;return s(n);case 8:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 12:r.next=15;return s(n);case 15:i=r.sent;if(!(n.toString()===i.toString())){r.next=18;break}return r.abrupt("break",21);case 18:n=i;r.next=12;break;case 21:return r.abrupt("return",I(i.car));case 22:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function O(e){return typeof e==="undefined"||e===x||e===null}function L(e){return typeof e==="function"&&e.toString().match(/\{\s*\[native code\]\s*\}/)}function q(e){return e instanceof Promise||typeof e!=="undefined"&&typeof e.then==="function"}function P(e,a){var o=function e(){for(var r=arguments.length,n=new Array(r),t=0;t2?r-2:0),t=2;t1?n-1:0),i=1;i1?r-1:0),t=1;tarray")(o.car);var l=s.inherit("let");var h=0;return function e(){var r=f[h++];function n(e){if(q(e)){return e.then(n)}else if(typeof e==="undefined"){l.set(r.car,x)}else{l.set(r.car,e)}}if(u){u=p?l:s}if(!r){var t=new k(new w("begin"),o.cdr);return V(t,{env:l,dynamic_scope:u,error:c})}else{var i=V(r.cdr.car,{env:p?l:s,dynamic_scope:u,error:c});var a=n(i);if(q(a)){return a.then(e)}else{return e()}}}()})}function F(e,r){if(typeof this!=="undefined"&&this.constructor!==F||typeof this==="undefined"){return new F(e,r===true?true:h)}if(e instanceof F){return F(e.value,e.float)}if(!F.isNumber(e)){throw new Error("You can't create LNumber from "+oe(e))}if(e===null){e=0}if(F.isFloat(e)){this.value=e}else if(r){this.value=e;this.float=true}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){this.value=BigInt(e)}else{this.value=e}}else if(typeof n!=="undefined"&&!(e instanceof n)){this.value=new n(e)}else{this.value=e}}F.isFloat=function e(r){return Number(r)===r&&r%1!==0};F.isNumber=function(e){return e instanceof F||!Number.isNaN(e)&&F.isNative(e)||F.isBN(e)};F.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};F.isBN=function(e){return typeof n!=="undefined"&&e instanceof n};F.prototype.toString=F.prototype.toJSON=function(){return this.value.toString()};F.prototype.isBigNumber=function(){return typeof this.value==="bigint"||typeof n!=="undefined"&&!(this.value instanceof n)};["floor","ceil","round"].forEach(function(e){F.prototype[e]=function(){if(this.float||F.isFloat(this.value)){return F(Math[e](this.value))}else{return F(this.value)}}});F.prototype.valueOf=function(){if(F.isNative(this.value)){return Number(this.value)}else if(F.isBN(this.value)){return this.value.toNumber()}};F.prototype.coerce=function(e){if(e===null){e=0}var r;if(e instanceof F){r=e.value}else{r=e}if(F.isFloat(r)){}else if(typeof this.value==="bigint"&&typeof r!=="bigint"){r=BigInt(r)}else if(typeof n!=="undefined"&&this.value instanceof n&&!r instanceof n){r=new n(r)}return F(r)};F.prototype.op=function(e,r){var n={"*":function e(r,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){return r-n},"/":function e(r,n){return r/n},"%":function e(r,n){return r%n},"|":function e(r,n){return r|n},"&":function e(r,n){return r&n},"~":function e(r){return~r},">>":function e(r,n){return r>>n},"<<":function e(r,n){return r<>":"ishln"};e=i[e];return F(this.value.clone()[e](r,t))}};var R={"+":"add","-":"sub","*":"mul","/":"div","%":"mod","|":"or","&":"and","~":"neg","<<":"shl",">>":"shr"};Object.keys(R).forEach(function(r){F.prototype[R[r]]=function(e){return this.op(r,e)}});F.prototype.sqrt=function(){var e;if(F.isNative(this.value)){e=Math.sqrt(this.value)}else if(F.isBN(this.value)){e=this.value.sqrt()}return new F(e)};F.prototype.pow=function(e){e=this.coerce(e);if(F.isNative(this.value)){try{var r=new Function("a,b","return a**b;");e.value=r(this.value,e.value)}catch(e){throw new Error("Power operator not supported")}}else if(F.isBN(this.value)){e.value=this.value.pow(e.value)}else{e.value=Math.pow(this.value,e.value)}return e};F.prototype.neg=function(){var e=this.value;if(F.isNative(e)){e=-e}else if(F.isBN(e)){e=e.neg()}return new F(e)};F.prototype.abs=function(){var e=this.value;if(F.isNative(this.value)){if(e<0){e=-e}}else if(F.isBN(e)){e.iabs()}return new F(e)};F.prototype.isOdd=function(){if(F.isNative(this.value)){return this.value%2===1}else if(F.isBN(this.value)){return this.value.isOdd()}};F.prototype.isEven=function(){return!this.isOdd()};F.prototype.cmp=function(e){e=this.coerce(e);if(F.isNative(this.value)){if(this.value1&&arguments[1]!==h?arguments[1]:{};if(oe(e)==="object"){r=e}if(!e||oe(e)==="object"){e="child of "+(this.name||"unknown")}return new T(r||{},this,e)};T.prototype.get=function(e){var r;var n=false;if(e instanceof w){if(e.name in this.env){r=this.env[e.name];n=true}}else if(typeof e==="string"){if(typeof this.env[e]!=="undefined"){r=this.env[e];n=true}}if(n){if(F.isNumber(r)){return F(r)}if(typeof r==="function"){return P(r,this)}return r}if(this.parent instanceof T){return this.parent.get(e)}else{var t;if(e instanceof w){t=e.name}else if(typeof e==="string"){t=e}if(t){var i=oe(a[t]);if(i==="function"){if(L(a[t])){return a[t].bind(a)}else{return a[t]}}else if(i!=="undefined"){return a[t]}}}t=(t.name||t).toString();throw new Error("Unbound variable `"+t+"'")};T.prototype.set=function(e,r){if(F.isNumber(r)){r=F(r)}if(e instanceof w){e=e.name}this.env[e]=r};T.prototype.has=function(e){return typeof this.env[e]!=="undefined"};T.prototype.ref=function(e){var r=this;while(true){if(!r){break}if(r.has(e)){return r}r=r.parent}};function I(e){if(q(e)){return e.then(I)}if(e instanceof k||e instanceof w){e.data=true}return e}function D(e,r){this.value=e;this.count=r}D.prototype.toString=function(){return"<#unquote["+this.count+"] "+this.value+">"};var M=function(){var r=0;return function(){var e=arguments.length>0&&arguments[0]!==h?arguments[0]:null;if(e!==null){return new w(a.Symbol("#"+e))}r++;return new w(a.Symbol("#gensym_"+r))}}();var G=new T({nil:x,undefined:h,true:true,NaN:NaN,false:false,stdout:{write:function e(){var r;(r=console).log.apply(r,arguments)}},stdin:{read:function e(){return new Promise(function(e){e(prompt(""))})}},this:function e(){return this},cons:function e(r,n){if(A(n)){n=x}return new k(r,n)},car:function e(r){if(r instanceof k){return r.car}else{throw new Error("argument to car need to be a list")}},cdr:function e(r){if(r instanceof k){return r.cdr}else{throw new Error("argument to cdr need to be a list")}},"set!":new S("set!",function(r){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},n=e.dynamic_scope,t=e.error;if(n){n=this}var i=V(r.cdr.car,{env:this,dynamic_scope:n,error:t});i=C(i);var a;if(r.car instanceof k&&w.is(r.car.car,".")){var o=r.car.cdr.car;var u=r.car.cdr.cdr.car;var c=V(o,{env:this,dynamic_scope:n,error:t});var f=V(u,{env:this,dynamic_scope:n,error:t});if(q(i)){return i.then(function(e){c[f]=e})}else{c[f]=i;return i}}if(!(r.car instanceof w)){throw new Error("set! first argument need to be a symbol")}a=this.ref(r.car.name);if(!a){a=this}if(q(i)){return i.then(function(e){return a.set(r.car,e)})}else{a.set(r.car,i)}}),"set-car!":function e(r,n){r.car=n},"set-cdr!":function e(r,n){r.cdr=n},"empty?":function e(r){return typeof r==="undefined"||A(r)},assoc:function e(r,n){if(r instanceof k&&!(n instanceof k)){throw new Error("First argument to assoc new to a key")}var t=n;while(true){if(!(t instanceof k)||this.get("empty?")(t)){break}var i=t.car.car;if(E(i,r)){return t.car}else{t=t.cdr}}return x},gensym:M,load:function e(r){var n=this;a.fetch(r).then(function(e){return e.text()}).then(function(e){n.get("eval")(n.get("read")(e))})},while:new S("while",function(){var n=ie(te.mark(function e(n,t){var i,a,o,u,c,f;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=t.dynamic_scope,a=t.error;o=this;u=new k(new w("begin"),n.cdr);if(i){i=o}case 4:r.next=7;return V(n.car,{env:o,dynamic_scope:i,error:a});case 7:f=r.sent;if(!(f&&!A(f))){r.next=14;break}r.next=11;return V(u,{env:o,dynamic_scope:i,error:a});case 11:c=r.sent;r.next=15;break;case 14:return r.abrupt("return",c);case 15:r.next=4;break;case 17:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()),if:new S("if",function(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(typeof r!=="boolean"){throw new Error("if: value need to be boolean")}if(r){return V(n.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return V(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}};var o=V(n.car,{env:a,dynamic_scope:t,error:i});if(q(o)){return o.then(r)}else{return r(o)}}),"let*":B(true),let:B(false),begin:new S("begin",function(e,r){var n=r.dynamic_scope,t=r.error;var i=this.get("list->array")(e);if(n){n=this}var a=this;var o;return function r(){if(i.length){var e=i.shift();o=V(e,{env:a,dynamic_scope:n,error:t});if(q(o)){return o.then(function(e){o=e;return r()})}else{return r()}}else{return o}}()}),nop:function e(){},timer:new S("timer",function(r){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},n=e.dynamic_scope,t=e.error;var i=this;if(n){n=this}return new Promise(function(e){setTimeout(function(){e(V(r.cdr,{env:i,dynamic_scope:n,error:t}))},r.car)})}),define:S.defmacro("define",function(r,e){var n=this;if(r.car instanceof k&&r.car.car instanceof w){var t=new k(new w("define"),new k(r.car.car,new k(new k(new w("lambda"),new k(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=r.cdr.car;if(i instanceof k){i=V(i,e)}else if(i instanceof w){i=n.get(i)}if(r.car instanceof w){if(q(i)){return i.then(function(e){n.set(r.car,e)})}else{n.set(r.car,i)}}}),"set-obj":function e(r,n,t){r[n]=t},eval:function e(r){var n=this;if(r instanceof k){return V(r,{env:this,dynamic_scope:this,error:function e(r){return n.get("print")(r.message)}})}if(r instanceof Array){var t;r.forEach(function(e){t=V(e,{env:n,dynamic_scope:n,error:function e(r){return n.get("print")(r.message)}})});return t}},lambda:new S("lambda",function(c){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},f=e.dynamic_scope,s=e.error;var l=this;function r(){var e=(f?this:l).inherit("lambda");var r=c.car;var n=0;var t;if(r instanceof w||!A(r)){for(var i=arguments.length,a=new Array(i),o=0;op){p=u}if(!(o===a)){r.next=43;break}if(!(n.cdr.cdr!==x)){r.next=40;break}r.t5=k;r.t6=new D(n.cdr.car,u);r.next=36;return v(n.cdr.cdr);case 36:r.t7=r.sent;return r.abrupt("return",new r.t5(r.t6,r.t7));case 40:return r.abrupt("return",new D(n.cdr.car,u));case 41:r.next=58;break;case 43:if(!(o.cdr.cdr!==x)){r.next=57;break}r.t8=k;r.t9=new D(a,u);if(!(o.cdr===x)){r.next=50;break}r.t10=x;r.next=53;break;case 50:r.next=52;return v(o.cdr.cdr);case 52:r.t10=r.sent;case 53:r.t11=r.t10;o.car.cdr=new r.t8(r.t9,r.t11);r.next=58;break;case 57:o.car.cdr=new D(a,u);case 58:return r.abrupt("return",i.car);case 59:c=n.car;f=n.cdr;if(!(c instanceof k)){r.next=65;break}r.next=64;return v(c);case 64:c=r.sent;case 65:if(!(f instanceof k)){r.next=69;break}r.next=68;return v(f);case 68:f=r.sent;case 69:return r.abrupt("return",new k(c,f));case 70:return r.abrupt("return",n);case 71:case"end":return r.stop()}}},e)}));return n.apply(this,arguments)}function a(e){return t.apply(this,arguments)}function t(){t=ie(te.mark(function e(n){var t,i;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(n instanceof D)){r.next=14;break}if(!(p===n.count)){r.next=5;break}return r.abrupt("return",V(n.value,{env:h,dynamic_scope:s,error:l}));case 5:r.t0=k;r.t1=new w("unquote");r.t2=k;r.next=10;return a(n.value);case 10:r.t3=r.sent;r.t4=x;r.t5=new r.t2(r.t3,r.t4);return r.abrupt("return",new r.t0(r.t1,r.t5));case 14:if(!(n instanceof k)){r.next=26;break}t=n.car;if(!(t instanceof k||t instanceof D)){r.next=20;break}r.next=19;return a(t);case 19:t=r.sent;case 20:i=n.cdr;if(!(i instanceof k||i instanceof D)){r.next=25;break}r.next=24;return a(i);case 24:i=r.sent;case 25:return r.abrupt("return",new k(t,i));case 26:return r.abrupt("return",n);case 27:case"end":return r.stop()}}},e)}));return t.apply(this,arguments)}return v(e.car).then(a).then(I)}),clone:function e(r){return r.clone()},append:function e(r,n){return r.clone().append([n])},reverse:function e(r){if(r instanceof k){var n=this.get("list->array")(r).reverse();return this.get("array->list")(n)}else if(!(r instanceof Array)){throw new Error("Invlid value for reverse")}else{return r.reverse()}},nth:function e(r,n){if(n instanceof k){var t=n;var i=0;while(iarray")(n).join(r)},split:function e(r,n){return this.get("array->list")(r.split(n))},replace:function e(r,n,t){return r.replace(n,t)},match:function e(r,n){return this.get("array->list")(r.match(n))},search:function e(r,n){return r.search(n)},string:function r(e,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"<#jQuery("+e.length+")>"}if(e instanceof F){return e.value.toString()}if(typeof e==="undefined"){return"<#undefined>"}if(typeof e==="function"){if(L(e)){return"<#function(native)>"}return"<#function>"}if(e===x){return"nil"}if(e instanceof Array){return"["+e.map(function(e){return r(e,true)}).join(", ")+"]"}if(e===null||typeof e==="string"&&n){return JSON.stringify(e)}if(e instanceof k||e instanceof w){return e.toString()}if(oe(e)==="object"){var t=e.constructor.name;if(t!==""){return"<#"+t+">"}return"<#Object>"}if(typeof e!=="string"){return e.toString()}return e},env:function e(r){r=r||this;var n=Object.keys(r.env);var t;if(n.length){t=k.fromArray(n)}else{t=x}if(r.parent!==h){return this.get("env").call(this,r.parent).append(t)}return t},new:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;ilist":function e(r){return k.fromArray(r)},"list->array":function e(r){if(r instanceof k&&r.isEmptyList()){return[]}var n=[];var t=r;while(true){if(t instanceof k){n.push(t.car);t=t.cdr}else{break}}return n},apply:new S("apply",function(t){var i=this;var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},a=e.dynamic_scope,o=e.error;if(a){a=this}function u(e){if(typeof e!=="function"){var r;if(t.car instanceof w){r="Variable `"+t.car.name+"' is not a function"}else{r="Expression `"+t.car.toString()+"' is not a function"}throw new Error(r)}}var r=function e(r){u(r);var n=V(t.cdr.car,{env:i,dynamic_scope:a,error:o});n=i.get("list->array")(n);if(n.filter(q).length){return Promise.all(n).then(function(e){return r.apply(i,e)})}else{return r.apply(i,n)}};var n=V(t.car,{env:this,dynamic_scope:a,error:o});if(q(n)){return n.then(r)}else{return r(n)}}),length:function e(r){if(!r){return F(0)}if(r instanceof k){return F(r.length())}if("length"in r){return F(r.length)}},find:function(){var n=ie(te.mark(function e(n,t){var i,a;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=this.get("list->array")(t);a=0;case 2:if(!(a1?t-1:0),a=1;a1?i-1:0),o=1;oarray")(e)});c=[];f=0;case 4:if(!(f2&&f[2]!==h?f[2]:null;a=this.get("list->array")(t);if(!(t.length===0)){r.next=4;break}return r.abrupt("return",x);case 4:o=i;if(i===null){o=a.unshift()}u=0;case 7:if(!(uarray")(t);a=[];o=0;case 3:if(!(o1?r-1:0),t=1;t=o){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}},odd:function e(r){return F(r).isOdd()},even:function e(r){return F(r).isEvent()},"*":function e(){for(var r=arguments.length,n=new Array(r),t=0;t":function e(r,n){return F(r).cmp(n)===1},"<":function e(r,n){return F(r).cmp(n)===-1},"<=":function e(r,n){return[0,-1].includes(F(r).cmp(n))},">=":function e(r,n){return[0,1].includes(F(r).cmp(n))},"eq?":E,or:new S("or",function(e,r){var o=r.dynamic_scope,u=r.error;var c=this.get("list->array")(e);var f=this;if(o){o=f}return new Promise(function(i){var a;(function r(){function e(e){a=e;if(a){i(e)}else{r()}}var n=c.shift();if(typeof n==="undefined"){if(a){i(a)}else{i(false)}}else{var t=V(n,{env:f,dynamic_scope:o,error:u});if(q(t)){t.then(e)}else{e(t)}}})()})}),and:new S("and",function(e){var r=arguments.length>1&&arguments[1]!==h?arguments[1]:{},o=r.dynamic_scope,u=r.error;var c=this.get("list->array")(e);var f=this;if(o){o=f}return new Promise(function(i){var a;(function r(){function e(e){a=e;if(!a){i(false)}else{r()}}var n=c.shift();if(typeof n==="undefined"){if(a){i(a)}else{i(false)}}else{var t=V(n,{env:f,dynamic_scope:o,error:u});if(q(t)){t.then(e)}else{e(t)}}})()})}),"|":function e(r,n){return F(r).or(n)},"&":function e(r,n){return F(r).and(n)},"~":function e(r){return F(r).neg()},">>":function e(r,n){return F(r).shr(n)},"<<":function e(r,n){return F(r).shl(n)},not:function e(r){if(A(r)){return true}return!r},"->":function e(r,n){for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a1&&arguments[1]!==h?arguments[1]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||G}else if(n===true){n=t=G}else{n=n||G}var o={env:n,dynamic_scope:t,error:a};var u;if(O(r)){return r}if(A(r)){return _()}var c=r.car;var f=r.cdr;if(c instanceof k){u=C(V(c,o));if(q(u)){return u.then(function(e){return V(new k(e,r.cdr),o)})}else if(typeof u!=="function"){throw new Error(n.get("string")(u)+" is not a function"+" while evaluating "+c.toString())}}if(c instanceof w){u=n.get(c);if(u instanceof S){return Q(u,f,o)}else if(typeof u!=="function"){if(u){var s="".concat(U(u)," `").concat(u,"' is not a function");throw new Error(s)}throw new Error("Unknown function `".concat(c.name,"'"))}}else if(typeof c==="function"){u=c}if(typeof u==="function"){var l=H(f,o);if(q(l)){return l.then(function(e){var r=t||n;return I(C(u.apply(r,e)))})}return I(C(u.apply(t||n,l)))}else if(r instanceof w){u=n.get(r);if(u==="undefined"){throw new Error("Unbound variable `"+r.name+"'")}return u}else if(r instanceof k){u=c&&c.toString();throw new Error("".concat(U(c)," ").concat(u," is not a function"))}else{return r}}catch(e){a&&a(e,r)}}function Y(e,r,n){return z.apply(this,arguments)}function z(){z=ie(te.mark(function e(n,t,i){var a,o,u,c;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(i===true){t=i=t||G}else if(t===true){t=i=G}else{t=t||G}a=v(p(n));o=[];case 3:u=a.shift();if(u){r.next=9;break}return r.abrupt("return",o);case 9:r.next=11;return V(u,{env:t,dynamic_scope:i,error:function e(r,n){r.code=n.toString();throw r}});case 11:c=r.sent;o.push(c);case 13:r.next=3;break;case 15:case"end":return r.stop()}}},e)}));return z.apply(this,arguments)}function X(r){return function(e){if(!e){return false}return(e.token||e).match(r)}}var K=X(/[()]/);function W(e){var r=typeof e==="string"?p(e):e;var n=r.filter(K);var t=n.filter(function(e){return(e.token||e)===")"});var i=n.filter(function(e){return(e.token||e)==="("});return t.length===i.length}k.unDry=function(e){return new k(e.car,e.cdr)};k.prototype.toDry=function(){return{value:{car:this.car,cdr:this.cdr}}};b.prototype.toDry=function(){return{value:null}};b.unDry=function(){return x};w.prototype.toDry=function(){return{value:{name:this.name}}};w.unDry=function(e){return new w(e.name)};function Z(){var t="text/x-lips";if(window.document){Array.from(document.querySelectorAll("script")).forEach(function(e){var r=e.getAttribute("type");if(r===t){var n=e.getAttribute("src");if(n){a.fetch(n).then(function(e){return e.text()}).then(Y)}else{Y(e.innerHTML)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+t+" found "+r)}})}}function ee(r){if(typeof window!=="undefined"){if(window.addEventListener){window.addEventListener("load",r,false)}else if(window.attachEvent){window.attachEvent("onload",r)}else if(typeof window.onload==="function"){(function(e){window.onload=function(){r();e()}})(window.onload)}else{window.onload=r}}}ee(function(){setTimeout(Z,0)});return{version:"DEV",exec:Y,parse:v,tokenize:p,evaluate:V,Environment:T,global_environment:G,env:G,balanced_parenthesis:W,Macro:S,quote:I,Pair:k,Formatter:c,nil:x,maybe_promise:C,Symbol:w,LNumber:F}})})(); \ No newline at end of file +(function(r,n){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=n(r,e)})}else if((typeof module==="undefined"?"undefined":oe(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof window!=="undefined"?window:global,function(a,n,h){if(!a.fetch){a.fetch=function(i,a){a=a||{};return new Promise(function(e,r){var n=new XMLHttpRequest;n.open(a.method||"get",i,true);for(var t in a.headers){n.setRequestHeader(t,a.headers[t])}n.withCredentials=a.credentials=="include";n.onload=function(){e(u())};n.onerror=r;n.send(a.body||null);function u(){var t=[],i=[],a={},o;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);o=a[r];a[r]=o?"".concat(o,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:u,text:function e(){return Promise.resolve(n.responseText)},json:function e(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function e(){return Promise.resolve(new Blob([n.response]))},headers:{keys:function e(){return t},entries:function e(){return i},get:function e(r){return a[r.toLowerCase()]},has:function e(r){return r.toLowerCase()in a}}}}})}}var t=/^\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;var i=/^[-+]?[0-9]+([eE][-+]?[0-9]+)?$/;var o=/^([-+]?((\.[0-9]+|[0-9]+\.[0-9]+)([eE][-+]?[0-9]+)?)|[0-9]+\.)$/;function d(e){function r(e){if(e.match(/^['"]/)){if(e==='""'||e==="''"){return""}var r=e[0];var n=new RegExp("((^|[^\\\\])(?:\\\\\\\\)*)"+r,"g");e=e.replace(n,"$1")}return JSON.parse('"'+e.replace(/\n/g,"\\n")+'"')}var n=e.match(t);if(n){return new RegExp(n[1],n[2])}else if(e.match(/['"]/)){return r(e)}else if(e.match(i)){return F(parseFloat(e))}else if(e.match(o)){return F(parseFloat(e),true)}else if(e==="nil"){return x}else if(e==="true"){return true}else if(e==="false"){return false}else{return new w(e)}}var f=/("(?:\\[\S\s]|[^"])*"|\/(?! )[^\/\\]*(?:\\[\S\s][^\/\\]*)*\/[gimy]*(?=\s|\(|\)|$)|;.*)/g;var s=/("(?:\\[\S\s]|[^"])*"|\/(?! )[^\/\\]*(?:\\[\S\s][^\/\\]*)*\/[gimy]*(?=\s|\(|\)|$)|\(|\)|'|"(?:\\[\S\s]|[^"])+|\n|(?:\\[\S\s]|[^"])*"|;.*|(?:[-+]?(?:(?:\.[0-9]+|[0-9]+\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\.)[0-9]|\.{2,}|\.|,@|,|`|[^(\s)]+)/gim;function l(e){return e[e.length-1]}function u(e){e=e.replace(/\n\r|\r/g,"\n");var i=0;var a=0;var o=[];var u=[];var c=0;e.split(f).filter(Boolean).forEach(function(e){if(e.match(f)){c=0;if(u.length){var r=l(u);if(r.token.match(/\n/)){var n=r.token.split("\n").pop();c+=n.length}else{c+=r.token.length}c+=r.col}var t={col:c,line:a,token:e,offset:i};o.push(t);u.push(t);i+=e.length;c+=e.length;a+=(e.match("\n")||[]).length;return}e.split(s).filter(Boolean).forEach(function(e){var r={col:c,line:a,token:e,offset:i};c+=e.length;i+=e.length;o.push(r);u.push(r);if(e==="\n"){++a;u=[];c=0}})});return o}function p(e,r){if(r){return u(e)}else{return u(e).map(function(e){return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)})}}var y={"'":new w("quote"),"`":new w("quasiquote"),",":new w("unquote"),",@":new w("unquote-splicing")};function v(e){var a=[];var o=[];var u=null;var c=Object.keys(y);var r=c.map(function(e){return y[e].name});var f=0;var s=false;var l=[];var h=[];var p=0;function v(){var e=a[a.length-1];if(e instanceof Array&&e[0]instanceof w&&r.includes(e[0].name)&&a.length>1){a.pop();if(a[a.length-1].length===1&&a[a.length-1][0]instanceof w){a[a.length-1].push(e)}else if(a[a.length-1].length===0){a[a.length-1]=e}else if(a[a.length-1]instanceof k){if(a[a.length-1].cdr instanceof k){a[a.length-1]=new k(a[a.length-1],k.fromArray(e))}else{a[a.length-1].cdr=k.fromArray(e)}}else{a[a.length-1].push(e)}}}e.forEach(function(e){var r=a[a.length-1];if(c.indexOf(e)!==-1){p++;u=e;a.push([y[u]]);if(!u){h=[]}h.push(u)}else{if(u){l.push(h);h=[]}if(e==="("){s=true;f++;a.push([]);u=null;p=0}else if(e==="."&&!s){a[a.length-1]=k.fromArray(r)}else if(e===")"){f--;if(!a.length){throw new Error("Unbalanced parenthesis")}if(a.length===1){o.push(a.pop())}else if(a.length>1){var n=a.pop();r=a[a.length-1];if(r instanceof Array){r.push(n)}else if(r instanceof k){r.append(k.fromArray(n))}if(l.length){h=l.pop();while(h.length){v();h.pop()}}else{v()}}if(f===0&&a.length){o.push(a.pop())}}else{s=false;var t=d(e);if(u){while(p--){a[a.length-1][1]=t;t=a.pop()}p=0;u=false}r=a[a.length-1];if(r instanceof k){var i=r;while(true){if(i.cdr===x){if(t instanceof Array){i.cdr=k.fromArray(t)}else{i.cdr=t}break}else{i=i.cdr}}}else if(!a.length){o.push(t)}else{r.push(t)}}}});if(a.length){throw new Error("Unbalanced parenthesis 2")}return o.map(function(e){if(e instanceof Array){return k.fromArray(e)}return e})}function m(e){var r=1;var n=e.length;while(r>0){var t=e[--n];if(!t){return}if(t.token==="("){r--}else if(t.token===")"){r++}}return e.slice(n)}function g(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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function c(e){this._code=e.replace(/\r/g,"")}c.defaults={offset:0,indent:2,specials:["define","lambda","let","let*","define-macro"]};c.prototype._options=function e(r){var n=c.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.specials||[];return Object.assign({},n,r,{specials:n.specials.concat(t)})};c.prototype.indent=function e(r){var n=p(this._code,true);return this._indent(n,r)};c.prototype._indent=function e(r,n){var t=this._options(n);var i=g(r);var a=t.specials;var o=m(r);if(o){if(o[0].line>0){t.offset=0}if(o.length===1){return t.offset+o[0].col+1}else if(a.indexOf(o[1].token)!==-1){return t.offset+o[0].col+t.indent}else if(o[0].line3&&o[1].line===o[3].line){if(o[1].token==="("){return t.offset+o[1].col}return t.offset+o[3].col}else if(o[0].line===o[1].line){return t.offset+t.indent+o[0].col}else{var u=o.slice(2);for(var c=0;c")}else if(typeof this.car==="string"){e.push(JSON.stringify(this.car))}else if(this.car instanceof w){e.push(this.car.toString())}else if(typeof this.car!=="undefined"){e.push(this.car)}if(this.cdr instanceof k){e.push(" ");e.push(this.cdr.toString().replace(/^\(|\)$/g,""))}else if(typeof this.cdr!=="undefined"&&this.cdr!==x){if(typeof this.cdr==="string"){e=e.concat([" . ",JSON.stringify(this.cdr)])}else{e=e.concat([" . ",this.cdr])}}}e.push(")");return e.join("")};k.prototype.append=function(e){if(e instanceof Array){return this.append(k.fromArray(e))}var r=this;if(r.car===h){if(e instanceof k){this.car=e.car;this.cdr=e.cdr}else{return e}}else{while(true){if(r instanceof k&&r.cdr!==x){r=r.cdr}else{break}}r.cdr=e}return this};function E(e,r){if(e instanceof F&&r instanceof F){return e.cmp(r)===0}else if(typeof e==="number"||typeof r==="number"){return F(e).cmp(F(r))}else if(e instanceof w&&r instanceof w){return e.name===r.name}else{return e===r}}function A(e){return e instanceof k&&e.isEmptyList()||e===x}function S(e,r){if(typeof this!=="undefined"&&this.constructor!==S||typeof this==="undefined"){return new S(e,r)}this.name=e;this.fn=r}S.defmacro=function(e,r){var n=new S(e,r);n.defmacro=true;return n};S.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var o={dynamic_scope:i,error:a,macro_expand:n};var u=this.fn.call(t,e,o,this.name);return n?I(u):u};S.prototype.toString=function(){return"#"};var N="define-macro";function j(a){return function(){var n=ie(te.mark(function e(n,c){var f,s,t,i;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=function e(){t=ie(te.mark(function e(n){var t,i,a,o,u;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(n instanceof k&&n.car instanceof w)){r.next=13;break}r.prev=1;t=f.get(n.car);if(!(t instanceof S&&t.defmacro)){r.next=9;break}r.next=6;return t.invoke(n.cdr,c,true);case 6:i=r.sent;if(!(i instanceof k)){r.next=9;break}return r.abrupt("return",i);case 9:r.next=13;break;case 11:r.prev=11;r.t0=r["catch"](1);case 13:a=n.car;if(!(a instanceof k)){r.next=18;break}r.next=17;return s(a);case 17:a=r.sent;case 18:o=n.cdr;if(!(o instanceof k)){r.next=23;break}r.next=22;return s(o);case 22:o=r.sent;case 23:u=new k(a,o);return r.abrupt("return",u);case 25:case"end":return r.stop()}}},e,null,[[1,11]])}));return t.apply(this,arguments)};s=function e(r){return t.apply(this,arguments)};f=c["env"]=this;i=n;if(!a){r.next=12;break}r.t0=I;r.next=8;return s(n);case 8:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 12:r.next=15;return s(n);case 15:i=r.sent;if(!(n.toString()===i.toString())){r.next=18;break}return r.abrupt("break",21);case 18:n=i;r.next=12;break;case 21:return r.abrupt("return",I(i.car));case 22:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function O(e){return typeof e==="undefined"||e===x||e===null}function L(e){return typeof e==="function"&&e.toString().match(/\{\s*\[native code\]\s*\}/)}function q(e){return e instanceof Promise||typeof e!=="undefined"&&typeof e.then==="function"}function P(e,a){var o=function e(){for(var r=arguments.length,n=new Array(r),t=0;t2?r-2:0),t=2;t1?n-1:0),i=1;i1?r-1:0),t=1;tarray")(o.car);var l=s.inherit("let");var h=0;return function e(){var r=f[h++];function n(e){if(q(e)){return e.then(n)}else if(typeof e==="undefined"){l.set(r.car,x)}else{l.set(r.car,e)}}if(u){u=p?l:s}if(!r){var t=new k(new w("begin"),o.cdr);return Y(t,{env:l,dynamic_scope:u,error:c})}else{var i=Y(r.cdr.car,{env:p?l:s,dynamic_scope:u,error:c});var a=n(i);if(q(a)){return a.then(e)}else{return e()}}}()})}function F(e,r){if(typeof this!=="undefined"&&this.constructor!==F||typeof this==="undefined"){return new F(e,r===true?true:h)}if(e instanceof F){return F(e.value,e.float)}if(!F.isNumber(e)){throw new Error("You can't create LNumber from "+oe(e))}if(e===null){e=0}if(F.isFloat(e)){this.value=e}else if(r){this.value=e;this.float=true}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){this.value=BigInt(e)}else{this.value=e}}else if(typeof n!=="undefined"&&!(e instanceof n)){this.value=new n(e)}else{this.value=e}}F.isFloat=function e(r){return Number(r)===r&&r%1!==0};F.isNumber=function(e){return e instanceof F||!Number.isNaN(e)&&F.isNative(e)||F.isBN(e)};F.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};F.isBN=function(e){return typeof n!=="undefined"&&e instanceof n};F.prototype.toString=F.prototype.toJSON=function(){return this.value.toString()};F.prototype.isBigNumber=function(){return typeof this.value==="bigint"||typeof n!=="undefined"&&!(this.value instanceof n)};["floor","ceil","round"].forEach(function(e){F.prototype[e]=function(){if(this.float||F.isFloat(this.value)){return F(Math[e](this.value))}else{return F(this.value)}}});F.prototype.valueOf=function(){if(F.isNative(this.value)){return Number(this.value)}else if(F.isBN(this.value)){return this.value.toNumber()}};F.prototype.coerce=function(e){if(e===null){e=0}var r;if(e instanceof F){r=e.value}else{r=e}if(F.isFloat(r)){}else if(typeof this.value==="bigint"&&typeof r!=="bigint"){r=BigInt(r)}else if(typeof n!=="undefined"&&this.value instanceof n&&!r instanceof n){r=new n(r)}return F(r)};F.prototype.op=function(e,r){var n={"*":function e(r,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){return r-n},"/":function e(r,n){return r/n},"%":function e(r,n){return r%n},"|":function e(r,n){return r|n},"&":function e(r,n){return r&n},"~":function e(r){return~r},">>":function e(r,n){return r>>n},"<<":function e(r,n){return r<>":"ishln"};e=i[e];return F(this.value.clone()[e](r,t))}};var R={"+":"add","-":"sub","*":"mul","/":"div","%":"mod","|":"or","&":"and","~":"neg","<<":"shl",">>":"shr"};Object.keys(R).forEach(function(r){F.prototype[R[r]]=function(e){return this.op(r,e)}});F.prototype.sqrt=function(){var e;if(F.isNative(this.value)){e=Math.sqrt(this.value)}else if(F.isBN(this.value)){e=this.value.sqrt()}return new F(e)};F.prototype.pow=function(e){e=this.coerce(e);if(F.isNative(this.value)){try{var r=new Function("a,b","return a**b;");e.value=r(this.value,e.value)}catch(e){throw new Error("Power operator not supported")}}else if(F.isBN(this.value)){e.value=this.value.pow(e.value)}else{e.value=Math.pow(this.value,e.value)}return e};F.prototype.neg=function(){var e=this.value;if(F.isNative(e)){e=-e}else if(F.isBN(e)){e=e.neg()}return new F(e)};F.prototype.abs=function(){var e=this.value;if(F.isNative(this.value)){if(e<0){e=-e}}else if(F.isBN(e)){e.iabs()}return new F(e)};F.prototype.isOdd=function(){if(F.isNative(this.value)){return this.value%2===1}else if(F.isBN(this.value)){return this.value.isOdd()}};F.prototype.isEven=function(){return!this.isOdd()};F.prototype.cmp=function(e){e=this.coerce(e);if(F.isNative(this.value)){if(this.value1&&arguments[1]!==h?arguments[1]:{};if(oe(e)==="object"){r=e}if(!e||oe(e)==="object"){e="child of "+(this.name||"unknown")}return new T(r||{},this,e)};T.prototype.get=function(e){var r;var n=false;if(e instanceof w){if(e.name in this.env){r=this.env[e.name];n=true}}else if(typeof e==="string"){if(typeof this.env[e]!=="undefined"){r=this.env[e];n=true}}if(n){if(F.isNumber(r)){return F(r)}if(typeof r==="function"){return P(r,this)}return r}if(this.parent instanceof T){return this.parent.get(e)}else{var t;if(e instanceof w){t=e.name}else if(typeof e==="string"){t=e}if(t){var i=oe(a[t]);if(i==="function"){if(L(a[t])){return a[t].bind(a)}else{return a[t]}}else if(i!=="undefined"){return a[t]}}}t=(t.name||t).toString();throw new Error("Unbound variable `"+t+"'")};T.prototype.set=function(e,r){if(F.isNumber(r)){r=F(r)}if(e instanceof w){e=e.name}this.env[e]=r};T.prototype.has=function(e){return typeof this.env[e]!=="undefined"};T.prototype.ref=function(e){var r=this;while(true){if(!r){break}if(r.has(e)){return r}r=r.parent}};function I(e){if(q(e)){return e.then(I)}if(e instanceof k||e instanceof w){e.data=true}return e}function M(e,r){this.value=e;this.count=r}M.prototype.toString=function(){return"<#unquote["+this.count+"] "+this.value+">"};var D=function(){var r=0;return function(){var e=arguments.length>0&&arguments[0]!==h?arguments[0]:null;if(e!==null){return new w(a.Symbol("#"+e))}r++;return new w(a.Symbol("#gensym_"+r))}}();var G=new T({nil:x,undefined:h,true:true,NaN:NaN,false:false,stdout:{write:function e(){var r;(r=console).log.apply(r,arguments)}},stdin:{read:function e(){return new Promise(function(e){e(prompt(""))})}},this:function e(){return this},cons:function e(r,n){if(A(n)){n=x}return new k(r,n)},car:function e(r){if(r instanceof k){return r.car}else{throw new Error("argument to car need to be a list")}},cdr:function e(r){if(r instanceof k){return r.cdr}else{throw new Error("argument to cdr need to be a list")}},"set!":new S("set!",function(r){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},n=e.dynamic_scope,t=e.error;if(n){n=this}var i=Y(r.cdr.car,{env:this,dynamic_scope:n,error:t});i=C(i);var a;if(r.car instanceof k&&w.is(r.car.car,".")){var o=r.car.cdr.car;var u=r.car.cdr.cdr.car;var c=Y(o,{env:this,dynamic_scope:n,error:t});var f=Y(u,{env:this,dynamic_scope:n,error:t});if(q(i)){return i.then(function(e){c[f]=e})}else{c[f]=i;return i}}if(!(r.car instanceof w)){throw new Error("set! first argument need to be a symbol")}a=this.ref(r.car.name);if(!a){a=this}if(q(i)){return i.then(function(e){return a.set(r.car,e)})}else{a.set(r.car,i)}}),"set-car!":function e(r,n){r.car=n},"set-cdr!":function e(r,n){r.cdr=n},"empty?":function e(r){return typeof r==="undefined"||A(r)},assoc:function e(r,n){if(r instanceof k&&!(n instanceof k)){throw new Error("First argument to assoc new to a key")}var t=n;while(true){if(!(t instanceof k)||this.get("empty?")(t)){break}var i=t.car.car;if(E(i,r)){return t.car}else{t=t.cdr}}return x},gensym:D,load:function e(r){var n=this;a.fetch(r).then(function(e){return e.text()}).then(function(e){n.get("eval")(n.get("read")(e))})},while:new S("while",function(){var n=ie(te.mark(function e(n,t){var i,a,o,u,c,f;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=t.dynamic_scope,a=t.error;o=this;u=new k(new w("begin"),n.cdr);if(i){i=o}case 4:r.next=7;return Y(n.car,{env:o,dynamic_scope:i,error:a});case 7:f=r.sent;if(!(f&&!A(f))){r.next=14;break}r.next=11;return Y(u,{env:o,dynamic_scope:i,error:a});case 11:c=r.sent;r.next=15;break;case 14:return r.abrupt("return",c);case 15:r.next=4;break;case 17:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()),if:new S("if",function(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(typeof r!=="boolean"){throw new Error("if: value need to be boolean")}if(r){return Y(n.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return Y(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}};var o=Y(n.car,{env:a,dynamic_scope:t,error:i});if(q(o)){return o.then(r)}else{return r(o)}}),"let*":B(true),let:B(false),begin:new S("begin",function(e,r){var n=r.dynamic_scope,t=r.error;var i=this.get("list->array")(e);if(n){n=this}var a=this;var o;return function r(){if(i.length){var e=i.shift();o=Y(e,{env:a,dynamic_scope:n,error:t});if(q(o)){return o.then(function(e){o=e;return r()})}else{return r()}}else{return o}}()}),nop:function e(){},timer:new S("timer",function(r){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},n=e.dynamic_scope,t=e.error;var i=this;if(n){n=this}return new Promise(function(e){setTimeout(function(){e(Y(r.cdr,{env:i,dynamic_scope:n,error:t}))},r.car)})}),define:S.defmacro("define",function(r,e){var n=this;if(r.car instanceof k&&r.car.car instanceof w){var t=new k(new w("define"),new k(r.car.car,new k(new k(new w("lambda"),new k(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=r.cdr.car;if(i instanceof k){i=Y(i,e)}else if(i instanceof w){i=n.get(i)}if(r.car instanceof w){if(q(i)){return i.then(function(e){n.set(r.car,e)})}else{n.set(r.car,i)}}}),"set-obj":function e(r,n,t){r[n]=t},eval:function e(r){var n=this;if(r instanceof k){return Y(r,{env:this,dynamic_scope:this,error:function e(r){return n.get("print")(r.message)}})}if(r instanceof Array){var t;r.forEach(function(e){t=Y(e,{env:n,dynamic_scope:n,error:function e(r){return n.get("print")(r.message)}})});return t}},lambda:new S("lambda",function(c){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},f=e.dynamic_scope,s=e.error;var l=this;function r(){var e=(f?this:l).inherit("lambda");var r=c.car;var n=0;var t;if(r instanceof w||!A(r)){for(var i=arguments.length,a=new Array(i),o=0;op){p=u}if(!(o===a)){r.next=43;break}if(!(n.cdr.cdr!==x)){r.next=40;break}r.t5=k;r.t6=new M(n.cdr.car,u);r.next=36;return v(n.cdr.cdr);case 36:r.t7=r.sent;return r.abrupt("return",new r.t5(r.t6,r.t7));case 40:return r.abrupt("return",new M(n.cdr.car,u));case 41:r.next=58;break;case 43:if(!(o.cdr.cdr!==x)){r.next=57;break}r.t8=k;r.t9=new M(a,u);if(!(o.cdr===x)){r.next=50;break}r.t10=x;r.next=53;break;case 50:r.next=52;return v(o.cdr.cdr);case 52:r.t10=r.sent;case 53:r.t11=r.t10;o.car.cdr=new r.t8(r.t9,r.t11);r.next=58;break;case 57:o.car.cdr=new M(a,u);case 58:return r.abrupt("return",i.car);case 59:c=n.car;f=n.cdr;if(!(c instanceof k)){r.next=65;break}r.next=64;return v(c);case 64:c=r.sent;case 65:if(!(f instanceof k)){r.next=69;break}r.next=68;return v(f);case 68:f=r.sent;case 69:return r.abrupt("return",new k(c,f));case 70:return r.abrupt("return",n);case 71:case"end":return r.stop()}}},e)}));return n.apply(this,arguments)}function a(e){return t.apply(this,arguments)}function t(){t=ie(te.mark(function e(n){var t,i;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!(n instanceof M)){r.next=14;break}if(!(p===n.count)){r.next=5;break}return r.abrupt("return",Y(n.value,{env:h,dynamic_scope:s,error:l}));case 5:r.t0=k;r.t1=new w("unquote");r.t2=k;r.next=10;return a(n.value);case 10:r.t3=r.sent;r.t4=x;r.t5=new r.t2(r.t3,r.t4);return r.abrupt("return",new r.t0(r.t1,r.t5));case 14:if(!(n instanceof k)){r.next=26;break}t=n.car;if(!(t instanceof k||t instanceof M)){r.next=20;break}r.next=19;return a(t);case 19:t=r.sent;case 20:i=n.cdr;if(!(i instanceof k||i instanceof M)){r.next=25;break}r.next=24;return a(i);case 24:i=r.sent;case 25:return r.abrupt("return",new k(t,i));case 26:return r.abrupt("return",n);case 27:case"end":return r.stop()}}},e)}));return t.apply(this,arguments)}return v(e.car).then(a).then(I)}),clone:function e(r){return r.clone()},append:function e(r,n){return r.clone().append([n])},reverse:function e(r){if(r instanceof k){var n=this.get("list->array")(r).reverse();return this.get("array->list")(n)}else if(!(r instanceof Array)){throw new Error("Invlid value for reverse")}else{return r.reverse()}},nth:function e(r,n){if(n instanceof k){var t=n;var i=0;while(iarray")(n).join(r)},split:function e(r,n){return this.get("array->list")(r.split(n))},replace:function e(r,n,t){return r.replace(n,t)},match:function e(r,n){return this.get("array->list")(r.match(n))},search:function e(r,n){return r.search(n)},string:function r(e,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"<#jQuery("+e.length+")>"}if(e instanceof F){return e.value.toString()}if(typeof e==="undefined"){return"<#undefined>"}if(typeof e==="function"){if(L(e)){return"<#function(native)>"}return"<#function>"}if(e===x){return"nil"}if(e instanceof Array){return"["+e.map(function(e){return r(e,true)}).join(", ")+"]"}if(e===null||typeof e==="string"&&n){return JSON.stringify(e)}if(e instanceof k||e instanceof w){return e.toString()}if(oe(e)==="object"){var t=e.constructor.name;if(t!==""){return"<#"+t+">"}return"<#Object>"}if(typeof e!=="string"){return e.toString()}return e},env:function e(r){r=r||this;var n=Object.keys(r.env);var t;if(n.length){t=k.fromArray(n)}else{t=x}if(r.parent!==h){return this.get("env").call(this,r.parent).append(t)}return t},new:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;ilist":function e(r){return k.fromArray(r)},"list->array":function e(r){if(r instanceof k&&r.isEmptyList()){return[]}var n=[];var t=r;while(true){if(t instanceof k){n.push(t.car);t=t.cdr}else{break}}return n},apply:new S("apply",function(t){var i=this;var e=arguments.length>1&&arguments[1]!==h?arguments[1]:{},a=e.dynamic_scope,o=e.error;if(a){a=this}function u(e){if(typeof e!=="function"){var r;if(t.car instanceof w){r="Variable `"+t.car.name+"' is not a function"}else{r="Expression `"+t.car.toString()+"' is not a function"}throw new Error(r)}}var r=function e(r){u(r);var n=Y(t.cdr.car,{env:i,dynamic_scope:a,error:o});n=i.get("list->array")(n);if(n.filter(q).length){return Promise.all(n).then(function(e){return r.apply(i,e)})}else{return r.apply(i,n)}};var n=Y(t.car,{env:this,dynamic_scope:a,error:o});if(q(n)){return n.then(r)}else{return r(n)}}),length:function e(r){if(!r){return F(0)}if(r instanceof k){return F(r.length())}if("length"in r){return F(r.length)}},find:function(){var n=ie(te.mark(function e(n,t){var i,a;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:i=this.get("list->array")(t);a=0;case 2:if(!(a1?t-1:0),a=1;a1?i-1:0),o=1;oarray")(e)});c=[];f=0;case 4:if(!(f2&&f[2]!==h?f[2]:null;a=this.get("list->array")(t);if(!(t.length===0)){r.next=4;break}return r.abrupt("return",x);case 4:o=i;if(i===null){o=a.unshift()}u=0;case 7:if(!(uarray")(t);a=[];o=0;case 3:if(!(o1?r-1:0),t=1;t=o){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}},odd:function e(r){return F(r).isOdd()},even:function e(r){return F(r).isEvent()},"*":function e(){for(var r=arguments.length,n=new Array(r),t=0;t":function e(r,n){return F(r).cmp(n)===1},"<":function e(r,n){return F(r).cmp(n)===-1},"<=":function e(r,n){return[0,-1].includes(F(r).cmp(n))},">=":function e(r,n){return[0,1].includes(F(r).cmp(n))},"eq?":E,or:new S("or",function(e,r){var o=r.dynamic_scope,u=r.error;var c=this.get("list->array")(e);var f=this;if(o){o=f}return new Promise(function(i){var a;(function r(){function e(e){a=e;if(a){i(e)}else{r()}}var n=c.shift();if(typeof n==="undefined"){if(a){i(a)}else{i(false)}}else{var t=Y(n,{env:f,dynamic_scope:o,error:u});if(q(t)){t.then(e)}else{e(t)}}})()})}),and:new S("and",function(e){var r=arguments.length>1&&arguments[1]!==h?arguments[1]:{},o=r.dynamic_scope,u=r.error;var c=this.get("list->array")(e);var f=this;if(o){o=f}return new Promise(function(i){var a;(function r(){function e(e){a=e;if(!a){i(false)}else{r()}}var n=c.shift();if(typeof n==="undefined"){if(a){i(a)}else{i(false)}}else{var t=Y(n,{env:f,dynamic_scope:o,error:u});if(q(t)){t.then(e)}else{e(t)}}})()})}),"|":function e(r,n){return F(r).or(n)},"&":function e(r,n){return F(r).and(n)},"~":function e(r){return F(r).neg()},">>":function e(r,n){return F(r).shr(n)},"<<":function e(r,n){return F(r).shl(n)},not:function e(r){if(A(r)){return true}return!r},"->":function e(r,n){for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a1&&arguments[1]!==h?arguments[1]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||G}else if(n===true){n=t=G}else{n=n||G}var o={env:n,dynamic_scope:t,error:a};var u;if(O(r)){return r}if(A(r)){return _()}var c=r.car;var f=r.cdr;if(c instanceof k){u=C(Y(c,o));if(q(u)){return u.then(function(e){return Y(new k(e,r.cdr),o)})}else if(typeof u!=="function"){throw new Error(n.get("string")(u)+" is not a function"+" while evaluating "+c.toString())}}if(c instanceof w){u=n.get(c);if(u instanceof S){return Q(u,f,o)}else if(typeof u!=="function"){if(u){var s="".concat(U(u)," `").concat(u,"' is not a function");throw new Error(s)}throw new Error("Unknown function `".concat(c.name,"'"))}}else if(typeof c==="function"){u=c}if(typeof u==="function"){var l=H(f,o);if(q(l)){return l.then(function(e){var r=t||n;return I(C(u.apply(r,e)))})}return I(C(u.apply(t||n,l)))}else if(r instanceof w){u=n.get(r);if(u==="undefined"){throw new Error("Unbound variable `"+r.name+"'")}return u}else if(r instanceof k){u=c&&c.toString();throw new Error("".concat(U(c)," ").concat(u," is not a function"))}else{return r}}catch(e){a&&a(e,r)}}function V(e,r,n){return z.apply(this,arguments)}function z(){z=ie(te.mark(function e(n,t,i){var a,o,u,c;return te.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(i===true){t=i=t||G}else if(t===true){t=i=G}else{t=t||G}a=v(p(n));o=[];case 3:u=a.shift();if(u){r.next=9;break}return r.abrupt("return",o);case 9:r.next=11;return Y(u,{env:t,dynamic_scope:i,error:function e(r,n){r.code=n.toString();throw r}});case 11:c=r.sent;o.push(c);case 13:r.next=3;break;case 15:case"end":return r.stop()}}},e)}));return z.apply(this,arguments)}function X(r){return function(e){if(!e){return false}return(e.token||e).match(r)}}var K=X(/[()]/);function W(e){var r=typeof e==="string"?p(e):e;var n=r.filter(K);var t=n.filter(function(e){return(e.token||e)===")"});var i=n.filter(function(e){return(e.token||e)==="("});return t.length===i.length}k.unDry=function(e){return new k(e.car,e.cdr)};k.prototype.toDry=function(){return{value:{car:this.car,cdr:this.cdr}}};b.prototype.toDry=function(){return{value:null}};b.unDry=function(){return x};w.prototype.toDry=function(){return{value:{name:this.name}}};w.unDry=function(e){return new w(e.name)};function Z(){var t="text/x-lips";if(window.document){Array.from(document.querySelectorAll("script")).forEach(function(e){var r=e.getAttribute("type");if(r===t){var n=e.getAttribute("src");if(n){a.fetch(n).then(function(e){return e.text()}).then(V)}else{V(e.innerHTML)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+t+" found "+r)}})}}function ee(r){if(typeof window!=="undefined"){if(window.addEventListener){window.addEventListener("load",r,false)}else if(window.attachEvent){window.attachEvent("onload",r)}else if(typeof window.onload==="function"){(function(e){window.onload=function(){r();e()}})(window.onload)}else{window.onload=r}}}ee(function(){setTimeout(Z,0)});return{version:"0.9.1",exec:V,parse:v,tokenize:p,evaluate:Y,Environment:T,global_environment:G,env:G,balanced_parenthesis:W,Macro:S,quote:I,Pair:k,Formatter:c,nil:x,maybe_promise:C,Symbol:w,LNumber:F}})})(); \ No newline at end of file diff --git a/package.json b/package.json index 1ac211f0..4998db3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jcubic/lips", - "version": "0.9.0", + "version": "0.9.1", "description": "Simple Scheme Like Lisp in JavaScript", "main": "src/lips.js", "unpkg": "dist/lips.min.js", diff --git a/src/lips.js b/src/lips.js index f0c95501..f6d22bff 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2673,7 +2673,7 @@ function ret(value) { if (value && value.data || !(value instanceof Pair)) { return value; - } else{ + } else { return evaluate(value, eval_args); } }